2012-02-19 05:07:33 +04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2015-05-29 19:07:55 +03:00
|
|
|
import argparse
|
|
|
|
import io
|
2012-02-19 05:07:33 +04:00
|
|
|
import os
|
2015-05-29 19:07:55 +03:00
|
|
|
import shlex
|
2012-02-19 05:07:33 +04:00
|
|
|
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",
|
2013-10-17 01:59:56 +04:00
|
|
|
"cassandra-cql": "com.yahoo.ycsb.db.CassandraCQLClient",
|
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",
|
2015-04-06 19:05:20 +03:00
|
|
|
"hbase-10" : "com.yahoo.ycsb.db.HBaseClient10",
|
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",
|
2013-07-27 05:20:02 +04:00
|
|
|
"mongodb-async": "com.yahoo.ycsb.db.AsyncMongoDbClient",
|
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",
|
2015-05-29 19:07:55 +03:00
|
|
|
"redis" : "com.yahoo.ycsb.db.RedisClient",
|
2013-07-25 12:28:33 +04:00
|
|
|
"voldemort" : "com.yahoo.ycsb.db.VoldemortClient",
|
|
|
|
"couchbase" : "com.yahoo.ycsb.db.CouchbaseClient"
|
2012-02-19 05:07:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
OPTIONS = {
|
2015-05-29 19:07:55 +03:00
|
|
|
"-P file" : "Specify workload file",
|
|
|
|
"-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)",
|
|
|
|
"-cp path" : "Additional Java classpath entries",
|
|
|
|
"-jvm-args args" : "Additional arguments to the JVM",
|
2012-02-19 05:07:33 +04:00
|
|
|
}
|
2012-02-19 13:05:07 +04:00
|
|
|
|
2012-02-19 05:07:33 +04:00
|
|
|
def usage():
|
2015-05-29 19:07:55 +03:00
|
|
|
output = io.BytesIO()
|
|
|
|
print >> output, "%s command database [options]" % sys.argv[0]
|
2012-02-19 05:07:33 +04:00
|
|
|
|
2015-05-29 19:07:55 +03:00
|
|
|
print >> output, "\nCommands:"
|
2012-02-19 05:07:33 +04:00
|
|
|
for command in sorted(COMMANDS.keys()):
|
2015-05-29 19:07:55 +03:00
|
|
|
print >> output, " %s %s" % (command.ljust(14),
|
|
|
|
COMMANDS[command]["description"])
|
2012-02-19 05:07:33 +04:00
|
|
|
|
2015-05-29 19:07:55 +03:00
|
|
|
print >> output, "\nDatabases:"
|
2012-02-19 05:07:33 +04:00
|
|
|
for db in sorted(DATABASES.keys()):
|
2015-05-29 19:07:55 +03:00
|
|
|
print >> output, " %s %s" % (db.ljust(14), BASE_URL +
|
|
|
|
db.split("-")[0])
|
2012-02-19 10:28:56 +04:00
|
|
|
|
2015-05-29 19:07:55 +03:00
|
|
|
print >> output, "\nOptions:"
|
2012-02-24 12:26:33 +04:00
|
|
|
for option in sorted(OPTIONS.keys()):
|
2015-05-29 19:07:55 +03:00
|
|
|
print >> output, " %s %s" % (option.ljust(14), OPTIONS[option])
|
2012-02-24 12:26:33 +04:00
|
|
|
|
2015-05-29 19:07:55 +03:00
|
|
|
print >> output, """\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
|
|
|
|
2015-05-29 19:07:55 +03:00
|
|
|
return output.getvalue()
|
|
|
|
|
2012-02-19 05:07:33 +04:00
|
|
|
|
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
|
|
|
|
|
2015-05-29 19:07:55 +03:00
|
|
|
|
2012-02-19 05:07:33 +04:00
|
|
|
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
|
|
|
|
2015-05-29 19:07:55 +03:00
|
|
|
|
|
|
|
def main():
|
|
|
|
p = argparse.ArgumentParser(
|
|
|
|
usage=usage(),
|
|
|
|
formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
|
|
p.add_argument('-cp', dest='classpath', help="""Additional classpath
|
|
|
|
entries, e.g. '-cp /tmp/hbase-1.0.1.1/conf'. Will be
|
|
|
|
prepended to the YCSB classpath.""")
|
|
|
|
p.add_argument("-jvm-args", default=[], type=shlex.split,
|
|
|
|
help="""Additional arguments to pass to 'java', e.g.
|
|
|
|
'-Xmx4g'""")
|
|
|
|
p.add_argument("command", choices=sorted(COMMANDS),
|
|
|
|
help="""Command to run.""")
|
|
|
|
p.add_argument("database", choices=sorted(DATABASES),
|
|
|
|
help="""Database to test.""")
|
|
|
|
args, remaining = p.parse_known_args()
|
|
|
|
ycsb_home = get_ycsb_home()
|
|
|
|
|
|
|
|
# Use JAVA_HOME to find java binary if set, otherwise just use PATH.
|
|
|
|
java = "java"
|
|
|
|
java_home = os.getenv("JAVA_HOME")
|
|
|
|
if java_home:
|
|
|
|
java = os.path.join(java_home, "bin", "java")
|
|
|
|
db_classname = DATABASES[args.database]
|
|
|
|
command = COMMANDS[args.command]["command"]
|
|
|
|
main_classname = COMMANDS[args.command]["main"]
|
|
|
|
classpath = os.pathsep.join(find_jars(ycsb_home, args.database))
|
|
|
|
if args.classpath:
|
|
|
|
classpath = os.pathsep.join([args.classpath, classpath])
|
|
|
|
|
|
|
|
ycsb_command = ([java] + args.jvm_args +
|
|
|
|
["-cp", classpath,
|
|
|
|
main_classname, "-db", db_classname] + remaining)
|
|
|
|
if command:
|
|
|
|
ycsb_command.append(command)
|
|
|
|
print >> sys.stderr, " ".join(ycsb_command)
|
|
|
|
return subprocess.call(ycsb_command)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(main())
|