use of joptsimple.OptionSet in project samza by apache.
the class RocksDbReadingTool method main.
public static void main(String[] args) throws RocksDBException {
RocksDbReadingTool tool = new RocksDbReadingTool();
OptionSet options = tool.parser().parse(args);
MapConfig config = tool.loadConfig(options);
String path = tool.getDbPath();
String dbName = tool.getDbName();
RocksDbKeyValueReader kvReader = new RocksDbKeyValueReader(dbName, path, config);
for (Object obj : tool.getKeys()) {
Object result = kvReader.get(obj);
tool.outputResult(obj, result);
}
kvReader.stop();
}
use of joptsimple.OptionSet in project samza by apache.
the class SamzaRestService method parseConfig.
/**
* Reads a {@link org.apache.samza.config.Config} from command line parameters.
* @param args the command line parameters supported by {@link org.apache.samza.util.CommandLine}.
* @return the parsed {@link org.apache.samza.config.Config}.
*/
private static SamzaRestConfig parseConfig(String[] args) {
CommandLine cmd = new CommandLine();
OptionSet options = cmd.parser().parse(args);
MapConfig cfg = cmd.loadConfig(options);
return new SamzaRestConfig(new MapConfig(cfg));
}
use of joptsimple.OptionSet in project voldemort by voldemort.
the class VoldemortThinClientShell method main.
@SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
OptionParser parser = new OptionParser();
OptionSet options = parser.parse(args);
List<String> nonOptions = (List<String>) options.nonOptionArguments();
if (nonOptions.size() < 2 || nonOptions.size() > 3) {
System.err.println("Usage: java VoldemortThinClientShell store_name coordinator_url [command_file] [options]");
parser.printHelpOn(System.err);
System.exit(-1);
}
String storeName = nonOptions.get(0);
String bootstrapUrl = nonOptions.get(1);
BufferedReader inputReader = null;
boolean fileInput = false;
try {
if (nonOptions.size() == 3) {
inputReader = new BufferedReader(new FileReader(nonOptions.get(2)));
fileInput = true;
} else {
inputReader = new BufferedReader(new InputStreamReader(System.in));
}
} catch (IOException e) {
Utils.croak("Failure to open input stream: " + e.getMessage());
}
VoldemortThinClientShell shell = new VoldemortThinClientShell(storeName, bootstrapUrl, inputReader, System.out, System.err);
shell.process(fileInput);
}
use of joptsimple.OptionSet in project voldemort by voldemort.
the class RemoteDataGenerator method main.
@SuppressWarnings("unchecked")
public static void main(String[] args) throws IOException {
OptionParser parser = new OptionParser();
parser.accepts("k", "key size").withRequiredArg().ofType(Integer.class);
parser.accepts("v", "value size").withRequiredArg().ofType(Integer.class);
parser.accepts("p", "prefix").withRequiredArg();
OptionSet options = parser.parse(args);
List<String> nonOptions = (List<String>) options.nonOptionArguments();
if (nonOptions.size() != 3) {
printUsage(System.err, parser);
}
String url = nonOptions.get(0);
String storeName = nonOptions.get(1);
int requests = Integer.parseInt(nonOptions.get(2));
int keySize = CmdUtils.valueOf(options, "k", 128);
int valueSize = CmdUtils.valueOf(options, "v", 256);
int workers = CmdUtils.valueOf(options, "threads", MAX_WORKERS);
String postfix = (String) (options.has("p") ? options.valueOf("p") : null);
RemoteDataGenerator rdg = new RemoteDataGenerator(url, storeName, workers);
rdg.generateData(requests, keySize, valueSize, postfix);
}
use of joptsimple.OptionSet in project voldemort by voldemort.
the class RequestFileFilter method main.
/**
* Filter requests specified in a file, generating a new file containing
* only requests destined for a specific node.
*
* @param args See usage for more information
* @throws Exception In case of I/O or Voldemort-specific errors
*/
public static void main(String[] args) throws Exception {
OptionParser parser = new OptionParser();
parser.accepts("help", "print usage information");
parser.accepts("node", "[REQUIRED] node id").withRequiredArg().ofType(Integer.class).describedAs("node id");
parser.accepts("store-name", "[REQUIRED] store name").withRequiredArg().describedAs("store name");
parser.accepts("url", "[REQUIRED] bootstrap URL").withRequiredArg().describedAs("bootstrap-url");
parser.accepts("input", "[REQUIRED] input request file").withRequiredArg().describedAs("input-file");
parser.accepts("output", "[REQUIRED] output file").withRequiredArg().describedAs("output-file");
parser.accepts("string-keys");
OptionSet options = parser.parse(args);
if (options.has("help")) {
parser.printHelpOn(System.out);
System.exit(0);
}
Set<String> missing = CmdUtils.missing(options, "node", "store-name", "url", "input", "output");
if (missing.size() > 0) {
System.err.println("Missing required arguments: " + Joiner.on(", ").join(missing));
parser.printHelpOn(System.err);
System.exit(1);
}
int nodeId = (Integer) options.valueOf("node");
String storeName = (String) options.valueOf("store-name");
String bootstrapURL = (String) options.valueOf("url");
String inputFile = (String) options.valueOf("input");
String outputFile = (String) options.valueOf("output");
boolean stringKeys = options.has("string-keys");
AdminClient adminClient = new AdminClient(bootstrapURL);
List<StoreDefinition> storeDefinitionList = adminClient.metadataMgmtOps.getRemoteStoreDefList(nodeId).getValue();
StoreDefinition storeDefinition = null;
for (StoreDefinition def : storeDefinitionList) {
if (storeName.equals(def.getName())) {
storeDefinition = def;
}
}
if (storeDefinition == null) {
Utils.croak("No store found with name\"" + storeName + "\"");
}
Cluster cluster = adminClient.metadataMgmtOps.getRemoteCluster(nodeId).getValue();
Node node = null;
try {
node = cluster.getNodeById(nodeId);
} catch (VoldemortException e) {
Utils.croak("Can't find a node with id " + nodeId);
}
RoutingStrategy routingStrategy = new RoutingStrategyFactory().updateRoutingStrategy(storeDefinition, cluster);
try {
new RequestFileFilter(storeDefinition, routingStrategy, inputFile, outputFile, node, stringKeys).filter();
} catch (FileNotFoundException e) {
Utils.croak(e.getMessage());
}
}
Aggregations