Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clientOptions doesn't apply on MongoClient #19

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config.bash
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export USERNAME=myuser
# database password to use for USERNAME
export PASSWORD=mypass

# --authenticationDatabase
export AUTHDB=admin

# name of the server to connect to
export MONGO_SERVER=localhost

Expand Down
4 changes: 2 additions & 2 deletions run.simple.bash
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if [[ $DOLOAD = "yes" ]]; then
rm -f $BENCHMARK_TSV

T="$(date +%s)"
java -cp $CLASSPATH:$PWD/src jmongosysbenchload $NUM_COLLECTIONS $DB_NAME $NUM_LOADER_THREADS $NUM_DOCUMENTS_PER_COLLECTION $NUM_DOCUMENTS_PER_INSERT $NUM_INSERTS_PER_FEEDBACK $NUM_SECONDS_PER_FEEDBACK $BENCHMARK_TSV $MONGO_COMPRESSION $MONGO_BASEMENT $WRITE_CONCERN $MONGO_SERVER $MONGO_PORT "$USERNAME" "$PASSWORD"
java -cp $CLASSPATH:$PWD/src jmongosysbenchload $NUM_COLLECTIONS $DB_NAME $NUM_LOADER_THREADS $NUM_DOCUMENTS_PER_COLLECTION $NUM_DOCUMENTS_PER_INSERT $NUM_INSERTS_PER_FEEDBACK $NUM_SECONDS_PER_FEEDBACK $BENCHMARK_TSV $MONGO_COMPRESSION $MONGO_BASEMENT $WRITE_CONCERN $MONGO_SERVER $MONGO_PORT "$USERNAME" "$PASSWORD" "$AUTHDB"
echo "" | tee -a $LOG_NAME
T="$(($(date +%s)-T))"
printf "`date` | sysbench loader duration = %02d:%02d:%02d:%02d\n" "$((T/86400))" "$((T/3600%24))" "$((T/60%60))" "$((T%60))" | tee -a $LOG_NAME
Expand All @@ -53,7 +53,7 @@ if [[ $DOQUERY = "yes" ]]; then
rm -f $BENCHMARK_TSV

