From 4e069d89aab1b5e02672790d8d420e156ffb20c9 Mon Sep 17 00:00:00 2001 From: Devika-NH Date: Wed, 3 Dec 2014 14:10:50 +0800 Subject: [PATCH 1/3] Updated "local" DB option to if case --- .../groovy/com/ee/tayra/connector/MongoAuthenticator.groovy | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/com/ee/tayra/connector/MongoAuthenticator.groovy b/src/main/groovy/com/ee/tayra/connector/MongoAuthenticator.groovy index 3100e10..683f323 100644 --- a/src/main/groovy/com/ee/tayra/connector/MongoAuthenticator.groovy +++ b/src/main/groovy/com/ee/tayra/connector/MongoAuthenticator.groovy @@ -68,7 +68,9 @@ class MongoAuthenticator implements Authenticator { } if(!mongo.getDB('admin').authenticate(username, password.toCharArray())) { throw new MongoException("Authentication Failed to $mongo.address.host") - } + } else if (!mongo.getDB('local').authenticate(username, password.toCharArray())) { + throw new MongoException("Authentication Failed to $mongo.address.host") + } true } } From 063868236dd93a7e1c9e8d9c0d4020bfe11fe0ce Mon Sep 17 00:00:00 2001 From: devika Date: Fri, 19 Dec 2014 16:49:35 +0800 Subject: [PATCH 2/3] Adding exit(-1) --- .../com/ee/tayra/command/backup/Backup.groovy | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/groovy/com/ee/tayra/command/backup/Backup.groovy b/src/main/groovy/com/ee/tayra/command/backup/Backup.groovy index 4e47819..390b6f0 100644 --- a/src/main/groovy/com/ee/tayra/command/backup/Backup.groovy +++ b/src/main/groovy/com/ee/tayra/command/backup/Backup.groovy @@ -29,15 +29,12 @@ * official policies, either expressed or implied, of the Tayra Project. ******************************************************************************/ package com.ee.tayra.command.backup - -import groovy.json.JsonSlurper - -import org.bson.types.BSONTimestamp - import com.ee.tayra.connector.MongoAuthenticator import com.ee.tayra.connector.MongoReplSetConnection -import com.ee.tayra.domain.* -import com.ee.tayra.io.* +import com.ee.tayra.domain.Oplog +import com.ee.tayra.io.Copier +import groovy.json.JsonSlurper +import org.bson.types.BSONTimestamp def cli = new CliBuilder(usage:'backup -s [--port=number] -f [--fSize=BackupFileSize] [--fMax=NumberOfRotatingLogs] [-t] [-u username] [-p password] [--sNs=]') cli.with { @@ -165,6 +162,7 @@ try { } } catch (Throwable problem) { console.println "Oops!! Could not perform backup...$problem.message" + Runtime.getRuntime().exit(1); } finally { reader?.close() timestampRecorder.stop() @@ -184,8 +182,8 @@ private printTimestampCaution(timestampRecorder, PrintWriter console) { } else { def timestampJson = new JsonSlurper().parseText(timestamp) - Integer time = timestampJson['ts']['$timestamp']['t'] - Integer inc = timestampJson['ts']['$timestamp']['i'] + Integer time = timestampJson['ts']['$ts'] + Integer inc = timestampJson['ts']['$inc'] def bsonTime = new BSONTimestamp(time, inc) console.println "Backup is starting from: \n $bsonTime ==> (${timestamp})" } From e5bfd6f1bb0c94708b316018062918fc1f9a93a0 Mon Sep 17 00:00:00 2001 From: devika Date: Fri, 19 Dec 2014 16:49:55 +0800 Subject: [PATCH 3/3] Adding "local" DB option --- .../com/ee/tayra/connector/MongoAuthenticator.groovy | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/groovy/com/ee/tayra/connector/MongoAuthenticator.groovy b/src/main/groovy/com/ee/tayra/connector/MongoAuthenticator.groovy index 683f323..133c2a5 100644 --- a/src/main/groovy/com/ee/tayra/connector/MongoAuthenticator.groovy +++ b/src/main/groovy/com/ee/tayra/connector/MongoAuthenticator.groovy @@ -29,11 +29,9 @@ * official policies, either expressed or implied, of the Tayra Project. ******************************************************************************/ package com.ee.tayra.connector - import com.mongodb.CommandFailureException import com.mongodb.MongoClient import com.mongodb.MongoException -import com.mongodb.MongoSocketException class MongoAuthenticator implements Authenticator { @@ -67,10 +65,10 @@ class MongoAuthenticator implements Authenticator { throw new MongoException('Password cannot be empty') } if(!mongo.getDB('admin').authenticate(username, password.toCharArray())) { - throw new MongoException("Authentication Failed to $mongo.address.host") - } else if (!mongo.getDB('local').authenticate(username, password.toCharArray())) { - throw new MongoException("Authentication Failed to $mongo.address.host") - } + if (!mongo.getDB('local').authenticate(username, password.toCharArray())) { + throw new MongoException("Authentication Failed to $mongo.address.host") + } + } true } }