use of org.apache.commons.cli.CommandLineParser in project WSPerfLab by Netflix-Skunkworks.
the class WSClient method main.
public static void main(String[] rawArgs) {
Options options = new Options();
options.addOption("j", false, "output JSON");
options.addOption("o", true, "output file path");
options.addOption("p", "port", true, "port");
options.addOption("h", "host", true, "host");
options.addOption("f", "step", true, "first step");
options.addOption("d", "duration", true, "duration");
options.addOption("q", "query", true, "query");
options.addOption("s", "stepsize", true, "step size");
CommandLineParser parser = new BasicParser();
CommandLine cmd;
try {
cmd = parser.parse(options, rawArgs);
} catch (ParseException e) {
throw new RuntimeException(e);
}
WSClient client = null;
try {
String host = "localhost";
if (cmd.hasOption('h')) {
host = cmd.getOptionValue('h');
}
int port = 8976;
if (cmd.hasOption('p')) {
port = Integer.parseInt(cmd.getOptionValue('p'));
}
int firstStep = 1;
if (cmd.hasOption('f')) {
firstStep = Integer.parseInt(cmd.getOptionValue('f'));
}
int stepSize = 200;
if (cmd.hasOption('s')) {
stepSize = Integer.parseInt(cmd.getOptionValue('s'));
}
int duration = 30;
if (cmd.hasOption('d')) {
duration = Integer.parseInt(cmd.getOptionValue('d'));
}
String query = "/?id=12345";
if (cmd.hasOption('q')) {
query = cmd.getOptionValue('q');
}
client = new WSClient(host, port, firstStep, stepSize, duration, query);
if (cmd.hasOption('j'))
client.setEnableJsonLogging(true);
if (cmd.hasOption("o"))
client.setOutputPath(cmd.getOptionValue("o"));
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
}
client.startMonitoring();
client.startLoad().toBlocking().last();
}
use of org.apache.commons.cli.CommandLineParser in project Apktool by iBotPeaches.
the class Main method main.
public static void main(String[] args) throws IOException, InterruptedException, BrutException {
// set verbosity default
Verbosity verbosity = Verbosity.NORMAL;
// cli parser
CommandLineParser parser = new PosixParser();
CommandLine commandLine;
// load options
_Options();
try {
commandLine = parser.parse(allOptions, args, false);
} catch (ParseException ex) {
System.err.println(ex.getMessage());
usage();
return;
}
// check for verbose / quiet
if (commandLine.hasOption("-v") || commandLine.hasOption("--verbose")) {
verbosity = Verbosity.VERBOSE;
} else if (commandLine.hasOption("-q") || commandLine.hasOption("--quiet")) {
verbosity = Verbosity.QUIET;
}
setupLogging(verbosity);
// check for advance mode
if (commandLine.hasOption("advance") || commandLine.hasOption("advanced")) {
setAdvanceMode(true);
}
// @todo use new ability of apache-commons-cli to check hasOption for non-prefixed items
boolean cmdFound = false;
for (String opt : commandLine.getArgs()) {
if (opt.equalsIgnoreCase("d") || opt.equalsIgnoreCase("decode")) {
cmdDecode(commandLine);
cmdFound = true;
} else if (opt.equalsIgnoreCase("b") || opt.equalsIgnoreCase("build")) {
cmdBuild(commandLine);
cmdFound = true;
} else if (opt.equalsIgnoreCase("if") || opt.equalsIgnoreCase("install-framework")) {
cmdInstallFramework(commandLine);
cmdFound = true;
} else if (opt.equalsIgnoreCase("empty-framework-dir")) {
cmdEmptyFrameworkDirectory(commandLine);
cmdFound = true;
} else if (opt.equalsIgnoreCase("publicize-resources")) {
cmdPublicizeResources(commandLine);
cmdFound = true;
}
}
// if no commands ran, run the version / usage check.
if (cmdFound == false) {
if (commandLine.hasOption("version")) {
_version();
} else {
usage();
}
}
}
use of org.apache.commons.cli.CommandLineParser in project pinot by linkedin.
the class FileBasedServer method processCommandLineArgs.
private static void processCommandLineArgs(String[] cliArgs) throws ParseException {
CommandLineParser cliParser = new GnuParser();
Options cliOptions = buildCommandLineOptions();
CommandLine cmd = cliParser.parse(cliOptions, cliArgs, true);
if (!cmd.hasOption(SERVER_CONFIG_OPT_NAME) || !cmd.hasOption(SERVER_PORT_OPT_NAME)) {
System.err.println("Missing required arguments !!");
System.err.println(cliOptions);
throw new RuntimeException("Missing required arguments !!");
}
_serverConfigPath = cmd.getOptionValue(SERVER_CONFIG_OPT_NAME);
_serverPort = Integer.parseInt(cmd.getOptionValue(SERVER_PORT_OPT_NAME));
}
use of org.apache.commons.cli.CommandLineParser in project pinot by linkedin.
the class ScatterGatherPerfServer method main.
/**
* @param args
*/
public static void main(String[] args) throws Exception {
CommandLineParser cliParser = new GnuParser();
Options cliOptions = buildCommandLineOptions();
CommandLine cmd = cliParser.parse(cliOptions, args, true);
if (!cmd.hasOption(RESPONSE_SIZE_OPT_NAME) || !cmd.hasOption(SERVER_PORT_OPT_NAME)) {
System.err.println("Missing required arguments !!");
System.err.println(cliOptions);
throw new RuntimeException("Missing required arguments !!");
}
int responseSize = Integer.parseInt(cmd.getOptionValue(RESPONSE_SIZE_OPT_NAME));
int serverPort = Integer.parseInt(cmd.getOptionValue(SERVER_PORT_OPT_NAME));
// 2ms latency
ScatterGatherPerfServer server = new ScatterGatherPerfServer(serverPort, responseSize, 2);
server.run();
}
use of org.apache.commons.cli.CommandLineParser in project pinot by linkedin.
the class ScatterGatherPerfClient method main.
public static void main(String[] args) throws Exception {
//Process Command Line to get config and port
CommandLineParser cliParser = new GnuParser();
Options cliOptions = buildCommandLineOptions();
CommandLine cmd = cliParser.parse(cliOptions, args, true);
if ((!cmd.hasOption(BROKER_CONFIG_OPT_NAME)) || (!cmd.hasOption(REQUEST_SIZE_OPT_NAME)) || (!cmd.hasOption(TABLE_NAME_OPT_NAME)) || (!cmd.hasOption(TABLE_NAME_OPT_NAME))) {
System.err.println("Missing required arguments !!");
System.err.println(cliOptions);
throw new RuntimeException("Missing required arguments !!");
}
String brokerConfigPath = cmd.getOptionValue(BROKER_CONFIG_OPT_NAME);
int requestSize = Integer.parseInt(cmd.getOptionValue(REQUEST_SIZE_OPT_NAME));
int numRequests = Integer.parseInt(cmd.getOptionValue(NUM_REQUESTS_OPT_NAME));
String resourceName = cmd.getOptionValue(TABLE_NAME_OPT_NAME);
// build brokerConf
PropertiesConfiguration brokerConf = new PropertiesConfiguration();
brokerConf.setDelimiterParsingDisabled(false);
brokerConf.load(brokerConfigPath);
RoutingTableConfig config = new RoutingTableConfig();
config.init(brokerConf.subset(ROUTING_CFG_PREFIX));
ScatterGatherPerfClient client = new ScatterGatherPerfClient(config, requestSize, resourceName, false, numRequests, 1, 1);
client.run();
System.out.println("Shutting down !!");
client.shutdown();
System.out.println("Shut down complete !!");
}
Aggregations