From 7b9cf5f49522f185c5378ae7d32233e4ecc62ad6 Mon Sep 17 00:00:00 2001 From: Jared Rosoff Date: Wed, 13 Mar 2013 10:41:48 -0700 Subject: [PATCH] Updated to current standard write concerns --- mongodb/README.md | 2 +- .../com/yahoo/ycsb/db/AsyncMongoDbClient.java | 27 +++++++++--------- .../java/com/yahoo/ycsb/db/MongoDbClient.java | 28 ++++++++++--------- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/mongodb/README.md b/mongodb/README.md index 1fed1348..dd139c42 100644 --- a/mongodb/README.md +++ b/mongodb/README.md @@ -39,7 +39,7 @@ See the next section for the list of configuration parameters for MongoDB. ### `mongodb.database` (default: `ycsb`) -### `mongodb.writeConcern` (default `safe`) +### `mongodb.writeConcern` (default `acknowledged`, options are `errors_ignored`, `unacknowledged`, `acknowledged`, `journaled`, `replica_acknowledged`) ### `mongodb.maxconnections` (default `10`) diff --git a/mongodb/src/main/java/com/yahoo/ycsb/db/AsyncMongoDbClient.java b/mongodb/src/main/java/com/yahoo/ycsb/db/AsyncMongoDbClient.java index 645b233e..d83fd43e 100644 --- a/mongodb/src/main/java/com/yahoo/ycsb/db/AsyncMongoDbClient.java +++ b/mongodb/src/main/java/com/yahoo/ycsb/db/AsyncMongoDbClient.java @@ -145,32 +145,31 @@ public class AsyncMongoDbClient extends DB { String url = props.getProperty("mongodb.url", "mongodb://localhost:27017"); database = props.getProperty("mongodb.database", "ycsb"); - final String writeConcernType = props.getProperty( - "mongodb.writeConcern", - props.getProperty("mongodb.durability", "safe")) + String writeConcernType = props.getProperty("mongodb.writeConcern", + props.getProperty("mongodb.durability", "acknowledged")) .toLowerCase(); - if ("none".equals(writeConcernType)) { + if ("errors_ignored".equals(writeConcernType)) { writeConcern = Durability.NONE; } - else if ("safe".equals(writeConcernType)) { + else if ("unacknowledged".equals(writeConcernType)) { + writeConcern = Durability.NONE; + } + else if ("acknowledged".equals(writeConcernType)) { writeConcern = Durability.ACK; } - else if ("normal".equals(writeConcernType)) { - writeConcern = Durability.ACK; + else if ("journaled".equals(writeConcernType)) { + writeConcern = Durability.journalDurable(0); } - else if ("fsync_safe".equals(writeConcernType)) { - writeConcern = Durability.fsyncDurable(10000); - } - else if ("replicas_safe".equals(writeConcernType)) { - writeConcern = Durability.replicaDurable(10000); + else if ("replica_acknowledged".equals(writeConcernType)) { + writeConcern = Durability.replicaDurable(2, 0); } else { System.err - .println("ERROR: Invalid durability: '" + .println("ERROR: Invalid writeConcern: '" + writeConcernType + "'. " - + "Must be [ none | safe | normal | fsync_safe | replicas_safe ]"); + + "Must be [ errors_ignored | unacknowledged | acknowledged | journaled | replica_acknowledged ]"); System.exit(1); } diff --git a/mongodb/src/main/java/com/yahoo/ycsb/db/MongoDbClient.java b/mongodb/src/main/java/com/yahoo/ycsb/db/MongoDbClient.java index 792c0418..814eb46e 100644 --- a/mongodb/src/main/java/com/yahoo/ycsb/db/MongoDbClient.java +++ b/mongodb/src/main/java/com/yahoo/ycsb/db/MongoDbClient.java @@ -39,7 +39,7 @@ import com.yahoo.ycsb.DBException; * Properties to set: * * mongodb.url=mongodb://localhost:27017 mongodb.database=ycsb - * mongodb.writeConcern=normal + * mongodb.writeConcern=acknowledged * * @author ypai */ @@ -90,7 +90,9 @@ public class MongoDbClient extends DB { database = props.getProperty("mongodb.database", "ycsb"); String writeConcernType = props.getProperty("mongodb.writeConcern", - "safe").toLowerCase(); + "acknowledged").toLowerCase(); + + // Set connectionpool to size of ycsb thread pool final String maxConnections = props.getProperty( "mongodb.maxconnections", "10"); final String threadsAllowedToBlockForConnectionMultiplier = props @@ -98,27 +100,27 @@ public class MongoDbClient extends DB { "mongodb.threadsAllowedToBlockForConnectionMultiplier", "5"); - if ("none".equals(writeConcernType)) { - writeConcern = WriteConcern.NONE; + if ("errors_ignored".equals(writeConcernType)) { + writeConcern = WriteConcern.ERRORS_IGNORED; } - else if ("safe".equals(writeConcernType)) { - writeConcern = WriteConcern.SAFE; + else if ("unacknowledged".equals(writeConcernType)) { + writeConcern = WriteConcern.UNACKNOWLEDGED; } - else if ("normal".equals(writeConcernType)) { - writeConcern = WriteConcern.NORMAL; + else if ("acknowledged".equals(writeConcernType)) { + writeConcern = WriteConcern.ACKNOWLEDGED; } - else if ("fsync_safe".equals(writeConcernType)) { - writeConcern = WriteConcern.FSYNC_SAFE; + else if ("journaled".equals(writeConcernType)) { + writeConcern = WriteConcern.JOURNALED; } - else if ("replicas_safe".equals(writeConcernType)) { - writeConcern = WriteConcern.REPLICAS_SAFE; + else if ("replica_acknowledged".equals(writeConcernType)) { + writeConcern = WriteConcern.REPLICA_ACKNOWLEDGED; } else { System.err .println("ERROR: Invalid writeConcern: '" + writeConcernType + "'. " - + "Must be [ none | safe | normal | fsync_safe | replicas_safe ]"); + + "Must be [ errors_ignored | unacknowledged | acknowledged | journaled | replica_acknowledged ]"); System.exit(1); }