Updated to current standard write concerns

This commit is contained in:
Jared Rosoff 2013-03-13 10:41:48 -07:00 коммит произвёл Robert J. Moore
Родитель 91f079160e
Коммит 7b9cf5f495
3 изменённых файлов: 29 добавлений и 28 удалений

Просмотреть файл

@ -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)) {
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);
}

Просмотреть файл

@ -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);
}