Java Code Examples for org.apache.commons.cli.CommandLine#getOptionProperties()
The following examples show how to use
org.apache.commons.cli.CommandLine#getOptionProperties() .
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: StandaloneJobClusterConfigurationParserFactory.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override public StandaloneJobClusterConfiguration createResult(@Nonnull CommandLine commandLine) throws FlinkParseException { final String configDir = commandLine.getOptionValue(CONFIG_DIR_OPTION.getOpt()); final Properties dynamicProperties = commandLine.getOptionProperties(DYNAMIC_PROPERTY_OPTION.getOpt()); final int restPort = getRestPort(commandLine); final String hostname = commandLine.getOptionValue(HOST_OPTION.getOpt()); final SavepointRestoreSettings savepointRestoreSettings = CliFrontendParser.createSavepointRestoreSettings(commandLine); final JobID jobId = getJobId(commandLine); final String jobClassName = commandLine.getOptionValue(JOB_CLASS_NAME_OPTION.getOpt()); return new StandaloneJobClusterConfiguration( configDir, dynamicProperties, commandLine.getArgs(), hostname, restPort, savepointRestoreSettings, jobId, jobClassName); }
Example 2
Source File: StandaloneJobClusterConfigurationParserFactory.java From flink with Apache License 2.0 | 6 votes |
@Override public StandaloneJobClusterConfiguration createResult(@Nonnull CommandLine commandLine) throws FlinkParseException { final String configDir = commandLine.getOptionValue(CONFIG_DIR_OPTION.getOpt()); final Properties dynamicProperties = commandLine.getOptionProperties(DYNAMIC_PROPERTY_OPTION.getOpt()); final int restPort = getRestPort(commandLine); final String hostname = commandLine.getOptionValue(HOST_OPTION.getOpt()); final SavepointRestoreSettings savepointRestoreSettings = CliFrontendParser.createSavepointRestoreSettings(commandLine); final JobID jobId = getJobId(commandLine); final String jobClassName = commandLine.getOptionValue(JOB_CLASS_NAME_OPTION.getOpt()); return new StandaloneJobClusterConfiguration( configDir, dynamicProperties, commandLine.getArgs(), hostname, restPort, savepointRestoreSettings, jobId, jobClassName); }
Example 3
Source File: StatefulFunctionsClusterConfigurationParserFactory.java From stateful-functions with Apache License 2.0 | 6 votes |
@Override public StatefulFunctionsClusterConfiguration createResult(@Nonnull CommandLine commandLine) throws FlinkParseException { final String configDir = commandLine.getOptionValue(CONFIG_DIR_OPTION.getOpt()); final Properties dynamicProperties = commandLine.getOptionProperties(DYNAMIC_PROPERTY_OPTION.getOpt()); final int restPort = getRestPort(commandLine); final String hostname = commandLine.getOptionValue(HOST_OPTION.getOpt()); final SavepointRestoreSettings savepointRestoreSettings = CliFrontendParser.createSavepointRestoreSettings(commandLine); final JobID jobId = getJobId(commandLine); return new StatefulFunctionsClusterConfiguration( configDir, dynamicProperties, commandLine.getArgs(), hostname, restPort, savepointRestoreSettings, jobId); }
Example 4
Source File: StatefulFunctionsClusterConfigurationParserFactory.java From flink-statefun with Apache License 2.0 | 6 votes |
@Override public StatefulFunctionsClusterConfiguration createResult(@Nonnull CommandLine commandLine) throws FlinkParseException { final String configDir = commandLine.getOptionValue(CONFIG_DIR_OPTION.getOpt()); final Properties dynamicProperties = commandLine.getOptionProperties(DYNAMIC_PROPERTY_OPTION.getOpt()); final int restPort = getRestPort(commandLine); final String hostname = commandLine.getOptionValue(HOST_OPTION.getOpt()); final int parallelism = getParallelism(commandLine); final SavepointRestoreSettings savepointRestoreSettings = CliFrontendParser.createSavepointRestoreSettings(commandLine); final JobID jobId = getJobId(commandLine); return new StatefulFunctionsClusterConfiguration( configDir, dynamicProperties, commandLine.getArgs(), hostname, restPort, savepointRestoreSettings, jobId, parallelism); }
Example 5
Source File: FlinkYarnSessionCli.java From flink with Apache License 2.0 | 6 votes |
private String encodeDynamicProperties(final CommandLine cmd) { final Properties properties = cmd.getOptionProperties(dynamicproperties.getOpt()); final String[] dynamicProperties = properties.stringPropertyNames().stream() .flatMap( (String key) -> { final String value = properties.getProperty(key); LOG.info("Dynamic Property set: {}={}", key, GlobalConfiguration.isSensitive(key) ? GlobalConfiguration.HIDDEN_CONTENT : value); if (value != null) { return Stream.of(key + dynamicproperties.getValueSeparator() + value); } else { return Stream.empty(); } }) .toArray(String[]::new); return StringUtils.join(dynamicProperties, YARN_DYNAMIC_PROPERTIES_SEPARATOR); }
Example 6
Source File: StandaloneApplicationClusterConfigurationParserFactory.java From flink with Apache License 2.0 | 6 votes |
@Override public StandaloneApplicationClusterConfiguration createResult(@Nonnull CommandLine commandLine) throws FlinkParseException { final String configDir = commandLine.getOptionValue(CONFIG_DIR_OPTION.getOpt()); final Properties dynamicProperties = commandLine.getOptionProperties(DYNAMIC_PROPERTY_OPTION.getOpt()); final int restPort = getRestPort(commandLine); final String hostname = commandLine.getOptionValue(HOST_OPTION.getOpt()); final SavepointRestoreSettings savepointRestoreSettings = CliFrontendParser.createSavepointRestoreSettings(commandLine); final JobID jobId = getJobId(commandLine); final String jobClassName = commandLine.getOptionValue(JOB_CLASS_NAME_OPTION.getOpt()); return new StandaloneApplicationClusterConfiguration( configDir, dynamicProperties, commandLine.getArgs(), hostname, restPort, savepointRestoreSettings, jobId, jobClassName); }
Example 7
Source File: SPARQLExtCli.java From sparql-generate with Apache License 2.0 | 6 votes |
private static void replaceSourcesIfRequested(CommandLine cli, SPARQLExtQuery query) { final Properties replacementSources = cli.getOptionProperties(ARG_SOURCE_LONG); List<Element> updatedSources = query.getBindingClauses().stream().map(element -> { if (element instanceof ElementSource) { ElementSource elementSource = (ElementSource) element; String sourceURI = elementSource.getSource().toString(query.getPrefixMapping(), false); if (replacementSources.containsKey(sourceURI)) { Node replacementSource = NodeFactory.createURI(replacementSources.getProperty(sourceURI)); LOG.info("Replaced source <{}> with <{}>.", sourceURI, replacementSource); return new ElementSource(replacementSource, elementSource.getAccept(), elementSource.getVar()); } } return element; }).collect(Collectors.toList()); query.setBindingClauses(updatedSources); }
Example 8
Source File: EntrypointClusterConfigurationParserFactory.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public EntrypointClusterConfiguration createResult(@Nonnull CommandLine commandLine) { final String configDir = commandLine.getOptionValue(CONFIG_DIR_OPTION.getOpt()); final Properties dynamicProperties = commandLine.getOptionProperties(DYNAMIC_PROPERTY_OPTION.getOpt()); final String restPortStr = commandLine.getOptionValue(REST_PORT_OPTION.getOpt(), "-1"); final int restPort = Integer.parseInt(restPortStr); final String hostname = commandLine.getOptionValue(HOST_OPTION.getOpt()); return new EntrypointClusterConfiguration( configDir, dynamicProperties, commandLine.getArgs(), hostname, restPort); }
Example 9
Source File: GenericCLI.java From flink with Apache License 2.0 | 5 votes |
private void encodeDynamicProperties(final CommandLine commandLine, final Configuration effectiveConfiguration) { final Properties properties = commandLine.getOptionProperties(dynamicProperties.getOpt()); properties.stringPropertyNames() .forEach(key -> { final String value = properties.getProperty(key); if (value != null) { effectiveConfiguration.setString(key, value); } else { effectiveConfiguration.setString(key, "true"); } }); }
Example 10
Source File: ClusterConfigurationParserFactory.java From flink with Apache License 2.0 | 5 votes |
@Override public ClusterConfiguration createResult(@Nonnull CommandLine commandLine) { final String configDir = commandLine.getOptionValue(CONFIG_DIR_OPTION.getOpt()); final Properties dynamicProperties = commandLine.getOptionProperties(DYNAMIC_PROPERTY_OPTION.getOpt()); return new ClusterConfiguration(configDir, dynamicProperties, commandLine.getArgs()); }
Example 11
Source File: EntrypointClusterConfigurationParserFactory.java From flink with Apache License 2.0 | 5 votes |
@Override public EntrypointClusterConfiguration createResult(@Nonnull CommandLine commandLine) { final String configDir = commandLine.getOptionValue(CONFIG_DIR_OPTION.getOpt()); final Properties dynamicProperties = commandLine.getOptionProperties(DYNAMIC_PROPERTY_OPTION.getOpt()); final String restPortStr = commandLine.getOptionValue(REST_PORT_OPTION.getOpt(), "-1"); final int restPort = Integer.parseInt(restPortStr); final String hostname = commandLine.getOptionValue(HOST_OPTION.getOpt()); return new EntrypointClusterConfiguration( configDir, dynamicProperties, commandLine.getArgs(), hostname, restPort); }
Example 12
Source File: ArgParsingHelper.java From triplea with GNU General Public License v3.0 | 5 votes |
/** * Parses the set of input parameters for things that look like "-Pkey=value" and will return the * key/value pairs as a Properties object. */ public static Properties getTripleaProperties(final String... args) { final Options options = getOptions(); final CommandLineParser parser = new DefaultParser(); try { final CommandLine cli = parser.parse(options, args); return cli.getOptionProperties(TRIPLEA_PROPERTY_PREFIX); } catch (final ParseException e) { throw new IllegalArgumentException("Failed to parse args: " + Arrays.toString(args), e); } }
Example 13
Source File: End.java From rockscript with Apache License 2.0 | 5 votes |
@Override protected void parse(CommandLine commandLine) { super.parse(commandLine); this.scriptExecutionId = commandLine.getOptionValue("seid"); this.executionId = commandLine.getOptionValue("eid"); this.resultProperties = commandLine.getOptionProperties("p"); }
Example 14
Source File: Start.java From rockscript with Apache License 2.0 | 5 votes |
@Override protected void parse(CommandLine commandLine) { super.parse(commandLine); this.scriptName = commandLine.getOptionValue("n"); this.scriptVersionId = commandLine.getOptionValue("v"); this.input = commandLine.getOptionProperties("p"); if (this.input.isEmpty()) { this.input = null; } }
Example 15
Source File: ClusterConfigurationParserFactory.java From flink with Apache License 2.0 | 5 votes |
@Override public ClusterConfiguration createResult(@Nonnull CommandLine commandLine) { final String configDir = commandLine.getOptionValue(CONFIG_DIR_OPTION.getOpt()); final Properties dynamicProperties = commandLine.getOptionProperties(DYNAMIC_PROPERTY_OPTION.getOpt()); return new ClusterConfiguration(configDir, dynamicProperties, commandLine.getArgs()); }
Example 16
Source File: EntrypointClusterConfigurationParserFactory.java From flink with Apache License 2.0 | 5 votes |
@Override public EntrypointClusterConfiguration createResult(@Nonnull CommandLine commandLine) { final String configDir = commandLine.getOptionValue(CONFIG_DIR_OPTION.getOpt()); final Properties dynamicProperties = commandLine.getOptionProperties(DYNAMIC_PROPERTY_OPTION.getOpt()); final String restPortStr = commandLine.getOptionValue(REST_PORT_OPTION.getOpt(), "-1"); final int restPort = Integer.parseInt(restPortStr); final String hostname = commandLine.getOptionValue(HOST_OPTION.getOpt()); return new EntrypointClusterConfiguration( configDir, dynamicProperties, commandLine.getArgs(), hostname, restPort); }
Example 17
Source File: ClusterConfigurationParserFactory.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public ClusterConfiguration createResult(@Nonnull CommandLine commandLine) { final String configDir = commandLine.getOptionValue(CONFIG_DIR_OPTION.getOpt()); final Properties dynamicProperties = commandLine.getOptionProperties(DYNAMIC_PROPERTY_OPTION.getOpt()); return new ClusterConfiguration(configDir, dynamicProperties, commandLine.getArgs()); }
Example 18
Source File: SchedulerMain.java From incubator-heron with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws Exception { // construct the options and help options first. Options options = constructOptions(); Options helpOptions = constructHelpOptions(); // parse the options CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(helpOptions, args, true); // print help, if we receive wrong set of arguments if (cmd.hasOption("h")) { usage(options); return; } // Now parse the required options try { cmd = parser.parse(options, args); } catch (ParseException e) { usage(options); throw new RuntimeException("Error parsing command line options: ", e); } // It returns a new empty Properties instead of null, // if no properties passed from command line. So no need for null check. Properties schedulerProperties = cmd.getOptionProperties(SchedulerUtils.SCHEDULER_COMMAND_LINE_PROPERTIES_OVERRIDE_OPTION); // initialize the scheduler with the options String topologyName = cmd.getOptionValue("topology_name"); SchedulerMain schedulerMain = createInstance(cmd.getOptionValue("cluster"), cmd.getOptionValue("role"), cmd.getOptionValue("environment"), cmd.getOptionValue("topology_bin"), topologyName, Integer.parseInt(cmd.getOptionValue("http_port")), cmd.hasOption("verbose"), schedulerProperties); LOG.info("Scheduler command line properties override: " + schedulerProperties.toString()); // run the scheduler boolean ret = schedulerMain.runScheduler(); // Log the result and exit if (!ret) { throw new RuntimeException("Failed to schedule topology: " + topologyName); } else { // stop the server and close the state manager LOG.log(Level.INFO, "Shutting down topology: {0}", topologyName); } }
Example 19
Source File: Application.java From hypergraphql with Apache License 2.0 | 4 votes |
public static void main(final String[] args) throws Exception { final String[] trimmedArgs = trimValues(args); final Options options = buildOptions(); final CommandLineParser parser = new DefaultParser(); final CommandLine commandLine; try { commandLine = parser.parse(options, trimmedArgs); } catch (ParseException e) { throw new HGQLConfigurationException("Unable to parse command line", e); } final ApplicationConfigurationService service = new ApplicationConfigurationService(); final List<HGQLConfig> configurations; final boolean showBanner = !commandLine.hasOption("nobanner"); if(commandLine.hasOption("config") || commandLine.hasOption("s3")) { configurations = getConfigurationFromArgs(service, commandLine); } else { final Map<String, String> properties; if(commandLine.hasOption("D")) { final Properties props = commandLine.getOptionProperties("D"); properties = new HashMap<>(); props.forEach((k, v) -> properties.put((String)k, (String)v)); } else { properties = System.getenv(); } configurations = getConfigurationsFromProperties(properties, service); } if(configurations.size() == 0) { System.err.println("No configurations loaded, exiting"); return; } start(configurations, showBanner); }
Example 20
Source File: Main.java From swift-t with Apache License 2.0 | 4 votes |
private static Args processArgs(String[] args) { Options opts = initOptions(); CommandLine cmd = null; try { CommandLineParser parser = new GnuParser(); cmd = parser.parse(opts, args); } catch (ParseException ex) { // Use Apache CLI-provided messages System.err.println(ex.getMessage()); usage(opts); System.exit(1); return null; } if (cmd.hasOption(INCLUDE_FLAG)) { for (String dir: cmd.getOptionValues(INCLUDE_FLAG)) { Settings.addModulePath(dir); } } Properties swiftProgramArgs = cmd.getOptionProperties(SWIFT_PROG_ARG_FLAG); String preprocMacros[]; if (cmd.hasOption(PREPROC_MACRO_FLAG)) { preprocMacros = cmd.getOptionValues(PREPROC_MACRO_FLAG); } else { preprocMacros = new String[0]; } String[] remainingArgs = cmd.getArgs(); if (remainingArgs.length < 1 || remainingArgs.length > 2) { System.out.println("Expected input file and optional output file, but got " + remainingArgs.length + " arguments"); usage(opts); System.exit(ExitCode.ERROR_COMMAND.code()); } String input = remainingArgs[0]; String output = null; if (remainingArgs.length == 2) { output = remainingArgs[1]; } Args result = new Args(input, output, swiftProgramArgs, Arrays.asList(preprocMacros)); recordArgValues(result); return result; }