Skip to content
Snippets Groups Projects
Commit 7b9cf5f4 authored by Jared Rosoff's avatar Jared Rosoff Committed by Robert J. Moore
Browse files

Updated to current standard write concerns

parent 91f07916
No related branches found
No related tags found
No related merge requests found
......@@ -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`)
......
......@@ -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)) {
writeConcern = Durability.ACK;
else if ("unacknowledged".equals(writeConcernType)) {
writeConcern = Durability.NONE;
}
else if ("normal".equals(writeConcernType)) {
else if ("acknowledged".equals(writeConcernType)) {
writeConcern = Durability.ACK;
}
else if ("fsync_safe".equals(writeConcernType)) {
writeConcern = Durability.fsyncDurable(10000);
else if ("journaled".equals(writeConcernType)) {
writeConcern = Durability.journalDurable(0);
}
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);
}
......
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment