.withRequiredArg()
.describedAs("zone-id")
.ofType(Integer.class);
parser.accepts(HELP);
OptionSet options = parser.parse(args);
if(options.has(HELP)) {
parser.printHelpOn(System.out);
System.exit(0);
}
Props mainProps = null;
if(options.has(PROP_FILE)) {
String propFileDestination = (String) options.valueOf(PROP_FILE);
File propertyFile = new File(propFileDestination);
if(!propertyFile.exists()) {
printUsage(parser, "Property file does not exist");
}
try {
mainProps = new Props(propertyFile);
} catch(Exception e) {
printUsage(parser, "Unable to parse the property file");
}
} else {
mainProps = new Props();
if(options.has(REQUEST_FILE)) {
mainProps.put(REQUEST_FILE, (String) options.valueOf(REQUEST_FILE));
mainProps.put(RECORD_SELECTION, FILE_RECORD_SELECTION);
} else {
mainProps.put(RECORD_SELECTION,
CmdUtils.valueOf(options, RECORD_SELECTION, UNIFORM_RECORD_SELECTION));
}
if(options.has(RECORD_COUNT)) {
mainProps.put(RECORD_COUNT, (Integer) options.valueOf(RECORD_COUNT));
} else {
mainProps.put(RECORD_COUNT, 0);
}
if(!options.has(OPS_COUNT)) {
printUsage(parser, "Missing " + OPS_COUNT);
}
mainProps.put(OPS_COUNT, (Integer) options.valueOf(OPS_COUNT));
if(options.has(URL)) {
mainProps.put(URL, (String) options.valueOf(URL));
if(options.has(STORE_NAME)) {
mainProps.put(STORE_NAME, (String) options.valueOf(STORE_NAME));
} else {
printUsage(parser, "Missing store name");
}
} else {
mainProps.put(KEY_TYPE, CmdUtils.valueOf(options, KEY_TYPE, STRING_KEY_TYPE));
mainProps.put(STORAGE_CONFIGURATION_CLASS,
CmdUtils.valueOf(options,
STORAGE_CONFIGURATION_CLASS,
BdbStorageConfiguration.class.getName()));
}
mainProps.put(VERBOSE, getCmdBoolean(options, VERBOSE));
mainProps.put(VERIFY, getCmdBoolean(options, VERIFY));
mainProps.put(IGNORE_NULLS, getCmdBoolean(options, IGNORE_NULLS));
mainProps.put(CLIENT_ZONE_ID, CmdUtils.valueOf(options, CLIENT_ZONE_ID, -1));
mainProps.put(START_KEY_INDEX, CmdUtils.valueOf(options, START_KEY_INDEX, 0));
mainProps.put(VALUE_SIZE, CmdUtils.valueOf(options, VALUE_SIZE, 1024));
mainProps.put(ITERATIONS, CmdUtils.valueOf(options, ITERATIONS, 1));
mainProps.put(THREADS, CmdUtils.valueOf(options, THREADS, MAX_WORKERS));
mainProps.put(NUM_CONNECTIONS_PER_NODE, CmdUtils.valueOf(options,
NUM_CONNECTIONS_PER_NODE,
MAX_CONNECTIONS_PER_NODE));
mainProps.put(PERCENT_CACHED, CmdUtils.valueOf(options, PERCENT_CACHED, 0));
mainProps.put(INTERVAL, CmdUtils.valueOf(options, INTERVAL, 0));
mainProps.put(TARGET_THROUGHPUT, CmdUtils.valueOf(options, TARGET_THROUGHPUT, -1));
mainProps.put(METRIC_TYPE, CmdUtils.valueOf(options, METRIC_TYPE, SUMMARY_METRIC_TYPE));
mainProps.put(READS, CmdUtils.valueOf(options, READS, 0));
mainProps.put(WRITES, CmdUtils.valueOf(options, WRITES, 0));
mainProps.put(DELETES, CmdUtils.valueOf(options, DELETES, 0));
mainProps.put(MIXED, CmdUtils.valueOf(options, MIXED, 0));
mainProps.put(PLUGIN_CLASS, CmdUtils.valueOf(options, PLUGIN_CLASS, ""));
mainProps.put(SAMPLE_SIZE, CmdUtils.valueOf(options, SAMPLE_SIZE, 0));
}
// Start the benchmark
Benchmark benchmark = null;
try {
benchmark = new Benchmark();
benchmark.initialize(mainProps);
benchmark.warmUpAndRun();
benchmark.close();
} catch(Exception e) {
if(options.has(VERBOSE)) {
e.printStackTrace();
}
parser.printHelpOn(System.err);
System.exit(-1);
}