org.apache.commons.cli.CommandLineParser Java Examples
The following examples show how to use
org.apache.commons.cli.CommandLineParser.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlowPersistenceProviderMigrator.java From nifi-registry with Apache License 2.0 | 6 votes |
public static void main(String[] args) { Options options = new Options(); options.addOption("t", "to", true, "Providers xml to migrate to."); CommandLineParser parser = new DefaultParser(); CommandLine commandLine = null; try { commandLine = parser.parse(options, args); } catch (ParseException e) { log.error("Unable to parse command line.", e); new HelpFormatter().printHelp("persistence-toolkit [args]", options); System.exit(PARSE_EXCEPTION); } NiFiRegistryProperties fromProperties = NiFiRegistry.initializeProperties(NiFiRegistry.getMasterKeyProvider()); DataSource dataSource = new DataSourceFactory(fromProperties).getDataSource(); DatabaseMetadataService fromMetadataService = new DatabaseMetadataService(new JdbcTemplate(dataSource)); FlowPersistenceProvider fromPersistenceProvider = createFlowPersistenceProvider(fromProperties, dataSource); FlowPersistenceProvider toPersistenceProvider = createFlowPersistenceProvider(createToProperties(commandLine, fromProperties), dataSource); new FlowPersistenceProviderMigrator().doMigrate(fromMetadataService, fromPersistenceProvider, toPersistenceProvider); }
Example #2
Source File: ServerUtil.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
public static CommandLine parseCmdLine(final String appName, String[] args, Options options, CommandLineParser parser) { HelpFormatter hf = new HelpFormatter(); hf.setWidth(110); CommandLine commandLine = null; try { commandLine = parser.parse(options, args); if (commandLine.hasOption('h')) { hf.printHelp(appName, options, true); return null; } } catch (ParseException e) { hf.printHelp(appName, options, true); } return commandLine; }
Example #3
Source File: TestTFileSeek.java From hadoop with Apache License 2.0 | 6 votes |
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(); } }
Example #4
Source File: BaseCommandLine.java From localization_nifi with Apache License 2.0 | 6 votes |
protected CommandLine doParse(String[] args) throws CommandLineParseException { CommandLineParser parser = new DefaultParser(); CommandLine commandLine; try { commandLine = parser.parse(options, args); if (commandLine.hasOption(HELP_ARG)) { return printUsageAndThrow(null, ExitCode.HELP); } certificateAuthorityHostname = commandLine.getOptionValue(CERTIFICATE_AUTHORITY_HOSTNAME_ARG, TlsConfig.DEFAULT_HOSTNAME); days = getIntValue(commandLine, DAYS_ARG, TlsConfig.DEFAULT_DAYS); keySize = getIntValue(commandLine, KEY_SIZE_ARG, TlsConfig.DEFAULT_KEY_SIZE); keyAlgorithm = commandLine.getOptionValue(KEY_ALGORITHM_ARG, TlsConfig.DEFAULT_KEY_PAIR_ALGORITHM); keyStoreType = commandLine.getOptionValue(KEY_STORE_TYPE_ARG, getKeyStoreTypeDefault()); if (KeystoreType.PKCS12.toString().equalsIgnoreCase(keyStoreType)) { logger.info("Command line argument --" + KEY_STORE_TYPE_ARG + "=" + keyStoreType + " only applies to keystore, recommended truststore type of " + KeystoreType.JKS.toString() + " unaffected."); } signingAlgorithm = commandLine.getOptionValue(SIGNING_ALGORITHM_ARG, TlsConfig.DEFAULT_SIGNING_ALGORITHM); differentPasswordForKeyAndKeystore = commandLine.hasOption(DIFFERENT_KEY_AND_KEYSTORE_PASSWORDS_ARG); } catch (ParseException e) { return printUsageAndThrow("Error parsing command line. (" + e.getMessage() + ")", ExitCode.ERROR_PARSING_COMMAND_LINE); } return commandLine; }
Example #5
Source File: StompClient.java From amazon-mq-workshop with Apache License 2.0 | 6 votes |
private static CommandLine parseAndValidateCommandLineArguments(String[] args) throws ParseException { Options options = new Options(); options.addOption("help", false, "Print the help message."); options.addOption("url", true, "The broker connection url."); options.addOption("user", true, "The user to connect to the broker."); options.addOption("password", true, "The password for the user."); options.addOption("mode", true, "Whether to act as 'sender' or 'receiver'"); options.addOption("type", true, "Whether to use a queue or a topic."); options.addOption("destination", true, "The name of the queue or topic"); options.addOption("name", true, "The name of the sender"); options.addOption("interval", true, "The interval in msec at which messages are generated. Default 1000"); CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("help")) { printUsage(options); } if (!(cmd.hasOption("url") && cmd.hasOption("mode") && cmd.hasOption("destination"))) { printUsage(options); } return cmd; }
Example #6
Source File: HealthManager.java From Dhalion with MIT License | 6 votes |
public static void main(String[] args) throws Exception { CommandLineParser parser = new DefaultParser(); Options slaManagerCliOptions = constructCliOptions(); // parse the help options first. Options helpOptions = constructHelpOptions(); CommandLine cmd = parser.parse(helpOptions, args, true); if (cmd.hasOption("h")) { usage(slaManagerCliOptions); return; } try { cmd = parser.parse(slaManagerCliOptions, args); } catch (ParseException e) { usage(slaManagerCliOptions); throw new RuntimeException("Error parsing command line options: ", e); } LOG.info("Initializing the health manager"); HealthManager healthmgr = new HealthManager(cmd); healthmgr.start(); }
Example #7
Source File: DigestAnalyzer.java From steady with Apache License 2.0 | 6 votes |
/** * <p>main.</p> * * @param _args an array of {@link java.lang.String} objects. */ public static void main(String[] _args){ // Prepare parsing of cmd line arguments final Options options = new Options(); options.addOption("digest", "digest", true, "Delete all existing results before upload; otherwise only upload results for AffectedLibraries not already existing in the backend"); try { final CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, _args); if(cmd.hasOption("digest")){ String digest = cmd.getOptionValue("digest"); log.info("Running patcheval to assess all bugs of digest["+digest+"], all other options will be ignored."); DigestAnalyzer d = new DigestAnalyzer(digest); d.analyze(); } } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
Example #8
Source File: CmdLineOpts.java From yb-sample-apps with Apache License 2.0 | 6 votes |
private static void parseHelpDetailed(String[] args, Options options) throws Exception { Options helpOptions = new Options(); helpOptions.addOption("help", true, "Print help."); CommandLineParser helpParser = new BasicParser(); CommandLine helpCommandLine = null; try { helpCommandLine = helpParser.parse(helpOptions, args); } catch (org.apache.commons.cli.MissingArgumentException e1) { // This is ok since there was no help argument passed. return; } catch (ParseException e) { return; } if (helpCommandLine.hasOption("help")) { printUsageDetails(options, "Usage:", helpCommandLine.getOptionValue("help")); System.exit(0); } }
Example #9
Source File: CliUtil.java From javatech with Creative Commons Attribution Share Alike 4.0 International | 6 votes |
public static void prepare(String[] args) throws Exception { // commons-cli命令行参数,需要带参数值 Options options = new Options(); // sql文件路径 options.addOption("sql", true, "sql config"); // 任务名称 options.addOption("name", true, "job name"); // 解析命令行参数 CommandLineParser parser = new DefaultParser(); CommandLine cl = parser.parse(options, args); String sql = cl.getOptionValue("sql"); String name = cl.getOptionValue("name"); System.out.println("sql : " + sql); System.out.println("name : " + name); }
Example #10
Source File: CommandLineApplication.java From validator with Apache License 2.0 | 6 votes |
/** * Hauptprogramm für die Kommandozeilen-Applikation. * * @param args die Eingabe-Argumente */ static int mainProgram(final String[] args) { int returnValue = 0; final Options options = createOptions(); if (isHelpRequested(args)) { printHelp(options); } else { try { final CommandLineParser parser = new DefaultParser(); final CommandLine cmd = parser.parse(options, args); if (cmd.hasOption(SERVER.getOpt())) { returnValue = startDaemonMode(cmd); } else if (cmd.getArgList().isEmpty()) { printHelp(createOptions()); } else { returnValue = processActions(cmd); } } catch (final ParseException e) { log.error("Error processing command line arguments: " + e.getMessage()); printHelp(options); } } return returnValue; }
Example #11
Source File: BrokerReplacement.java From doctorkafka with Apache License 2.0 | 6 votes |
/** * Usage: BrokerReplacement -broker broker1 -command "relaunch host script" */ private static CommandLine parseCommandLine(String[] args) { Option broker = new Option(BROKER, true, "broker name"); Option command = new Option(COMMAND, true, "command for relaunching a host"); options.addOption(broker).addOption(command); if (args.length < 3) { printUsageAndExit(); } CommandLineParser parser = new DefaultParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (ParseException | NumberFormatException e) { printUsageAndExit(); } return cmd; }
Example #12
Source File: ApexCli.java From Bats with Apache License 2.0 | 5 votes |
static GetOperatorClassesCommandLineInfo getGetOperatorClassesCommandLineInfo(String[] args) throws ParseException { CommandLineParser parser = new PosixParser(); GetOperatorClassesCommandLineInfo result = new GetOperatorClassesCommandLineInfo(); CommandLine line = parser.parse(GET_OPERATOR_CLASSES_OPTIONS.options, args); result.parent = line.getOptionValue("parent"); result.args = line.getArgs(); return result; }
Example #13
Source File: ApexCli.java From Bats with Apache License 2.0 | 5 votes |
static LaunchCommandLineInfo getLaunchCommandLineInfo(String[] args) throws ParseException { CommandLineParser parser = new PosixParser(); LaunchCommandLineInfo result = new LaunchCommandLineInfo(); CommandLine line = parser.parse(LAUNCH_OPTIONS.options, args); result.localMode = line.hasOption(LAUNCH_OPTIONS.local.getOpt()); result.configFile = line.getOptionValue(LAUNCH_OPTIONS.configFile.getOpt()); result.apConfigFile = line.getOptionValue(LAUNCH_OPTIONS.apConfigFile.getOpt()); result.ignorePom = line.hasOption(LAUNCH_OPTIONS.ignorePom.getOpt()); String[] defs = line.getOptionValues(LAUNCH_OPTIONS.defProperty.getOpt()); if (defs != null) { result.overrideProperties = new HashMap<>(); for (String def : defs) { int equal = def.indexOf('='); if (equal < 0) { result.overrideProperties.put(def, null); } else { result.overrideProperties.put(def.substring(0, equal), def.substring(equal + 1)); } } } result.libjars = line.getOptionValue(LAUNCH_OPTIONS.libjars.getOpt()); result.archives = line.getOptionValue(LAUNCH_OPTIONS.archives.getOpt()); result.files = line.getOptionValue(LAUNCH_OPTIONS.files.getOpt()); result.queue = line.getOptionValue(LAUNCH_OPTIONS.queue.getOpt()); result.tags = line.getOptionValue(LAUNCH_OPTIONS.tags.getOpt()); result.args = line.getArgs(); result.origAppId = line.getOptionValue(LAUNCH_OPTIONS.originalAppID.getOpt()); result.exactMatch = line.hasOption("exactMatch"); result.force = line.hasOption("force"); result.useConfigApps = line.getOptionValue(LAUNCH_OPTIONS.useConfigApps.getOpt()); return result; }
Example #14
Source File: ApexCli.java From Bats with Apache License 2.0 | 5 votes |
private static ShowLogicalPlanCommandLineInfo getShowLogicalPlanCommandLineInfo(String[] args) throws ParseException { CommandLineParser parser = new PosixParser(); ShowLogicalPlanCommandLineInfo result = new ShowLogicalPlanCommandLineInfo(); CommandLine line = parser.parse(getShowLogicalPlanCommandLineOptions(), args); result.libjars = line.getOptionValue("libjars"); result.ignorePom = line.hasOption("ignorepom"); result.args = line.getArgs(); result.exactMatch = line.hasOption("exactMatch"); return result; }
Example #15
Source File: BddScenariosCounter.java From vividus with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws ParseException, InitializationError, ReflectiveOperationException { Vividus.init(); CommandLineParser parser = new DefaultParser(); Option helpOption = new Option("h", "help", false, "print this message."); Option directoryOption = new Option("d", "dir", true, "directory to count scenarios in (e.g. story/release)."); Options options = new Options(); options.addOption(helpOption); options.addOption(directoryOption); CommandLine commandLine = parser.parse(options, args); if (commandLine.hasOption(helpOption.getOpt())) { new HelpFormatter().printHelp("BddScenariosCounter", options); return; } String storyLocation = commandLine.hasOption(directoryOption.getOpt()) ? commandLine.getOptionValue(directoryOption.getOpt()) : DEFAULT_STORY_LOCATION; configureStoryLocation(storyLocation); System.out.println("Story parsing may take up to 5 minutes. Please be patient."); JUnitReportingRunner runner = new JUnitReportingRunner(StoriesRunner.class); print(getNumberOfChildren(runner.getDescription(), BDDLevel.STORY.getLevel()), "Stories"); print(getNumberOfChildren(runner.getDescription(), BDDLevel.SCENARIO.getLevel()), "Scenarios"); print(getNumberOfChildren(runner.getDescription(), BDDLevel.EXAMPLE.getLevel()), "Scenarios with Examples"); }
Example #16
Source File: MLPlanCLI.java From AILibs with GNU Affero General Public License v3.0 | 5 votes |
private static CommandLine generateCommandLine(final Options options, final String[] commandLineArguments) { final CommandLineParser cmdLineParser = new DefaultParser(); CommandLine commandLine = null; try { commandLine = cmdLineParser.parse(options, commandLineArguments); } catch (ParseException parseException) { logger.error("ERROR: Unable to parse command-line arguments {} due to {}", Arrays.toString(commandLineArguments), parseException); } return commandLine; }
Example #17
Source File: FileSystemEventReader.java From singer with Apache License 2.0 | 5 votes |
private static CommandLine parseCommandLine(String[] args) { Option path = new Option(PATH, true, "path to be monitored"); Option poll_interval_ms = new Option(POLL_INTERVAL_MS, true, "interval in milliseconds to poll for file system events"); options.addOption(path).addOption(poll_interval_ms); if (args.length < 1) { printUsageAndExit(); } CommandLineParser parser = new DefaultParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (ParseException | NumberFormatException e) { printUsageAndExit(); } return cmd; }
Example #18
Source File: GenbankInterpreter.java From act with GNU General Public License v3.0 | 5 votes |
public static void main(String[] args) throws Exception { Options opts = new Options(); for (Option.Builder b : OPTION_BUILDERS) { opts.addOption(b.build()); } CommandLine cl = null; try { CommandLineParser parser = new DefaultParser(); cl = parser.parse(opts, args); } catch (ParseException e) { LOGGER.error("Argument parsing failed: %s", e.getMessage()); HELP_FORMATTER.printHelp(GenbankInterpreter.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } if (cl.hasOption("help")) { HELP_FORMATTER.printHelp(GenbankInterpreter.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } File genbankFile = new File(cl.getOptionValue(OPTION_GENBANK_PATH)); String seq_type = cl.getOptionValue(OPTION_SEQ_TYPE); if (!genbankFile.exists()) { String msg = "Genbank file path is null"; LOGGER.error(msg); throw new RuntimeException(msg); } else { GenbankInterpreter reader = new GenbankInterpreter(genbankFile, seq_type); reader.init(); reader.printSequences(); } }
Example #19
Source File: DataflowAddNodeExperiment.java From twister2 with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws ParseException { // first load the configurations from command line and config files Config config = ResourceAllocator.loadConfig(new HashMap<>()); // build JobConfig HashMap<String, Object> configurations = new HashMap<>(); configurations.put(SchedulerContext.THREADS_PER_WORKER, 8); Options options = new Options(); options.addOption(DataObjectConstants.ARGS_ITERATIONS, true, "iter"); options.addOption(DataObjectConstants.PARALLELISM_VALUE, true, "parallelism"); options.addOption(DataObjectConstants.WORKERS, true, "workers"); options.addOption(DataObjectConstants.DSIZE, true, "dsize"); CommandLineParser commandLineParser = new DefaultParser(); CommandLine cmd = commandLineParser.parse(options, args); int workers = Integer.parseInt(cmd.getOptionValue(DataObjectConstants.WORKERS)); int parallelismValue = Integer.parseInt(cmd.getOptionValue( DataObjectConstants.PARALLELISM_VALUE)); int iterations = Integer.parseInt(cmd.getOptionValue( DataObjectConstants.ARGS_ITERATIONS)); int dsize = Integer.parseInt(cmd.getOptionValue(DataObjectConstants.DSIZE)); // build JobConfig JobConfig jobConfig = new JobConfig(); jobConfig.put(DataObjectConstants.DSIZE, Integer.toString(dsize)); jobConfig.put(DataObjectConstants.WORKERS, Integer.toString(workers)); jobConfig.put(DataObjectConstants.PARALLELISM_VALUE, Integer.toString(parallelismValue)); jobConfig.put(DataObjectConstants.ARGS_ITERATIONS, Integer.toString(iterations)); jobConfig.putAll(configurations); Twister2Job.Twister2JobBuilder jobBuilder = Twister2Job.newBuilder(); jobBuilder.setJobName("Experiment2"); jobBuilder.setWorkerClass(DataflowAddNodeExperiment.class.getName()); jobBuilder.addComputeResource(2, 512, 1.0, workers); jobBuilder.setConfig(jobConfig); // now submit the job Twister2Submitter.submitJob(jobBuilder.build(), config); }
Example #20
Source File: FlinkYarnSessionCliTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testDynamicProperties() throws Exception { FlinkYarnSessionCli cli = new FlinkYarnSessionCli( new Configuration(), tmp.getRoot().getAbsolutePath(), "", "", false); Options options = new Options(); cli.addGeneralOptions(options); cli.addRunOptions(options); CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, new String[]{"run", "-j", "fake.jar", "-n", "15", "-D", "akka.ask.timeout=5 min", "-D", "env.java.opts=-DappName=foobar"}); AbstractYarnClusterDescriptor flinkYarnDescriptor = cli.createClusterDescriptor(cmd); Assert.assertNotNull(flinkYarnDescriptor); Map<String, String> dynProperties = FlinkYarnSessionCli.getDynamicProperties(flinkYarnDescriptor.getDynamicPropertiesEncoded()); assertEquals(2, dynProperties.size()); assertEquals("5 min", dynProperties.get("akka.ask.timeout")); assertEquals("-DappName=foobar", dynProperties.get("env.java.opts")); }
Example #21
Source File: MesosSessionClusterEntrypoint.java From flink with Apache License 2.0 | 5 votes |
public static void main(String[] args) { // startup checks and logging EnvironmentInformation.logEnvironmentInfo(LOG, MesosSessionClusterEntrypoint.class.getSimpleName(), args); SignalHandler.register(LOG); JvmShutdownSafeguard.installAsShutdownHook(LOG); // load configuration incl. dynamic properties CommandLineParser parser = new PosixParser(); CommandLine cmd; try { cmd = parser.parse(ALL_OPTIONS, args); } catch (Exception e){ LOG.error("Could not parse the command-line options.", e); System.exit(STARTUP_FAILURE_RETURN_CODE); return; } Configuration dynamicProperties = BootstrapTools.parseDynamicProperties(cmd); Configuration configuration = MesosEntrypointUtils.loadConfiguration(dynamicProperties, LOG); MesosSessionClusterEntrypoint clusterEntrypoint = new MesosSessionClusterEntrypoint(configuration, dynamicProperties); ClusterEntrypoint.runClusterEntrypoint(clusterEntrypoint); }
Example #22
Source File: ProductScorer.java From act with GNU General Public License v3.0 | 5 votes |
public static void main(String[] args) throws Exception { // Build command line parser. Options opts = new Options(); for (Option.Builder b : OPTION_BUILDERS) { opts.addOption(b.build()); } CommandLine cl = null; try { CommandLineParser parser = new DefaultParser(); cl = parser.parse(opts, args); } catch (ParseException e) { LOGGER.error("Argument parsing failed: %s", e.getMessage()); HELP_FORMATTER.printHelp(L2FilteringDriver.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } File inputCorpusFile = new File(cl.getOptionValue(OPTION_PREDICTION_CORPUS)); File lcmsFile = new File(cl.getOptionValue(OPTION_LCMS_RESULTS)); File scoredSarsFile = new File(cl.getOptionValue(OPTION_SCORED_SARS)); File outputFile = new File(cl.getOptionValue(OPTION_OUTPUT_PATH)); JavaRunnable productScoreRunner = getProductScorer( inputCorpusFile, scoredSarsFile, lcmsFile, outputFile); LOGGER.info("Scoring products."); productScoreRunner.run(); LOGGER.info("Complete!."); }
Example #23
Source File: SecondaryNameNode.java From hadoop with Apache License 2.0 | 5 votes |
public void parse(String ... argv) throws ParseException { CommandLineParser parser = new PosixParser(); CommandLine cmdLine = parser.parse(options, argv); if (cmdLine.hasOption(helpOpt.getOpt()) || cmdLine.hasOption(helpOpt.getLongOpt())) { shouldPrintHelp = true; return; } boolean hasGetEdit = cmdLine.hasOption(geteditsizeOpt.getOpt()); boolean hasCheckpoint = cmdLine.hasOption(checkpointOpt.getOpt()); if (hasGetEdit && hasCheckpoint) { throw new ParseException("May not pass both " + geteditsizeOpt.getOpt() + " and " + checkpointOpt.getOpt()); } if (hasGetEdit) { cmd = Command.GETEDITSIZE; } else if (hasCheckpoint) { cmd = Command.CHECKPOINT; String arg = cmdLine.getOptionValue(checkpointOpt.getOpt()); if ("force".equals(arg)) { shouldForce = true; } else if (arg != null) { throw new ParseException("-checkpoint may only take 'force' as an " + "argument"); } } if (cmdLine.hasOption(formatOpt.getOpt())) { shouldFormat = true; } }
Example #24
Source File: OptionsParser.java From Quicksql with MIT License | 5 votes |
private void parseOptions(String[] args) throws ParseException { SubmitOption[] values = SubmitOption.values(); List<Option> optionList = Arrays.stream(values) .map(option -> Option.builder().longOpt(option.key).hasArg().build()).collect(Collectors.toList()); Options options = new Options(); optionList.forEach(options::addOption); CommandLineParser parser = new DefaultParser(); commandLine = parser.parse(options, args); }
Example #25
Source File: DataflowNodeExperiment.java From twister2 with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws ParseException { // first load the configurations from command line and config files Config config = ResourceAllocator.loadConfig(new HashMap<>()); // build JobConfig HashMap<String, Object> configurations = new HashMap<>(); configurations.put(SchedulerContext.THREADS_PER_WORKER, 8); Options options = new Options(); options.addOption(DataObjectConstants.ARGS_ITERATIONS, true, "iter"); options.addOption(DataObjectConstants.PARALLELISM_VALUE, true, "parallelism"); options.addOption(DataObjectConstants.WORKERS, true, "workers"); options.addOption(DataObjectConstants.DSIZE, true, "dsize"); CommandLineParser commandLineParser = new DefaultParser(); CommandLine cmd = commandLineParser.parse(options, args); int workers = Integer.parseInt(cmd.getOptionValue(DataObjectConstants.WORKERS)); int parallelismValue = Integer.parseInt(cmd.getOptionValue( DataObjectConstants.PARALLELISM_VALUE)); int iterations = Integer.parseInt(cmd.getOptionValue( DataObjectConstants.ARGS_ITERATIONS)); int dsize = Integer.parseInt(cmd.getOptionValue(DataObjectConstants.DSIZE)); // build JobConfig JobConfig jobConfig = new JobConfig(); jobConfig.put(DataObjectConstants.DSIZE, Integer.toString(dsize)); jobConfig.put(DataObjectConstants.WORKERS, Integer.toString(workers)); jobConfig.put(DataObjectConstants.PARALLELISM_VALUE, Integer.toString(parallelismValue)); jobConfig.put(DataObjectConstants.ARGS_ITERATIONS, Integer.toString(iterations)); jobConfig.putAll(configurations); Twister2Job.Twister2JobBuilder jobBuilder = Twister2Job.newBuilder(); jobBuilder.setJobName("Experiment1"); jobBuilder.setWorkerClass(DataflowNodeExperiment.class.getName()); jobBuilder.addComputeResource(2, 512, 1.0, workers); jobBuilder.setConfig(jobConfig); // now submit the job Twister2Submitter.submitJob(jobBuilder.build(), config); }
Example #26
Source File: SQLServerManager.java From aliyun-maxcompute-data-collectors with Apache License 2.0 | 5 votes |
/** * Parse extra arguments. * * @param args Extra arguments array * @throws ParseException */ void parseExtraArgs(String[] args) throws ParseException { // No-op when no extra arguments are present if (args == null || args.length == 0) { return; } // We do not need extended abilities of SqoopParser, so we're using // Gnu parser instead. CommandLineParser parser = new GnuParser(); CommandLine cmdLine = parser.parse(getExtraOptions(), args, true); // Apply extra options if (cmdLine.hasOption(SCHEMA)) { String schemaName = cmdLine.getOptionValue(SCHEMA); LOG.info("We will use schema " + schemaName); this.schema = schemaName; } // Apply table hints if (cmdLine.hasOption(TABLE_HINTS)) { String hints = cmdLine.getOptionValue(TABLE_HINTS); LOG.info("Sqoop will use following table hints for data transfer: " + hints); this.tableHints = hints; } identityInserts = cmdLine.hasOption(IDENTITY_INSERT); }
Example #27
Source File: CommandLineUriParserTest.java From cyberduck with GNU General Public License v3.0 | 5 votes |
@Test public void testCustomProvider() throws Exception { final CommandLineParser parser = new PosixParser(); final CommandLine input = parser.parse(new Options(), new String[]{}); final ProtocolFactory factory = new ProtocolFactory(new LinkedHashSet<>(Collections.singletonList(new SwiftProtocol()))); final Profile rackspace = new ProfilePlistReader(factory).read(this.getClass().getResourceAsStream("/Rackspace US.cyberduckprofile")); assertEquals(new SwiftProtocol(), rackspace.getProtocol()); factory.register(rackspace); final Profile generic = new ProfilePlistReader(factory).read(this.getClass().getResourceAsStream("/Openstack Swift (Keystone 2).cyberduckprofile")); assertEquals(new SwiftProtocol(), generic.getProtocol()); factory.register(generic); assertEquals(rackspace, new CommandLineUriParser(input, factory).parse("rackspace://container//").getProtocol()); assertEquals(0, new Host(rackspace, "identity.api.rackspacecloud.com", 443, "/container") .compareTo(new CommandLineUriParser(input, factory).parse("rackspace://container/"))); assertEquals(generic, new CommandLineUriParser(input, factory).parse("swift://auth.cloud.ovh.net/container/").getProtocol()); assertEquals(0, new Host(generic, "auth.cloud.ovh.net", 443, "/container") .compareTo(new CommandLineUriParser(input, factory).parse("swift://auth.cloud.ovh.net/container/"))); }
Example #28
Source File: FeedingAnalysis.java From act with GNU General Public License v3.0 | 5 votes |
public static void main(String[] args) throws Exception { Options opts = new Options(); for (Option.Builder b : OPTION_BUILDERS) { opts.addOption(b.build()); } CommandLine cl = null; try { CommandLineParser parser = new DefaultParser(); cl = parser.parse(opts, args); } catch (ParseException e) { System.err.format("Argument parsing failed: %s\n", e.getMessage()); HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } if (cl.hasOption("help")) { HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); return; } File lcmsDir = new File(cl.getOptionValue(OPTION_DIRECTORY)); if (!lcmsDir.isDirectory()) { System.err.format("File at %s is not a directory\n", lcmsDir.getAbsolutePath()); HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } try (DB db = DB.openDBFromCLI(cl)) { System.out.format("Loading/updating LCMS scan files into DB\n"); ScanFile.insertOrUpdateScanFilesInDirectory(db, lcmsDir); System.out.format("Running feeding analysis\n"); performFeedingAnalysis(db, cl.getOptionValue(OPTION_DIRECTORY), cl.getOptionValue(OPTION_ION_NAME),cl.getOptionValue(OPTION_SEARCH_MZ), cl.getOptionValue(OPTION_PLATE_BARCODE), cl.getOptionValue(OPTION_FEEDING_STRAIN_OR_CONSTRUCT), cl.getOptionValue(OPTION_FEEDING_EXTRACT), cl.getOptionValue(OPTION_FEEDING_FED_CHEMICAL), cl.getOptionValue(OPTION_OUTPUT_PREFIX), "pdf"); } }
Example #29
Source File: ConditionalReachabilityInterpreter.java From act with GNU General Public License v3.0 | 5 votes |
public static void main(String[] args) throws Exception { // Parse the command line options Options opts = new Options(); for (Option.Builder b : OPTION_BUILDERS) { opts.addOption(b.build()); } CommandLine cl = null; try { CommandLineParser parser = new DefaultParser(); cl = parser.parse(opts, args); } catch (ParseException e) { System.err.format("Argument parsing failed: %s\n", e.getMessage()); HELP_FORMATTER.printHelp(BingSearchRanker.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } if (cl.hasOption("help")) { HELP_FORMATTER.printHelp(BingSearchRanker.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); return; } String inputPath = cl.getOptionValue(OPTION_INPUT_ACT_FILEPATH); String outputPath = cl.getOptionValue(OPTION_OUTPUT_FILEPATH); String dbName = cl.getOptionValue(OPTION_DB_NAME); LOGGER.info("Starting to deserialize reachables forest."); ActData.instance().deserialize(inputPath); ActData actData = ActData.instance(); LOGGER.info("Finished deserializing reachables forest."); NoSQLAPI db = new NoSQLAPI(dbName, dbName); ConditionalReachabilityInterpreter conditionalReachabilityInterpreter = new ConditionalReachabilityInterpreter(actData, db); conditionalReachabilityInterpreter.run(outputPath); }
Example #30
Source File: DoctorKafkaActionWriter.java From doctorkafka with Apache License 2.0 | 5 votes |
/** * Usage: KafkaWriter \ * --zookeeper zookeeper001:2181/cluster1 --topic kafka_test \ * --message "this is a test message" */ private static CommandLine parseCommandLine(String[] args) { Option zookeeper = new Option(ZOOKEEPER, true, "zookeeper connection string"); Option topic = new Option(TOPIC, true, "action report topic name"); Option message = new Option(MESSAGE, true, "messags that writes to kafka"); options.addOption(zookeeper).addOption(topic).addOption(message); if (args.length < 6) { printUsageAndExit(); } CommandLineParser parser = new DefaultParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (ParseException | NumberFormatException e) { printUsageAndExit(); } return cmd; }