/** * Main method. * * @param args * @throws IOException * @throws ParseException */ public static void main(String[] args) throws Exception { java.util.logging.Logger l = java.util.logging.Logger.getLogger("org.glassfish.grizzly.http.server.HttpHandler"); l.setLevel(java.util.logging.Level.FINE); l.setUseParentHandlers(false); java.util.logging.ConsoleHandler ch = new java.util.logging.ConsoleHandler(); ch.setLevel(java.util.logging.Level.ALL); l.addHandler(ch); CommandLineParser parser = new GnuParser(); Options options = new Options(); options.addOption("h", "host", true, "Server hostname."); options.addOption("p", "port", true, "TCP port to listen."); options.addOption("s", "storage_path", true, "Storage path."); options.addOption("w", "wat_gcube_token", true, "WAT gcube authentication token"); CommandLine line = parser.parse(options, args); String serverUri = String.format("http://%s:%d/smaph", line.getOptionValue("host", "localhost"), Integer.parseInt(line.getOptionValue("port", "8080"))); Path storage = Paths.get(line.getOptionValue("storage_path")); startServer(serverUri, storage, line.getOptionValue("wat_gcube_token")); }
/** * Test that options passed to the constructor are used. */ @SuppressWarnings("static-access") public void testCreateWithOptions() throws Exception { // Create new option newOpt Option opt = OptionBuilder.withArgName("int") .hasArg() .withDescription("A new option") .create("newOpt"); Options opts = new Options(); opts.addOption(opt); // Check newOpt is actually used to parse the args String[] args = new String[2]; args[0] = "--newOpt"; args[1] = "7"; GenericOptionsParser g = new GenericOptionsParser(opts, args); assertEquals("New option was ignored", "7", g.getCommandLine().getOptionValues("newOpt")[0]); }
public static void main(String[] args) { CommandLineParser parser = new DefaultParser(); try { Options options = getOptions(); CommandLine line = parser.parse(options, args ); if (line.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); System.out.println(Constants.PROJECT_NAME + ", " + Constants.PROJECT_URL); formatter.printHelp(Constants.PROJECT_NAME, options, true); } else if (line.hasOption("version")) { System.out.println("version: " + Constants.VERSION); } else { logger.info("Starting pm-home-station ({} v.{})...", Constants.PROJECT_URL, Constants.VERSION); setLookAndFeel(); PlanTowerSensor planTowerSensor = new PlanTowerSensor(); Station station = new Station(planTowerSensor); SwingUtilities.invokeLater(() -> { station.showUI(); }); } } catch (ParseException e) { logger.error("Ooops", e); return; } }
private static Options getOptions() { Options options = new Options(); options.addOption( Option.builder("in").longOpt(PARAMETER_INPUT_FILE).argName("input file").hasArg().desc("Input file. Can be a .rpx or .rpx").required().build()); options.addOption(Option.builder("f").longOpt(PARAMETER_FUNCTION_NAME).argName("The function name to be searched in the input file").hasArg().desc("").build()); options.addOption(Option.builder("m").longOpt(PARAMETER_MAX_SIGNATURE_LENGTH).hasArg() .desc("Maximum length of the signature that will be checked. Default is " + SIGNATURE_LENGTH).optionalArg(true).build()); options.addOption(Option.builder("t").longOpt(PARAMETER_FILTER_FILE).hasArg().argName("file").desc("A file containing a list of Hex Strings representing a list of TitleIDs in the folder " + RPX_WITH_SYMBOLS_FOLDER + " that should be used.").build()); options.addOption(Option.builder("v").longOpt(PARAMETER_VERBOSE_LOGGING).desc("Enables verbose logging").build()); options.addOption(Option.builder("e").longOpt(PARAMETER_EXTRA_FUNCTIONS).argName("filename").hasArg().desc("A file contains a list of functions that should be checked.").build()); options.addOption(Option.builder("s").longOpt(PARAMETER_RPX_WITH_SYMBOLS_FOLDER).hasArg().argName("filename").desc("Sets the path to the folder which contains folders (named the TITLEID) which contain the RPX files with symbols.=> A folder containing this: /1234567812345678/test.rpx /1234567812345698/test2.rpx").build()); options.addOption("help", false, "Shows this text"); return options; }
@Override public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) throws SubCommandException { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { defaultMQAdminExt.start(); String topic = commandLine.getOptionValue('t').trim(); TopicRouteData topicRouteData = defaultMQAdminExt.examineTopicRouteInfo(topic); String json = topicRouteData.toJson(true); System.out.printf("%s%n", json); } catch (Exception e) { throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e); } finally { defaultMQAdminExt.shutdown(); } }
/** * Creates an Options object, returns it. * @return Returns all acceptable command-line options. */ private static Options getOptions() { Options opts = new Options(); opts.addOption("h", "help", false, "Print the help"); opts.addOption("u", "url", true, "URL of album to rip"); opts.addOption("t", "threads", true, "Number of download threads per rip"); opts.addOption("w", "overwrite", false, "Overwrite existing files"); opts.addOption("r", "rerip", false, "Re-rip all ripped albums"); opts.addOption("R", "rerip-selected", false, "Re-rip all selected albums"); opts.addOption("d", "saveorder", false, "Save the order of images in album"); opts.addOption("D", "nosaveorder", false, "Don't save order of images"); opts.addOption("4", "skip404", false, "Don't retry after a 404 (not found) error"); opts.addOption("l", "ripsdirectory", true, "Rips Directory (Default: ./rips)"); opts.addOption("n", "no-prop-file", false, "Do not create properties file."); opts.addOption("f", "urls-file", true, "Rip URLs from a file."); opts.addOption("v", "version", false, "Show current version"); return opts; }
@Override public Options buildCommandlineOptions(Options options) { Option opt = new Option("g", "groupName", true, "consumer group name"); opt.setRequired(false); options.addOption(opt); return options; }
@Override public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); String topic = commandLine.getOptionValue('t').trim(); try { defaultMQAdminExt.start(); Set<String> clusters = defaultMQAdminExt.getTopicClusterList(topic); for (String value : clusters) { System.out.printf("%s%n", value); } } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { final String topic = commandLine.getOptionValue('t').trim(); final String key = commandLine.getOptionValue('k').trim(); this.queryByKey(defaultMQAdminExt, topic, key); } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException { DefaultMQAdminExt adminExt = new DefaultMQAdminExt(rpcHook); adminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { String topic = commandLine.getOptionValue('t').trim(); if (commandLine.hasOption('c')) { String clusterName = commandLine.getOptionValue('c').trim(); adminExt.start(); deleteTopic(adminExt, clusterName, topic); return; } ServerUtil.printCommandLineHelp("mqadmin " + this.commandName(), options); } catch (Exception e) { throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e); } finally { adminExt.shutdown(); } }
@Override public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); String topic = commandLine.getOptionValue('t').trim(); try { defaultMQAdminExt.start(); Set<String> clusters = defaultMQAdminExt.getTopicClusterList(topic); for (String value : clusters){ System.out.println(value); } } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { // namespace String namespace = commandLine.getOptionValue('s').trim(); // key name String key = commandLine.getOptionValue('k').trim(); // key name String value = commandLine.getOptionValue('v').trim(); defaultMQAdminExt.start(); defaultMQAdminExt.createAndUpdateKvConfig(namespace, key, value); System.out.printf("create or update kv config to namespace success.\n"); return; } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
public MyOptions(String[] args) { seed = System.nanoTime(); try { Options opts = buildOptions(); CommandLineParser parser = new GnuParser(); CommandLine line = parser.parse(opts, args, true); processOptions(line, opts); validateOptions(); } catch (ParseException e) { System.out.println(e.getMessage()); System.out.println("Try \"--help\" option for details."); setStopProceed(); } }
private static Options getOptions() { Options options = new Options(); //options.addOption("noui", false, "no UI, console only"); options.addOption("h", "help", false, "print this message and exit"); options.addOption("v", "version", false, "print the version information and exit"); return options; }
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { boolean result = false; defaultMQAdminExt.start(); if (commandLine.hasOption('b')) { String addr = commandLine.getOptionValue('b').trim(); result = defaultMQAdminExt.cleanUnusedTopicByAddr(addr); } else { String cluster = commandLine.getOptionValue('c'); if (null != cluster) cluster = cluster.trim(); result = defaultMQAdminExt.cleanUnusedTopicByAddr(cluster); } System.out.printf(result ? "success" : "false"); } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { boolean result = false; defaultMQAdminExt.start(); if (commandLine.hasOption('b')) { String addr = commandLine.getOptionValue('b').trim(); result = defaultMQAdminExt.cleanExpiredConsumerQueueByAddr(addr); } else { String cluster = commandLine.getOptionValue('c'); if (null != cluster) cluster = cluster.trim(); result = defaultMQAdminExt.cleanExpiredConsumerQueue(cluster); } System.out.printf(result ? "success" : "false"); } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
public final static void main(String[] args) throws Exception { logger.debug(format("%s called with arguments: '%s'.", UploadFileToTransport.class.getSimpleName(), Commands.Helpers.getArgsLogString(args))); Options options = new Options(); Commands.Helpers.addStandardParameters(options); if(helpRequested(args)) { handleHelpOption(format("%s <changeId> <transportId> <applicationId> <filePath>", getCommandName(UploadFileToTransport.class)), "Uploads the file specified by <filePath> to transport <transportId> for change <changeId>. " + "<applicationId> specifies how the file needs to be handled on server side.", new Options()); return; } CommandLine commandLine = new DefaultParser().parse(options, args); new UploadFileToTransport( getHost(commandLine), getUser(commandLine), getPassword(commandLine), getChangeId(commandLine), getArg(commandLine, 2, "transportId"), getArg(commandLine, 3, "applicationId"), getArg(commandLine, 4, "filePath")).execute(); }
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { boolean result = false; defaultMQAdminExt.start(); if (commandLine.hasOption('b')) { String addr = commandLine.getOptionValue('b').trim(); result = defaultMQAdminExt.cleanUnusedTopicByAddr(addr); } else { String cluster = commandLine.getOptionValue('c'); if (null != cluster) cluster = cluster.trim(); result = defaultMQAdminExt.cleanUnusedTopicByAddr(cluster); } System.out.printf(result ? "success" : "false"); } catch (Exception e) { throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e); } finally { defaultMQAdminExt.shutdown(); } }
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException { final DefaultMQProducer producer = new DefaultMQProducer("PID_SMSC", rpcHook); producer.setInstanceName("PID_SMSC_" + System.currentTimeMillis()); try { producer.start(); String brokerName = commandLine.getOptionValue('b').trim(); int messageSize = commandLine.hasOption('s') ? Integer.parseInt(commandLine.getOptionValue('s')) : 128; int count = commandLine.hasOption('c') ? Integer.parseInt(commandLine.getOptionValue('c')) : 50; producer.send(buildMessage(brokerName, 16)); for (int i = 0; i < count; i++) { long begin = System.currentTimeMillis(); SendResult result = producer.send(buildMessage(brokerName, messageSize)); System.out.printf("rt:" + (System.currentTimeMillis() - begin) + "ms, SendResult=" + result); } } catch (Exception e) { throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e); } finally { producer.shutdown(); } }
private static Options getOptions() { Options options = new Options(); options.addOption("b", "bind", true, "Address to bind the Thrift server to. [default: 0.0.0.0]"); options.addOption("p", "port", true, "Port to bind to [default: " + DEFAULT_LISTEN_PORT + "]"); options.addOption("f", "framed", false, "Use framed transport"); options.addOption("c", "compact", false, "Use the compact protocol"); options.addOption("w", "workers", true, "How many worker threads to use."); options.addOption("h", "help", false, "Print help information"); options.addOption(null, "infoport", true, "Port for web UI"); options.addOption("t", READ_TIMEOUT_OPTION, true, "Amount of time in milliseconds before a server thread will timeout " + "waiting for client to send data on a connected socket. Currently, " + "only applies to TBoundedThreadPoolServer"); OptionGroup servers = new OptionGroup(); servers.addOption( new Option("nonblocking", false, "Use the TNonblockingServer. This implies the framed transport.")); servers.addOption(new Option("hsha", false, "Use the THsHaServer. This implies the framed transport.")); servers.addOption(new Option("threadpool", false, "Use the TThreadPoolServer. This is the default.")); options.addOptionGroup(servers); return options; }
private static Options configureCommandLineOptions() { Options result = new Options(); result.addOption("i", "input", true, "specify the directory containing Parquet data files"); result.addOption("c", "config", true, "specify the xml file path containing namenode address and port"); return result; }
public static CommandLine parseCommandLine(String nameApp, String descriptionApp, String[] args, Options options) { CommandLineParser parser = new BasicParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (ParseException e) { usage(nameApp, descriptionApp, options); } return cmd; }
private static Options configureCommandLineOptions() { Options result = new Options(); result.addOption("s", "structPath", true, "specify the input file path containing the structure of dataset in the form of key=value pairs"); result.addOption("f", "structPath", true, "specify the path of a file .txt containing a set of values"); result.addOption("p", "partitions", true, "number of output Parquet data files"); result.addOption("r", "rows", true, "number of rows of each Parquet data file"); result.addOption("o", "output", true, "specify the output directory in which to store Parquet data files"); return result; }
@SuppressWarnings({ "static-access", "AccessStaticViaInstance" }) protected void getSharedOptions(Options options) { options.addOption(OptionBuilder.withArgName("results_path").hasArg() .withDescription("Directory in which to store the exported results lists. If omitted, defaults to the current directory.") .withLongOpt(EXPORT_RESULTS_PATH).create()); options.addOption(OptionBuilder.withArgName("string").hasArg() .withDescription("Prefix for the results lists file names. If omitted, results lists file names have no prefix.") .withLongOpt(EXPORT_RESULTS_PREFIX).create()); options.addOption(OptionBuilder.withArgName("integer").hasArg() .withDescription("Maximum number of connections per HCP system node. Valid range is from 1 to 100. If omitted, defaults to 25.") .withLongOpt(MAX_NODE_CONNECTIONS).create()); options.addOption(OptionBuilder.withArgName("integer").hasArg() .withDescription("Maximum number of connections to the HCP system. Valid range is from 2 to 1000. If omitted, defaults to 200") .withLongOpt(MAX_CONNECTIONS).create()); options.addOption(OptionBuilder.withArgName("integer").hasArg() .withDescription("Maximum number of connections per HCP system node during reduced load. Valid range is from 1 to 100. If omitted, defaults to 4.") .withLongOpt(REDUCED_MAX_NODE_CONNECTIONS).create()); options.addOption(OptionBuilder.withArgName("integer").hasArg() .withDescription("Maximum number of connections to the HCP system during reduced load. Valid range is from 2 to 1000. If omitted, defaults to 50.") .withLongOpt(REDUCED_MAX_CONNECTIONS).create()); options.addOption(OptionBuilder.withArgName("hh:mm").hasArg() .withDescription("Start time for the reduced load. If omitted, defaults to 08:00. If " + REDUCED_END + " is also omitted, reduced load is off.") .withLongOpt(REDUCED_START).create()); options.addOption(OptionBuilder.withArgName("hh:mm").hasArg() .withDescription("End time for the reduced load. If omitted, defaults to 20:00. If " + REDUCED_START + " is also omitted, reduced load is off.") .withLongOpt(REDUCED_END).create()); options.addOption(OptionBuilder.withArgName("job_name").hasArg() .withDescription("The name of the job.") .withLongOpt(JOB_NAME).create()); options.addOption(getInsecureSSLOption()); }
@Override public void execute(final CommandLine commandLine, final Options options, final RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { // servers String servers = commandLine.getOptionValue('n'); List<String> serverList = null; if (servers != null && servers.length() > 0) { String[] serverArray = servers.trim().split(";"); if (serverArray.length > 0) { serverList = Arrays.asList(serverArray); } } defaultMQAdminExt.start(); Map<String, Properties> nameServerConfigs = defaultMQAdminExt.getNameServerConfig(serverList); for (String server : nameServerConfigs.keySet()) { System.out.printf("============%s============\n", server); for (Object key : nameServerConfigs.get(server).keySet()) { System.out.printf("%-50s= %s\n", key, nameServerConfigs.get(server).get(key)); } } } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
/** * A check that the default settings are not outdated compared to what is in java.yaml. */ @Test public void testDefaultSettingsMatchJavaYaml() throws URISyntaxException, IOException, ParseException { Path path = Paths.get("../java.yaml"); ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); JavaYaml javaYaml = mapper.readValue(path.toFile(), JavaYaml.class); String[] args = ((ArrayList<String>) javaYaml.getSteps()[0].get("args")).toArray(new String[0]); Options options = new Options(); Application.addCliOptions(options); CommandLine cmd = new DefaultParser().parse(options, args); String[] jdkMappings = cmd.getOptionValues("j"); String[] serverMappings = cmd.getOptionValues("s"); assertTrue(Arrays.equals(jdkMappings, Application.DEFAULT_JDK_MAPPINGS)); assertTrue(Arrays.equals(serverMappings, Application.DEFAULT_SERVER_MAPPINGS)); String compatImage = cmd.getOptionValue("c"); String mavenImage = cmd.getOptionValue("m"); String gradleImage = cmd.getOptionValue("g"); assertEquals(compatImage, Application.DEFAULT_COMPAT_RUNTIME_IMAGE); assertEquals(mavenImage, Application.DEFAULT_MAVEN_DOCKER_IMAGE); assertEquals(gradleImage, Application.DEFAULT_GRADLE_DOCKER_IMAGE); }
@Override public Options getOptions() { Options options = new Options(); options.addOption(Option.builder() .longOpt(FILE) .desc("the script file") .hasArg() .required() .argName("FILE") .build()); return options; }
@Override public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); long printInterval = 1; boolean enableInterval = commandLine.hasOption('i'); if (enableInterval) { printInterval = Long.parseLong(commandLine.getOptionValue('i')) * 1000; } try { defaultMQAdminExt.start(); long i = 0; do { if (i++ > 0) { Thread.sleep(printInterval); } if (commandLine.hasOption('m')) { this.printClusterMoreStats(defaultMQAdminExt); } else { this.printClusterBaseInfo(defaultMQAdminExt); } } while (enableInterval); } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
@Override public Command getCommand() { return new Command() { @Override public String getName() { return "tool1"; } @Override public String getTheme() { return "theme1"; } @Override public String getDescription() { return "test tool1"; } @Override public Options getOptions() { Options options = new Options(); options.addOption(Option.builder() .longOpt("option1") .desc("this is option 1") .hasArg() .argName("FILE") .required() .build()); return options; } @Override public String getUsageFooter() { return "footer1"; } }; }
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { boolean result = false; defaultMQAdminExt.start(); if (commandLine.hasOption('b')) { String addr = commandLine.getOptionValue('b').trim(); result = defaultMQAdminExt.cleanUnusedTopicByAddr(addr); } else { String cluster = commandLine.getOptionValue('c'); if (null != cluster) cluster = cluster.trim(); result = defaultMQAdminExt.cleanUnusedTopicByAddr(cluster); } System.out.println(result ? "success" : "false"); } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
@Ignore @Test public void testExecute() throws SubCommandException { GetBrokerConfigCommand cmd = new GetBrokerConfigCommand(); Options options = ServerUtil.buildCommandlineOptions(new Options()); String[] subargs = new String[] {"-b 127.0.0.1:10911", "-c default-cluster"}; final CommandLine commandLine = ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options), new PosixParser()); cmd.execute(commandLine, options, null); }
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) { DefaultMQAdminExt adminExt = new DefaultMQAdminExt(rpcHook); adminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { adminExt.start(); String topic = commandLine.getOptionValue('t').trim(); String ips = commandLine.getOptionValue('i').trim(); final String[] split = ips.split(","); final List<String> ipList = new LinkedList<String>(); for (String ip : split) { ipList.add(ip); } final TopicRouteData topicRouteData = adminExt.examineTopicRouteInfo(topic); final Set<MessageQueue> mqs = MQClientInstance.topicRouteData2TopicSubscribeInfo(topic, topicRouteData); final AllocateMessageQueueAveragely averagely = new AllocateMessageQueueAveragely(); RebalanceResult rr = new RebalanceResult(); for (String i : ipList) { final List<MessageQueue> mqResult = averagely.allocate("aa", i, new ArrayList<MessageQueue>(mqs), ipList); rr.getResult().put(i, mqResult); } final String json = RemotingSerializable.toJson(rr, false); System.out.printf("%s%n", json); } catch (Exception e) { e.printStackTrace(); } finally { adminExt.shutdown(); } }
private void printHelpMessage(Options options) { System.out.println("Retrieve logs for completed YARN applications."); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("yarn logs -applicationId <application ID> [OPTIONS]", new Options()); formatter.setSyntaxPrefix(""); formatter.printHelp("general options are:", options); }
public static Options createMpiOptions() { Options options = new Options(); options.addOption(Option.builder() .longOpt(TMP_DIR) .desc("local temporary directory") .hasArg() .argName("dir") .build()); options.addOption(Option.builder() .longOpt(STATISTICS_DB_DIR) .desc("statistics db directory") .hasArg() .argName("dir") .build()); options.addOption(Option.builder() .longOpt(STATISTICS_DB_NAME) .desc("statistics db name") .hasArg() .argName("name") .build()); options.addOption(Option.builder() .longOpt(CORES) .desc("number of cores per rank") .hasArg() .required() .argName("n") .build()); options.addOption(Option.builder() .longOpt(VERBOSE) .desc("verbose mode") .build()); options.addOption(Option.builder() .longOpt(STDOUT_ARCHIVE) .desc("tasks standard output archive") .hasArg() .argName("file") .build()); return options; }
/** * * @param options * @param message */ protected static void printHelp(Options options,String message) { if (message!=null) System.out.println(message); System.out.println(title); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp( MainApp.class.getName(), options ); System.out.println("Examples:"); System.out.println(example_demo_fp()); System.out.println(example_demo_density()); System.out.println(example_density()); Runtime.getRuntime().runFinalization(); Runtime.getRuntime().exit(0); }
private static void printUsageAndExit(Options options, int exitCode) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("bin/hbase rest start", "", options, "\nTo run the REST server as a daemon, execute " + "bin/hbase-daemon.sh start|stop rest [--infoport <port>] [-p <port>] [-ro]\n", true); System.exit(exitCode); }
@Test public void testExecute() { DeleteTopicSubCommand cmd = new DeleteTopicSubCommand(); Options options = ServerUtil.buildCommandlineOptions(new Options()); String[] subargs = new String[] {"-t unit-test", "-c default-cluster"}; final CommandLine commandLine = ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options), new PosixParser()); assertThat(commandLine.getOptionValue('t').trim()).isEqualTo("unit-test"); assertThat(commandLine.getOptionValue("c").trim()).isEqualTo("default-cluster"); }
@SuppressWarnings({"rawtypes", "unchecked"}) private static void printHelp(Options options) { StringBuilder helpFooter = new StringBuilder(); helpFooter.append("Examples: \n"); helpFooter.append("config_upgrade.sh -c schema.xml -t schema -u solr_4_to_5_processors.xml -d /tmp/result-dir \n"); helpFooter.append("config_upgrade.sh --dry-run -c schema.xml -t schema -u solr_4_to_5_processors.xml -d /tmp/result-dir \n"); HelpFormatter formatter = new HelpFormatter(); formatter.setOptionComparator(new OptionComarator()); formatter.printHelp("ConfigUpgradeTool", null, options, helpFooter.toString(), false); }