зеркало из https://github.com/Azure/YCSB.git
gh-73. added readme. added defaults for all the config parameters.
This commit is contained in:
Родитель
448685cad4
Коммит
e1de9c60e6
|
@ -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`)
|
|
@ -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.Set;
|
|||
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 class MongoDbClient extends DB {
|
|||
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 class MongoDbClient extends DB {
|
|||
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)
|
||||
|
|
Загрузка…
Ссылка в новой задаче