2012-02-19 05:07:33 +04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
|
2012-02-22 13:32:13 +04:00
|
|
|
BASE_URL = "https://github.com/brianfrankcooper/YCSB/tree/master/"
|
2012-02-19 05:07:33 +04:00
|
|
|
COMMANDS = {
|
2012-02-24 12:08:06 +04:00
|
|
|
"shell" : {
|
|
|
|
"command" : "",
|
|
|
|
"description" : "Interactive mode",
|
|
|
|
"main" : "com.yahoo.ycsb.CommandLine",
|
|
|
|
},
|
2012-02-19 10:28:56 +04:00
|
|
|
"load" : {
|
|
|
|
"command" : "-load",
|
|
|
|
"description" : "Execute the load phase",
|
2012-02-24 12:08:06 +04:00
|
|
|
"main" : "com.yahoo.ycsb.Client",
|
2012-02-19 10:28:56 +04:00
|
|
|
},
|
|
|
|
"run" : {
|
|
|
|
"command" : "-t",
|
|
|
|
"description" : "Execute the transaction phase",
|
2012-02-24 12:08:06 +04:00
|
|
|
"main" : "com.yahoo.ycsb.Client",
|
2012-02-19 10:28:56 +04:00
|
|
|
},
|
2012-02-19 05:07:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
DATABASES = {
|
2013-07-20 10:45:36 +04:00
|
|
|
"accumulo" : "com.yahoo.ycsb.db.AccumuloClient",
|
2012-02-19 10:28:56 +04:00
|
|
|
"basic" : "com.yahoo.ycsb.BasicDB",
|
|
|
|
"cassandra-7" : "com.yahoo.ycsb.db.CassandraClient7",
|
|
|
|
"cassandra-8" : "com.yahoo.ycsb.db.CassandraClient8",
|
|
|
|
"cassandra-10" : "com.yahoo.ycsb.db.CassandraClient10",
|
2012-08-03 06:09:30 +04:00
|
|
|
"dynamodb" : "com.yahoo.ycsb.db.DynamoDBClient",
|
2012-08-25 04:17:15 +04:00
|
|
|
"elasticsearch": "com.yahoo.ycsb.db.ElasticSearchClient",
|
2012-02-19 13:05:07 +04:00
|
|
|
"gemfire" : "com.yahoo.ycsb.db.GemFireClient",
|
2012-02-19 10:28:56 +04:00
|
|
|
"hbase" : "com.yahoo.ycsb.db.HBaseClient",
|
2012-07-10 00:38:55 +04:00
|
|
|
"hypertable" : "com.yahoo.ycsb.db.HypertableClient",
|
2012-02-19 10:28:56 +04:00
|
|
|
"infinispan" : "com.yahoo.ycsb.db.InfinispanClient",
|
|
|
|
"jdbc" : "com.yahoo.ycsb.db.JdbcDBClient",
|
|
|
|
"mapkeeper" : "com.yahoo.ycsb.db.MapKeeperClient",
|
|
|
|
"mongodb" : "com.yahoo.ycsb.db.MongoDbClient",
|
2012-02-20 06:16:22 +04:00
|
|
|
"nosqldb" : "com.yahoo.ycsb.db.NoSqlDbClient",
|
2012-05-11 02:59:49 +04:00
|
|
|
"orientdb" : "com.yahoo.ycsb.db.OrientDBClient",
|
2012-02-19 10:28:56 +04:00
|
|
|
"redis" : "com.yahoo.ycsb.db.RedisClient",
|
2012-10-22 21:58:38 +04:00
|
|
|
"voldemort" : "com.yahoo.ycsb.db.VoldemortClient",
|
2012-02-19 05:07:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
OPTIONS = {
|
2012-02-24 12:26:33 +04:00
|
|
|
"-P file" : "Specify workload file",
|
2012-02-19 05:07:33 +04:00
|
|
|
"-p key=value" : "Override workload property",
|
|
|
|
"-s" : "Print status to stderr",
|
|
|
|
"-target n" : "Target ops/sec (default: unthrottled)",
|
|
|
|
"-threads n" : "Number of client threads (default: 1)",
|
|
|
|
}
|
2012-02-19 13:05:07 +04:00
|
|
|
|
2012-02-19 05:07:33 +04:00
|
|
|
def usage():
|
2012-02-24 12:26:33 +04:00
|
|
|
print "Usage: %s command database [options]" % sys.argv[0]
|
2012-02-19 05:07:33 +04:00
|
|
|
|
2012-02-19 13:05:07 +04:00
|
|
|
print "\nCommands:"
|
2012-02-19 05:07:33 +04:00
|
|
|
for command in sorted(COMMANDS.keys()):
|
2012-02-21 23:48:41 +04:00
|
|
|
print " %s %s" % (command.ljust(13), COMMANDS[command]["description"])
|
2012-02-19 05:07:33 +04:00
|
|
|
|
2012-02-19 13:05:07 +04:00
|
|
|
print "\nDatabases:"
|
2012-02-19 05:07:33 +04:00
|
|
|
for db in sorted(DATABASES.keys()):
|
2012-02-22 13:34:58 +04:00
|
|
|
print " %s %s" % (db.ljust(13), BASE_URL + db.split("-")[0])
|
2012-02-19 10:28:56 +04:00
|
|
|
|
2012-02-24 12:26:33 +04:00
|
|
|
print "\nOptions:"
|
|
|
|
for option in sorted(OPTIONS.keys()):
|
|
|
|
print " %s %s" % (option.ljust(13), OPTIONS[option])
|
|
|
|
|
2012-02-19 13:05:07 +04:00
|
|
|
print """\nWorkload Files:
|
2012-02-19 10:28:56 +04:00
|
|
|
There are various predefined workloads under workloads/ directory.
|
|
|
|
See https://github.com/brianfrankcooper/YCSB/wiki/Core-Properties
|
2012-02-19 13:05:07 +04:00
|
|
|
for the list of workload properties."""
|
2012-02-19 05:07:33 +04:00
|
|
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
2012-02-19 10:28:56 +04:00
|
|
|
def find_jars(dir, database):
|
2012-02-19 05:07:33 +04:00
|
|
|
jars = []
|
|
|
|
for (dirpath, dirnames, filenames) in os.walk(dir):
|
2012-02-19 13:05:07 +04:00
|
|
|
if dirpath.endswith("conf"):
|
|
|
|
jars.append(dirpath)
|
2012-02-19 05:07:33 +04:00
|
|
|
for filename in filenames:
|
2012-02-19 10:28:56 +04:00
|
|
|
if filename.endswith(".jar") and \
|
2012-02-22 13:32:13 +04:00
|
|
|
(filename.startswith("core") or \
|
|
|
|
filename.startswith(database.split("-")[0]) or \
|
|
|
|
not "binding" in filename):
|
2012-02-19 05:07:33 +04:00
|
|
|
jars.append(os.path.join(dirpath, filename))
|
|
|
|
return jars
|
|
|
|
|
|
|
|
def get_ycsb_home():
|
2012-02-19 06:48:24 +04:00
|
|
|
dir = os.path.abspath(os.path.dirname(sys.argv[0]))
|
|
|
|
while "CHANGELOG" not in os.listdir(dir):
|
|
|
|
dir = os.path.join(dir, os.path.pardir)
|
2012-02-19 13:05:07 +04:00
|
|
|
return os.path.abspath(dir)
|
2012-02-19 05:07:33 +04:00
|
|
|
|
2012-02-24 12:26:33 +04:00
|
|
|
if len(sys.argv) < 3:
|
2012-02-19 13:05:07 +04:00
|
|
|
usage()
|
|
|
|
if sys.argv[1] not in COMMANDS:
|
|
|
|
print "ERROR: Command '%s' not found" % sys.argv[1]
|
|
|
|
usage()
|
|
|
|
if sys.argv[2] not in DATABASES:
|
|
|
|
print "ERROR: Database '%s' not found" % sys.argv[2]
|
|
|
|
usage()
|
2012-02-19 05:07:33 +04:00
|
|
|
|
|
|
|
ycsb_home = get_ycsb_home()
|
2012-02-19 13:05:07 +04:00
|
|
|
command = COMMANDS[sys.argv[1]]["command"]
|
|
|
|
database = sys.argv[2]
|
|
|
|
db_classname = DATABASES[database]
|
2012-02-24 12:26:33 +04:00
|
|
|
options = sys.argv[3:]
|
2012-02-19 13:05:07 +04:00
|
|
|
|
2012-11-28 21:17:50 +04:00
|
|
|
ycsb_command = ["java", "-cp", os.pathsep.join(find_jars(ycsb_home, database)), \
|
2012-02-24 12:26:33 +04:00
|
|
|
COMMANDS[sys.argv[1]]["main"], "-db", db_classname] + options
|
2012-02-24 12:08:06 +04:00
|
|
|
if command:
|
|
|
|
ycsb_command.append(command)
|
2012-02-22 13:32:13 +04:00
|
|
|
print " ".join(ycsb_command)
|
2012-02-19 05:07:33 +04:00
|
|
|
subprocess.call(ycsb_command)
|