Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

gh-73. added readme. added defaults for all the config parameters.

  • Loading branch information...
commit e1de9c60e6ab0c0c825aaf7152a1b13c6f221d79 1 parent 448685c
Michi Mutsuzaki authored
View
42 mongodb/README.md
@@ -0,0 +1,42 @@
+## Quick Start
+
+This section describes how to run YCSB on MongoDB running locally.
+
+### 1. Start MongoDB
+
+First, download MongoDB and start `mongod`. For example, to start MongoDB
+on x86-64 Linux box:
+
+ wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-1.8.3.tgz
+ tar xfvz mongodb-linux-x86_64-1.8.3.tgz
+ mkdir /tmp/mongodb
+ cd mongodb-linux-x86_64-1.8.3
+ ./bin/mongod --dbpath /tmp/mongodb
+
+### 2. Set Up YCSB
+
+Clone the YCSB git repository and compile:
+
+ git clone git://github.com/brianfrankcooper/YCSB.git
+ cd YCSB
+ mvn clean package
+
+### 3. Run YCSB
+
+Now you are ready to run! First, load the data:
+
+ ./bin/ycsb load mongodb -s -P workloads/workloada
+
+Then, run the workload:
+
+ ./bin/ycsb run mongodb -s -P workloads/workloada
+
+See the next section for the list of configuration parameters for MongoDB.
+
+## MongoDB Configuration Parameters
+
+### `mongodb.url` (default: `mongodb://localhost:27017`)
+
+### `mongodb.database` (default: `ycsb`)
+
+### `mongodb.writeConcern` (default `safe`)
View
22 mongodb/src/main/java/com/yahoo/ycsb/db/MongoDbClient.java
@@ -9,7 +9,6 @@
package com.yahoo.ycsb.db;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Properties;
@@ -17,15 +16,12 @@
import java.util.Map;
import java.util.Vector;
-import org.bson.types.ObjectId;
-
import com.mongodb.BasicDBObject;
import com.mongodb.DBAddress;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.Mongo;
-import com.mongodb.ServerAddress;
import com.mongodb.WriteConcern;
import com.mongodb.WriteResult;
@@ -59,16 +55,24 @@
public void init() throws DBException {
// initialize MongoDb driver
Properties props = getProperties();
- String url = props.getProperty("mongodb.url");
- database = props.getProperty("mongodb.database");
- String writeConcernType = props.getProperty("mongodb.writeConcern");
+ String url = props.getProperty("mongodb.url", "mongodb://localhost:27017");
+ database = props.getProperty("mongodb.database", "ycsb");
+ String writeConcernType = props.getProperty("mongodb.writeConcern", "safe").toLowerCase();
if ("none".equals(writeConcernType)) {
writeConcern = WriteConcern.NONE;
- } else if ("strict".equals(writeConcernType)) {
+ } else if ("safe".equals(writeConcernType)) {
writeConcern = WriteConcern.SAFE;
} else if ("normal".equals(writeConcernType)) {
writeConcern = WriteConcern.NORMAL;
+ } else if ("fsync_safe".equals(writeConcernType)) {
+ writeConcern = WriteConcern.FSYNC_SAFE;
+ } else if ("replicas_safe".equals(writeConcernType)) {
+ writeConcern = WriteConcern.REPLICAS_SAFE;
+ } else {
+ System.err.println("ERROR: Invalid writeConcern: '" + writeConcernType + "'. " +
+ "Must be [ none | safe | normal | fsync_safe | replicas_safe ]");
+ System.exit(1);
}
try {
@@ -149,7 +153,7 @@ public int insert(String table, String key, HashMap<String, ByteIterator> values
WriteResult res = collection.insert(r,writeConcern);
return res.getError() == null ? 0 : 1;
} catch (Exception e) {
- System.err.println(e.toString());
+ e.printStackTrace();
return 1;
} finally {
if (db!=null)
Please sign in to comment.
Something went wrong with that request. Please try again.