List of usage examples for org.apache.commons.cli CommandLine getOptions
public Option[] getOptions()
From source file:com.redhat.poc.jdg.bankofchina.performance.TestCase531RemoteMultiThreads.java
public static void main(String[] args) throws Exception { CommandLine commandLine; Options options = new Options(); options.addOption("n", true, "The read thread numbers option"); options.addOption("t", true, "The thread read times option"); BasicParser parser = new BasicParser(); parser.parse(options, args);// w w w. j a v a2 s . co m commandLine = parser.parse(options, args); if (commandLine.getOptions().length > 0) { if (commandLine.hasOption("n")) { String numbers = commandLine.getOptionValue("n"); if (numbers != null && numbers.length() > 0) { readThreadNumbers = Integer.parseInt(numbers); } } if (commandLine.hasOption("t")) { String times = commandLine.getOptionValue("t"); if (times != null && times.length() > 0) { threadReadTimes = Integer.parseInt(times); } } } System.out.println(); System.out.println("%%%%%%%%% userid.csv %%%%%%%%%"); LoadUserIdList(); randomPoolSize = userIdList.size(); System.out.println( "%%%%%%%%% ? userid.csv , " + randomPoolSize + " ?? %%%%%%%%%"); randomPoolSizeByThread = randomPoolSize / readThreadNumbers; System.out.println(); System.out.println( "%%%%%%%%% ?, " + readThreadNumbers + " ,, ???, " + threadReadTimes + " ,?, ?(ms)," + new Date().getTime()); for (int i = 0; i < readThreadNumbers; i++) { new TestCase531RemoteMultiThreads(i * randomPoolSizeByThread).start(); } }
From source file:com.redhat.poc.jdg.bankofchina.performance.TestCase532RemoteMultiThreads.java
public static void main(String[] args) throws Exception { CommandLine commandLine; Options options = new Options(); options.addOption("n", true, "The read thread numbers option"); options.addOption("t", true, "The thread read times option"); BasicParser parser = new BasicParser(); parser.parse(options, args);//from w ww . j a va 2 s. c o m commandLine = parser.parse(options, args); if (commandLine.getOptions().length > 0) { if (commandLine.hasOption("n")) { String numbers = commandLine.getOptionValue("n"); if (numbers != null && numbers.length() > 0) { writeThreadNumbers = Integer.parseInt(numbers); } } if (commandLine.hasOption("t")) { String times = commandLine.getOptionValue("t"); if (times != null && times.length() > 0) { threadWriteTimes = Integer.parseInt(times); } } } System.out.println(); System.out.println("%%%%%%%%% userid.csv %%%%%%%%%"); LoadUserIdList(); randomPoolSize = userIdList.size(); System.out.println( "%%%%%%%%% ? userid.csv , " + randomPoolSize + " ?? %%%%%%%%%"); randomPoolSizeByThread = randomPoolSize / writeThreadNumbers; System.out.println(); System.out.println( "%%%%%%%%% ?, " + writeThreadNumbers + ", , ??, " + threadWriteTimes + ", ?, ?(ms)," + new Date().getTime()); for (int i = 0; i < writeThreadNumbers; i++) { new TestCase532RemoteMultiThreads(i * randomPoolSizeByThread).start(); } }
From source file:com.ibm.zurich.Main.java
public static void main(String[] args) throws NoSuchAlgorithmException, IOException { Option help = new Option(HELP, "print this message"); Option version = new Option(VERSION, "print the version information"); Options options = new Options(); Option useCurve = Option.builder(USECURVE).hasArg().argName("curve") .desc("Specify the BN Curve. Options: " + curveOptions()).build(); Option isskeygen = Option.builder(IKEYGEN).numberOfArgs(3).argName("ipk><isk><RL") .desc("Generate Issuer key pair and empty revocation list and store it in files").build(); Option join1 = Option.builder(JOIN1).numberOfArgs(3).argName("ipk><authsk><msg1") .desc("Create an authenticator secret key and perform the first step of the join protocol").build(); Option join2 = Option.builder(JOIN2).numberOfArgs(4).argName("ipk><isk><msg1><msg2") .desc("Complete the join protocol").build(); Option verify = Option.builder(VERIFY).numberOfArgs(5).argName("ipk><sig><krd><appId><RL") .desc("Verify a signature").build(); Option sign = Option.builder(SIGN).numberOfArgs(6).argName("ipk><authsk><msg2><appId><krd><sig") .desc("create a signature").build(); options.addOption(help);//from w w w . java2 s . c o m options.addOption(version); options.addOption(useCurve); options.addOption(isskeygen); options.addOption(sign); options.addOption(verify); options.addOption(join1); options.addOption(join2); HelpFormatter formatter = new HelpFormatter(); CommandLineParser parser = new DefaultParser(); //FIXME Choose a proper instantiation of SecureRandom depending on the platform SecureRandom random = new SecureRandom(); Base64.Encoder encoder = Base64.getUrlEncoder(); Base64.Decoder decoder = Base64.getUrlDecoder(); try { CommandLine line = parser.parse(options, args); BNCurveInstantiation instantiation = null; BNCurve curve = null; if (line.hasOption(HELP) || line.getOptions().length == 0) { formatter.printHelp(USAGE, options); } else if (line.hasOption(VERSION)) { System.out.println("Version " + Main.class.getPackage().getImplementationVersion()); } else if (line.hasOption(USECURVE)) { instantiation = BNCurveInstantiation.valueOf(line.getOptionValue(USECURVE)); curve = new BNCurve(instantiation); } else { System.out.println("Specify the curve to use."); return; } if (line.hasOption(IKEYGEN)) { String[] optionValues = line.getOptionValues(IKEYGEN); // Create secret key IssuerSecretKey sk = Issuer.createIssuerKey(curve, random); // Store pk writeToFile((new IssuerPublicKey(curve, sk, random)).toJSON(curve), optionValues[0]); // Store sk writeToFile(sk.toJson(curve), optionValues[1]); // Create empty revocation list and store HashSet<BigInteger> rl = new HashSet<BigInteger>(); writeToFile(Verifier.revocationListToJson(rl, curve), optionValues[2]); } else if (line.hasOption(SIGN)) { //("ipk><authsk><msg2><appId><krd><sig") String[] optionValues = line.getOptionValues(SIGN); IssuerPublicKey ipk = new IssuerPublicKey(curve, readStringFromFile(optionValues[0])); BigInteger authsk = curve.bigIntegerFromB(decoder.decode(readFromFile(optionValues[1]))); JoinMessage2 msg2 = new JoinMessage2(curve, readStringFromFile(optionValues[2])); // setup a new authenticator Authenticator auth = new Authenticator(curve, ipk, authsk); auth.EcDaaJoin1(curve.getRandomModOrder(random)); if (auth.EcDaaJoin2(msg2)) { EcDaaSignature sig = auth.EcDaaSign(optionValues[3]); // Write krd to file writeToFile(sig.krd, optionValues[4]); // Write signature to file writeToFile(sig.encode(curve), optionValues[5]); System.out.println("Signature written to " + optionValues[5]); } else { System.out.println("JoinMsg2 invalid"); } } else if (line.hasOption(VERIFY)) { Verifier ver = new Verifier(curve); String[] optionValues = line.getOptionValues(VERIFY); String pkFile = optionValues[0]; String sigFile = optionValues[1]; String krdFile = optionValues[2]; String appId = optionValues[3]; String rlPath = optionValues[4]; byte[] krd = Files.readAllBytes(Paths.get(krdFile)); IssuerPublicKey pk = new IssuerPublicKey(curve, readStringFromFile(pkFile)); EcDaaSignature sig = new EcDaaSignature(Files.readAllBytes(Paths.get(sigFile)), krd, curve); boolean valid = ver.verify(sig, appId, pk, Verifier.revocationListFromJson(readStringFromFile(rlPath), curve)); System.out.println("Signature is " + (valid ? "valid." : "invalid.")); } else if (line.hasOption(JOIN1)) { String[] optionValues = line.getOptionValues(JOIN1); IssuerPublicKey ipk = new IssuerPublicKey(curve, readStringFromFile(optionValues[0])); // Create authenticator key BigInteger sk = curve.getRandomModOrder(random); writeToFile(encoder.encodeToString(curve.bigIntegerToB(sk)), optionValues[1]); Authenticator auth = new Authenticator(curve, ipk, sk); JoinMessage1 msg1 = auth.EcDaaJoin1(curve.getRandomModOrder(random)); writeToFile(msg1.toJson(curve), optionValues[2]); } else if (line.hasOption(JOIN2)) { String[] optionValues = line.getOptionValues(JOIN2); // create issuer with the specified key IssuerPublicKey pk = new IssuerPublicKey(curve, readStringFromFile(optionValues[0])); IssuerSecretKey sk = new IssuerSecretKey(curve, readStringFromFile(optionValues[1])); Issuer iss = new Issuer(curve, sk, pk); JoinMessage1 msg1 = new JoinMessage1(curve, readStringFromFile(optionValues[2])); // Note that we do not check for nonce freshness. JoinMessage2 msg2 = iss.EcDaaIssuerJoin(msg1, false); if (msg2 == null) { System.out.println("Join message invalid."); } else { System.out.println("Join message valid, msg2 written to file."); writeToFile(msg2.toJson(curve), optionValues[3]); } } } catch (ParseException e) { System.out.println("Error parsing input."); e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.esri.geoevent.test.performance.ProducerMain.java
/** * Main method - this is used to when running from command line * * @param args Command Line Options//from w w w . j ava2s . c o m */ @SuppressWarnings("static-access") public static void main(String[] args) { // performer options Options performerOptions = new Options(); performerOptions .addOption(OptionBuilder .withLongOpt("type").withDescription("One of the following values: [" + Protocol.getAllowableValues() + "]. (Default value is tcp).") .hasArg().create("t")); performerOptions.addOption(OptionBuilder.withLongOpt("commandListenerPort").withDescription( "The TCP Port where producer will listen for commands from the orchestrator. (Default value is 5020).") .hasArg().create("p")); performerOptions.addOption(OptionBuilder.withLongOpt("serverPort") .withDescription("The TCP Port where the server will produce events. (Default value is 5665)") .hasArg().create("sp")); performerOptions.addOption("h", "help", false, "print the help message"); // parse the command line CommandLineParser parser = new BasicParser(); CommandLine cmd = null; // parse try { cmd = parser.parse(performerOptions, args, false); } catch (ParseException error) { printHelp(performerOptions); return; } if (cmd.getOptions().length == 0) { // No Args Start GUI ProducerUI ui = new ProducerUI(); ui.run(); } else { // User Request Help Page if (cmd.hasOption("h")) { printHelp(performerOptions); return; } // parse out the performer options String protocolValue = cmd.getOptionValue("t"); String commandListenerPortValue = cmd.getOptionValue("p"); if (protocolValue == null) { protocolValue = "tcp"; } if (commandListenerPortValue == null) { commandListenerPortValue = "5010"; } // validate if (!validateTestHarnessOptions(protocolValue, commandListenerPortValue)) { printHelp(performerOptions); return; } // parse the values Protocol protocol = Protocol.fromValue(protocolValue); boolean isLocal = "local".equalsIgnoreCase(commandListenerPortValue); int commandListenerPort = -1; if (!isLocal) { commandListenerPort = Integer.parseInt(commandListenerPortValue); } int serverPort = NumberUtils.toInt(cmd.getOptionValue("sp"), 5665); PerformanceCollector producer = null; switch (protocol) { case TCP: producer = new TcpEventProducer(); break; case TCP_SERVER: producer = new TcpServerEventProducer(serverPort); break; case WEBSOCKETS: producer = new WebsocketEventProducer(); break; case ACTIVE_MQ: producer = new ActiveMQEventProducer(); break; case RABBIT_MQ: producer = new RabbitMQEventProducer(); break; case STREAM_SERVICE: producer = new StreamServiceEventProducer(); break; case KAFKA: producer = new KafkaEventProducer(); break; case WEBSOCKET_SERVER: producer = new WebsocketServerEventProducer(serverPort); break; case AZURE: producer = new AzureIoTHubProducer(); break; case REST_JSON: producer = new JsonEventProducer(); break; default: return; } producer.listenOnCommandPort((isLocal ? 5010 : commandListenerPort), true); } }
From source file:com.redhat.poc.jdg.bankofchina.function.TestCase411RemoteMultiThreadsCustomMarshal.java
public static void main(String[] args) throws Exception { CommandLine commandLine; Options options = new Options(); options.addOption("s", true, "The start csv file number option"); options.addOption("e", true, "The end csv file number option"); BasicParser parser = new BasicParser(); parser.parse(options, args);//from www . ja va 2 s .c o m commandLine = parser.parse(options, args); if (commandLine.getOptions().length > 0) { if (commandLine.hasOption("s")) { String start = commandLine.getOptionValue("s"); if (start != null && start.length() > 0) { csvFileStart = Integer.parseInt(start); } } if (commandLine.hasOption("e")) { String end = commandLine.getOptionValue("e"); if (end != null && end.length() > 0) { csvFileEnd = Integer.parseInt(end); } } } System.out.println( "%%%%%%%%% csv ?, ?, ?(ms)," + new Date().getTime()); for (int i = csvFileStart; i <= csvFileEnd; i++) { new TestCase411RemoteMultiThreadsCustomMarshal(i).start(); } }
From source file:com.netflix.suro.SuroServer.java
public static void main(String[] args) throws IOException { final AtomicReference<Injector> injector = new AtomicReference<Injector>(); try {/* www. j a v a2 s. c om*/ // Parse the command line Options options = createOptions(); final CommandLine line = new BasicParser().parse(options, args); // Load the properties file final Properties properties = new Properties(); if (line.hasOption('p')) { properties.load(new FileInputStream(line.getOptionValue('p'))); } // Bind all command line options to the properties with prefix "SuroServer." for (Option opt : line.getOptions()) { String name = opt.getOpt(); String value = line.getOptionValue(name); String propName = PROP_PREFIX + opt.getArgName(); if (propName.equals(DynamicPropertyRoutingMapConfigurator.ROUTING_MAP_PROPERTY)) { properties.setProperty(DynamicPropertyRoutingMapConfigurator.ROUTING_MAP_PROPERTY, FileUtils.readFileToString(new File(value))); } else if (propName.equals(DynamicPropertySinkConfigurator.SINK_PROPERTY)) { properties.setProperty(DynamicPropertySinkConfigurator.SINK_PROPERTY, FileUtils.readFileToString(new File(value))); } else if (propName.equals(DynamicPropertyInputConfigurator.INPUT_CONFIG_PROPERTY)) { properties.setProperty(DynamicPropertyInputConfigurator.INPUT_CONFIG_PROPERTY, FileUtils.readFileToString(new File(value))); } else { properties.setProperty(propName, value); } } create(injector, properties); injector.get().getInstance(LifecycleManager.class).start(); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { try { Closeables.close(injector.get().getInstance(LifecycleManager.class), true); } catch (IOException e) { // do nothing because Closeables.close will swallow IOException } } }); waitForShutdown(getControlPort(properties)); } catch (Throwable e) { System.err.println("SuroServer startup failed: " + e.getMessage()); System.exit(-1); } finally { Closeables.close(injector.get().getInstance(LifecycleManager.class), true); } }
From source file:com.cws.esolutions.security.main.UserManagementUtility.java
public static final void main(final String[] args) { final String methodName = UserManagementUtility.CNAME + "#main(final String[] args)"; if (DEBUG) {//from w w w . j a va2 s . c om DEBUGGER.debug(methodName); DEBUGGER.debug("Value: {}", (Object) args); } if (args.length == 0) { HelpFormatter usage = new HelpFormatter(); usage.printHelp(UserManagementUtility.CNAME, options, true); return; } try { CommandLineParser parser = new PosixParser(); CommandLine commandLine = parser.parse(options, args); if (DEBUG) { DEBUGGER.debug("CommandLineParser parser: {}", parser); DEBUGGER.debug("CommandLine commandLine: {}", commandLine); DEBUGGER.debug("CommandLine commandLine.getOptions(): {}", (Object[]) commandLine.getOptions()); DEBUGGER.debug("CommandLine commandLine.getArgList(): {}", commandLine.getArgList()); } if ((commandLine.hasOption("configFile")) && (!(StringUtils.isBlank(commandLine.getOptionValue("configFile"))))) { SecurityServiceInitializer.initializeService(commandLine.getOptionValue("configFile"), UserManagementUtility.LOG_CONFIG, true); } else { SecurityServiceInitializer.initializeService(UserManagementUtility.SEC_CONFIG, UserManagementUtility.LOG_CONFIG, true); } AccountControlResponse response = null; final UserAccount userAccount = new UserAccount(); final RequestHostInfo reqInfo = new RequestHostInfo(); final SecurityConfigurationData secConfigData = UserManagementUtility.svcBean.getConfigData(); final SecurityConfig secConfig = secConfigData.getSecurityConfig(); try { reqInfo.setHostAddress(InetAddress.getLocalHost().getHostAddress()); reqInfo.setHostName(InetAddress.getLocalHost().getHostName()); } catch (UnknownHostException uhx) { reqInfo.setHostAddress("127.0.0.1"); reqInfo.setHostName("localhost"); } if (DEBUG) { DEBUGGER.debug("SecurityConfigurationData secConfig: {}", secConfigData); DEBUGGER.debug("SecurityConfig secConfig: {}", secConfig); DEBUGGER.debug("RequestHostInfo reqInfo: {}", reqInfo); } AccountControlRequest request = new AccountControlRequest(); request.setApplicationId(secConfig.getApplicationId()); request.setApplicationName(secConfig.getApplicationName()); request.setHostInfo(reqInfo); request.setRequestor(secConfig.getSvcAccount()); if (DEBUG) { DEBUGGER.debug("AccountControlRequest request: {}", request); } if (commandLine.hasOption("search")) { if (StringUtils.isEmpty(commandLine.getOptionValue("search"))) { throw new ParseException("No entry option was provided. Cannot continue."); } userAccount.setEmailAddr(commandLine.getOptionValue("search")); if (DEBUG) { DEBUGGER.debug("UserAccount userAccount: {}", userAccount); } request.setUserAccount(userAccount); if (DEBUG) { DEBUGGER.debug("AccountControlRequest: {}", request); } response = processor.searchAccounts(request); } else if (commandLine.hasOption("load")) { if (StringUtils.isEmpty(commandLine.getOptionValue("load"))) { throw new ParseException("No entry option was provided. Cannot continue."); } userAccount.setGuid(commandLine.getOptionValue("load")); request.setUserAccount(userAccount); if (DEBUG) { DEBUGGER.debug("AccountControlRequest: {}", request); } response = processor.loadUserAccount(request); } if (DEBUG) { DEBUGGER.debug("AccountControlResponse response: {}", response); } if ((response != null) && (response.getRequestStatus() == SecurityRequestStatus.SUCCESS)) { UserAccount account = response.getUserAccount(); if (DEBUG) { DEBUGGER.debug("UserAccount: {}", account); } System.out.println(account); } } catch (ParseException px) { ERROR_RECORDER.error(px.getMessage(), px); System.err.println("An error occurred during processing: " + px.getMessage()); } catch (SecurityException sx) { ERROR_RECORDER.error(sx.getMessage(), sx); System.err.println("An error occurred during processing: " + sx.getMessage()); } catch (SecurityServiceException ssx) { ERROR_RECORDER.error(ssx.getMessage(), ssx); System.err.println("An error occurred during processing: " + ssx.getMessage()); } }
From source file:com.esri.geoevent.test.performance.ConsumerMain.java
/** * Main method - this is used to when running from command line * * @param args Command Line Parameters/* w w w . j a v a 2 s.co m*/ */ @SuppressWarnings("static-access") public static void main(String[] args) { // performer options Options performerOptions = new Options(); performerOptions .addOption(OptionBuilder .withLongOpt("type").withDescription("One of the following values: [" + Protocol.getAllowableValues() + "]. (Default value is tcp).") .hasArg().create("t")); performerOptions.addOption(OptionBuilder.withLongOpt("commandListenerPort").withDescription( "The TCP Port where consumer will listen for commands from the orchestrator. (Default value is 5010).") .hasArg().create("p")); performerOptions.addOption(OptionBuilder.withLongOpt("serverPort") .withDescription("The TCP Port where the server will listen for events. (Default value is 5675)") .hasArg().create("sp")); performerOptions.addOption("h", "help", false, "print the help message"); // parse the command line CommandLineParser parser = new BasicParser(); CommandLine cmd; // parse try { cmd = parser.parse(performerOptions, args, false); } catch (ParseException error) { printHelp(performerOptions); return; } // User requested Help if (cmd.hasOption("h")) { printHelp(performerOptions); return; } if (cmd.getOptions().length == 0) { ConsumerUI ui = new ConsumerUI(); ui.run(); } else { // parse out the performer options String protocolValue = cmd.getOptionValue("t"); String commandListenerPortValue = cmd.getOptionValue("p"); if (protocolValue == null) { protocolValue = "tcp"; } if (commandListenerPortValue == null) { commandListenerPortValue = "5020"; } // validate if (!validateTestHarnessOptions(protocolValue, commandListenerPortValue)) { printHelp(performerOptions); return; } // parse the values Protocol protocol = Protocol.fromValue(protocolValue); boolean isLocal = "local".equalsIgnoreCase(commandListenerPortValue); int commandListenerPort = -1; if (!isLocal) { commandListenerPort = Integer.parseInt(commandListenerPortValue); } int serverPort = NumberUtils.toInt(cmd.getOptionValue("sp"), 5775); PerformanceCollector consumer; switch (protocol) { case TCP: consumer = new TcpEventConsumer(); break; case TCP_SERVER: consumer = new TcpServerEventConsumer(serverPort); break; case WEBSOCKETS: consumer = new WebsocketEventConsumer(); break; case WEBSOCKET_SERVER: consumer = new WebsocketServerEventConsumer(serverPort); break; case ACTIVE_MQ: consumer = new ActiveMQEventConsumer(); break; case RABBIT_MQ: consumer = new RabbitMQEventConsumer(); break; case STREAM_SERVICE: consumer = new StreamServiceEventConsumer(); break; case KAFKA: consumer = new KafkaEventConsumer(); break; case BDS: consumer = new BdsEventConsumer(); break; case AZURE: consumer = new AzureIoTHubConsumer(); break; default: return; } consumer.listenOnCommandPort((isLocal ? 5020 : commandListenerPort), true); } }
From source file:com.esri.geoevent.test.tools.RunTcpInTcpOutTest.java
public static void main(String args[]) { int numberEvents = 10000; //int brake = 1000; String server = "ags104"; int in_port = 5565; int out_port = 5575; int start_rate = 5000; int end_rate = 5005; int rate_step = 1; Options opts = new Options(); opts.addOption("n", true, "Number of Events"); opts.addOption("s", true, "Server"); opts.addOption("i", true, "Input TCP Port"); opts.addOption("o", true, "Output TCP Port"); opts.addOption("r", true, "Range"); opts.addOption("h", false, "Help"); try {/* w w w .j av a 2 s. c o m*/ CommandLineParser parser = new BasicParser(); CommandLine cmd = null; try { cmd = parser.parse(opts, args, false); } catch (ParseException ignore) { System.err.println(ignore.getMessage()); } String cmdInputErrorMsg = ""; if (cmd.getOptions().length == 0 || cmd.hasOption("h")) { throw new ParseException("Show Help"); } if (cmd.hasOption("n")) { String val = cmd.getOptionValue("n"); try { numberEvents = Integer.valueOf(val); } catch (NumberFormatException e) { cmdInputErrorMsg += "Invalid value for n. Must be integer.\n"; } } if (cmd.hasOption("s")) { server = cmd.getOptionValue("s"); } if (cmd.hasOption("i")) { String val = cmd.getOptionValue("i"); try { in_port = Integer.valueOf(val); } catch (NumberFormatException e) { cmdInputErrorMsg += "Invalid value for i. Must be integer.\n"; } } if (cmd.hasOption("o")) { String val = cmd.getOptionValue("o"); try { out_port = Integer.valueOf(val); } catch (NumberFormatException e) { cmdInputErrorMsg += "Invalid value for o. Must be integer.\n"; } } if (cmd.hasOption("r")) { String val = cmd.getOptionValue("r"); try { String parts[] = val.split(","); if (parts.length == 3) { start_rate = Integer.parseInt(parts[0]); end_rate = Integer.parseInt(parts[1]); rate_step = Integer.parseInt(parts[2]); } else if (parts.length == 1) { // Run single rate start_rate = Integer.parseInt(parts[0]); end_rate = start_rate; rate_step = start_rate; } else { throw new ParseException("Rate must be three comma seperated values or a single value"); } } catch (ParseException e) { cmdInputErrorMsg += e.getMessage(); } catch (NumberFormatException e) { cmdInputErrorMsg += "Invalid value for r. Must be integers.\n"; } } if (!cmdInputErrorMsg.equalsIgnoreCase("")) { throw new ParseException(cmdInputErrorMsg); } DecimalFormat df = new DecimalFormat("##0"); RunTcpInTcpOutTest t = new RunTcpInTcpOutTest(); if (start_rate == end_rate) { // Single Rate Test System.out.println("*********************************"); System.out.println("Incremental testing at requested rate: " + start_rate); System.out.println("Count,Incremental Rate"); t.runTest(numberEvents, start_rate, server, in_port, out_port, true); if (t.send_rate < 0 || t.rcv_rate < 0) { throw new Exception("Test Run Failed!"); } System.out.println("Overall Average Send Rate, Received Rate"); System.out.println(df.format(t.send_rate) + "," + df.format(t.rcv_rate)); } else { System.out.println("*********************************"); System.out.println("rateRqstd,avgSendRate,avgRcvdRate"); //for (int rate: rates) { for (int rate = start_rate; rate <= end_rate; rate += rate_step) { t.runTest(numberEvents, rate, server, in_port, out_port, false); if (t.send_rate < 0 || t.rcv_rate < 0) { throw new Exception("Test Run Failed!"); } System.out.println( Integer.toString(rate) + "," + df.format(t.send_rate) + "," + df.format(t.rcv_rate)); } } } catch (ParseException e) { System.out.println("Invalid Command Options: "); System.out.println(e.getMessage()); System.out.println( "Command line options: -n NumEvents -s Server -i InputPort -o OutputPort -r StartRate,EndRate,Step"); } catch (Exception e) { System.out.println(e.getMessage()); } }
From source file:net.aepik.alasca.plugin.schemaquery.SchemaQueryTool.java
/** * Launch this tool.//from w w w.j av a2 s . c om */ public static void main(String[] args) { String inFile = null; String inSyntax = null; boolean attr = false; boolean objt = false; boolean synt = false; // // Parsing options. // CommandLineParser parser = new GnuParser(); try { CommandLine cmdOptions = parser.parse(options, args); inFile = cmdOptions.getOptionValue("i"); inSyntax = cmdOptions.getOptionValue("I"); if (cmdOptions.hasOption("a")) { attr = true; } if (cmdOptions.hasOption("o")) { objt = true; } if (cmdOptions.hasOption("l")) { synt = true; } if (cmdOptions.getOptions().length == 0) { displayHelp(); System.exit(2); } } catch (MissingArgumentException e) { System.out.println("Missing arguments\n"); displayHelp(); System.exit(2); } catch (ParseException e) { System.out.println("Wrong arguments\n"); displayHelp(); System.exit(2); } // // Print query options. // if (synt) { displayAvailableSyntaxes(); System.exit(0); } // // Launch schema. // SchemaSyntax inSchemaSyntax = createSchemaSyntax(inSyntax); if (inSchemaSyntax == null) { System.out.println("Unknow input syntax (" + inSyntax + ")"); System.exit(1); } Schema inSchema = createSchema(inSchemaSyntax, inFile); if (inSchema == null) { System.out.println("Failed to read input schema file (" + inFile + ")"); System.exit(1); } // // List if asks // if (attr) { displayAttributes(inSchema); } if (objt) { displayObjectClasses(inSchema); } System.exit(0); }