T="$(date +%s)"
java -cp $CLASSPATH:$PWD/src jmongosysbenchexecute $NUM_COLLECTIONS $DB_NAME $NUM_WRITER_THREADS $NUM_DOCUMENTS_PER_COLLECTION $NUM_SECONDS_PER_FEEDBACK $BENCHMARK_TSV $SYSBENCH_AUTO_COMMIT $RUN_TIME_SECONDS $SYSBENCH_RANGE_SIZE $SYSBENCH_POINT_SELECTS $SYSBENCH_SIMPLE_RANGES $SYSBENCH_SUM_RANGES $SYSBENCH_ORDER_RANGES $SYSBENCH_DISTINCT_RANGES $SYSBENCH_INDEX_UPDATES $SYSBENCH_NON_INDEX_UPDATES $SYSBENCH_INSERTS $WRITE_CONCERN $MAX_TPS $MONGO_SERVER $MONGO_PORT $SEED "$USERNAME" "$PASSWORD" | tee -a $LOG_NAME
java -cp $CLASSPATH:$PWD/src jmongosysbenchexecute $NUM_COLLECTIONS $DB_NAME $NUM_WRITER_THREADS $NUM_DOCUMENTS_PER_COLLECTION $NUM_SECONDS_PER_FEEDBACK $BENCHMARK_TSV $SYSBENCH_AUTO_COMMIT $RUN_TIME_SECONDS $SYSBENCH_RANGE_SIZE $SYSBENCH_POINT_SELECTS $SYSBENCH_SIMPLE_RANGES $SYSBENCH_SUM_RANGES $SYSBENCH_ORDER_RANGES $SYSBENCH_DISTINCT_RANGES $SYSBENCH_INDEX_UPDATES $SYSBENCH_NON_INDEX_UPDATES $SYSBENCH_INSERTS $WRITE_CONCERN $MAX_TPS $MONGO_SERVER $MONGO_PORT $SEED "$USERNAME" "$PASSWORD" "$AUTHDB" | tee -a $LOG_NAME
echo "" | tee -a $LOG_NAME
T="$(($(date +%s)-T))"
printf "`date` | sysbench benchmark duration = %02d:%02d:%02d:%02d\n" "$((T/86400))" "$((T/3600%24))" "$((T/60%60))" "$((T%60))" | tee -a $LOG_NAME
Expand Down
12 changes: 7 additions & 5 deletions src/jmongosysbenchexecute.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class jmongosysbenchexecute {
public static int serverPort;
public static String userName;
public static String passWord;
public static String authdb;

public static int oltpRangeSize;
public static int oltpPointSelects;
Expand All @@ -71,12 +72,12 @@ public jmongosysbenchexecute() {
}

public static void main (String[] args) throws Exception {
if (args.length != 24) {
if (args.length != 25) {
logMe("*** ERROR : CONFIGURATION ISSUE ***");
logMe("jsysbenchexecute [number of collections] [database name] [number of writer threads] [documents per collection] [seconds feedback] "+
"[log file name] [auto commit Y/N] [runtime (seconds)] [range size] [point selects] "+
"[simple ranges] [sum ranges] [order ranges] [distinct ranges] [index updates] [non index updates] [inserts] [writeconcern] "+
"[max tps] [server] [port] [seed] [username] [password]");
"[max tps] [server] [port] [seed] [username] [password] [authdb]");
System.exit(1);
}

Expand Down Expand Up @@ -104,6 +105,7 @@ public static void main (String[] args) throws Exception {
rngSeed = Long.valueOf(args[21]);
userName = args[22];
passWord = args[23];
authdb = args[24];

maxThreadTPS = (maxTPS / writerThreads) + 1;

Expand Down Expand Up @@ -161,10 +163,10 @@ else if ((myWriteConcern.toLowerCase().equals("safe"))) {
// Credential login is optional.
MongoClient m;
if (userName.isEmpty() || userName.equalsIgnoreCase("none")) {
m = new MongoClient(srvrAdd);
m = new MongoClient(srvrAdd, clientOptions);
} else {
MongoCredential credential = MongoCredential.createCredential(userName, dbName, passWord.toCharArray());
m = new MongoClient(srvrAdd, Arrays.asList(credential));
MongoCredential credential = MongoCredential.createCredential(userName, authdb, passWord.toCharArray());
m = new MongoClient(srvrAdd, Arrays.asList(credential), clientOptions);
}

logMe("mongoOptions | " + m.getMongoOptions().toString());
Expand Down
21 changes: 16 additions & 5 deletions src/jmongosysbenchload.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,17 @@ public class jmongosysbenchload {
public static int serverPort;
public static String userName;
public static String passWord;
public static String authdb;

public static int allDone = 0;

public jmongosysbenchload() {
}

public static void main (String[] args) throws Exception {
if (args.length != 15) {
if (args.length != 16) {
logMe("*** ERROR : CONFIGURATION ISSUE ***");
logMe("jsysbenchload [number of collections] [database name] [number of writer threads] [documents per collection] [documents per insert] [inserts feedback] [seconds feedback] [log file name] [compression type] [basement node size (bytes)] [writeconcern] [server] [port] [username] [password]");
logMe("jsysbenchload [number of collections] [database name] [number of writer threads] [documents per collection] [documents per insert] [inserts feedback] [seconds feedback] [log file name] [compression type] [basement node size (bytes)] [writeconcern] [server] [port] [username] [password] [authdb]");
System.exit(1);
}

Expand All @@ -69,6 +70,7 @@ public static void main (String[] args) throws Exception {
serverPort = Integer.valueOf(args[12]);
userName = args[13];
passWord = args[14];
authdb = args[15];

WriteConcern myWC = new WriteConcern();
if (myWriteConcern.toLowerCase().equals("fsync_safe")) {
Expand Down Expand Up @@ -112,17 +114,26 @@ else if ((myWriteConcern.toLowerCase().equals("safe"))) {
// Credential login is optional.
MongoClient m;
if (userName.isEmpty() || userName.equalsIgnoreCase("none")) {
m = new MongoClient(srvrAdd);
m = new MongoClient(srvrAdd, clientOptions);
} else {
MongoCredential credential = MongoCredential.createCredential(userName, dbName, passWord.toCharArray());
m = new MongoClient(srvrAdd, Arrays.asList(credential));
MongoCredential credential = MongoCredential.createCredential(userName, authdb, passWord.toCharArray());
m = new MongoClient(srvrAdd, Arrays.asList(credential), clientOptions);
}

logMe("mongoOptions | " + m.getMongoOptions().toString());
logMe("mongoWriteConcern | " + m.getWriteConcern().toString());

DB db = m.getDB(dbName);

// skip load if already loaded
DBObject cmd = new BasicDBObject();
cmd.put("collStats", "sbtest1");
CommandResult collStats = db.command(cmd);
if (collStats.ok()) {
logMe("*** ignore load stage because already loaded");
System.exit(1);
}

// determine server type : mongo or tokumx
DBObject checkServerCmd = new BasicDBObject();
CommandResult commandResult = db.command("buildInfo");
Expand Down