org.apache.flink.client.cli.CliFrontendParser Java Examples

The following examples show how to use org.apache.flink.client.cli.CliFrontendParser. 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: StandaloneApplicationClusterConfigurationParserFactory.java    From flink with Apache License 2.0 6 votes vote down vote up
@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 #2
Source File: StandaloneJobClusterConfigurationParserFactory.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@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: StandaloneJobClusterConfigurationParserFactory.java    From flink with Apache License 2.0 6 votes vote down vote up
@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 #4
Source File: StatefulFunctionsClusterConfigurationParserFactory.java    From flink-statefun with Apache License 2.0 6 votes vote down vote up
@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: StatefulFunctionsClusterConfigurationParserFactory.java    From stateful-functions with Apache License 2.0 6 votes vote down vote up
@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 #6
Source File: StatefulFunctionsClusterConfigurationParserFactory.java    From stateful-functions with Apache License 2.0 5 votes vote down vote up
@Override
public Options getOptions() {
  final Options options = new Options();
  options.addOption(CONFIG_DIR_OPTION);
  options.addOption(REST_PORT_OPTION);
  options.addOption(JOB_ID_OPTION);
  options.addOption(DYNAMIC_PROPERTY_OPTION);
  options.addOption(CliFrontendParser.SAVEPOINT_PATH_OPTION);
  options.addOption(CliFrontendParser.SAVEPOINT_ALLOW_NON_RESTORED_OPTION);

  return options;
}
 
Example #7
Source File: FlinkYarnSessionCliTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private void validateExecutorCLIisPrioritised(Configuration configuration, String[] argsUnderTest) throws IOException, CliArgsException {
	final List<CustomCommandLine> customCommandLines = CliFrontend.loadCustomCommandLines(
			configuration,
			tmp.newFile().getAbsolutePath());

	final CliFrontend cli = new CliFrontend(configuration, customCommandLines);
	final CommandLine commandLine = cli.getCommandLine(
			CliFrontendParser.getRunCommandOptions(),
			argsUnderTest,
			true);

	final CustomCommandLine customCommandLine = cli.validateAndGetActiveCommandLine(commandLine);
	assertTrue(customCommandLine instanceof GenericCLI);
}
 
Example #8
Source File: StandaloneApplicationClusterConfigurationParserFactory.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Options getOptions() {
	final Options options = new Options();
	options.addOption(CONFIG_DIR_OPTION);
	options.addOption(REST_PORT_OPTION);
	options.addOption(JOB_CLASS_NAME_OPTION);
	options.addOption(JOB_ID_OPTION);
	options.addOption(DYNAMIC_PROPERTY_OPTION);
	options.addOption(HOST_OPTION);
	options.addOption(CliFrontendParser.SAVEPOINT_PATH_OPTION);
	options.addOption(CliFrontendParser.SAVEPOINT_ALLOW_NON_RESTORED_OPTION);

	return options;
}
 
Example #9
Source File: DeploymentEntry.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Parses the given command line options from the deployment properties. Ignores properties
 * that are not defined by options.
 */
public CommandLine getCommandLine(Options commandLineOptions) throws Exception {
	final List<String> args = new ArrayList<>();

	properties.asMap().forEach((k, v) -> {
		// only add supported options
		if (commandLineOptions.hasOption(k)) {
			final Option o = commandLineOptions.getOption(k);
			final String argument = "--" + o.getLongOpt();
			// options without args
			if (!o.hasArg()) {
				final Boolean flag = Boolean.parseBoolean(v);
				// add key only
				if (flag) {
					args.add(argument);
				}
			}
			// add key and value
			else if (!o.hasArgs()) {
				args.add(argument);
				args.add(v);
			}
			// options with multiple args are not supported yet
			else {
				throw new IllegalArgumentException("Option '" + o + "' is not supported yet.");
			}
		}
	});

	return CliFrontendParser.parse(commandLineOptions, args.toArray(new String[args.size()]), true);
}
 
Example #10
Source File: LocalExecutor.java    From flink with Apache License 2.0 5 votes vote down vote up
private static Options collectCommandLineOptions(List<CustomCommandLine> commandLines) {
	final Options customOptions = new Options();
	for (CustomCommandLine customCommandLine : commandLines) {
		customCommandLine.addGeneralOptions(customOptions);
		customCommandLine.addRunOptions(customOptions);
	}
	return CliFrontendParser.mergeOptions(
		CliFrontendParser.getRunCommandOptions(),
		customOptions);
}
 
Example #11
Source File: StatefulFunctionsClusterConfigurationParserFactory.java    From flink-statefun with Apache License 2.0 5 votes vote down vote up
@Override
public Options getOptions() {
  final Options options = new Options();
  options.addOption(CONFIG_DIR_OPTION);
  options.addOption(REST_PORT_OPTION);
  options.addOption(JOB_ID_OPTION);
  options.addOption(DYNAMIC_PROPERTY_OPTION);
  options.addOption(PARALLELISM_OPTION);
  options.addOption(CliFrontendParser.SAVEPOINT_PATH_OPTION);
  options.addOption(CliFrontendParser.SAVEPOINT_ALLOW_NON_RESTORED_OPTION);

  return options;
}
 
Example #12
Source File: LocalExecutor.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private static Options collectCommandLineOptions(List<CustomCommandLine<?>> commandLines) {
	final Options customOptions = new Options();
	for (CustomCommandLine<?> customCommandLine : commandLines) {
		customCommandLine.addRunOptions(customOptions);
	}
	return CliFrontendParser.mergeOptions(
		CliFrontendParser.getRunCommandOptions(),
		customOptions);
}
 
Example #13
Source File: StandaloneJobClusterConfigurationParserFactory.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Options getOptions() {
	final Options options = new Options();
	options.addOption(CONFIG_DIR_OPTION);
	options.addOption(REST_PORT_OPTION);
	options.addOption(JOB_CLASS_NAME_OPTION);
	options.addOption(JOB_ID_OPTION);
	options.addOption(DYNAMIC_PROPERTY_OPTION);
	options.addOption(CliFrontendParser.SAVEPOINT_PATH_OPTION);
	options.addOption(CliFrontendParser.SAVEPOINT_ALLOW_NON_RESTORED_OPTION);

	return options;
}
 
Example #14
Source File: DeploymentEntry.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Parses the given command line options from the deployment properties. Ignores properties
 * that are not defined by options.
 */
public CommandLine getCommandLine(Options commandLineOptions) throws Exception {
	final List<String> args = new ArrayList<>();

	properties.asMap().forEach((k, v) -> {
		// only add supported options
		if (commandLineOptions.hasOption(k)) {
			final Option o = commandLineOptions.getOption(k);
			final String argument = "--" + o.getLongOpt();
			// options without args
			if (!o.hasArg()) {
				final Boolean flag = Boolean.parseBoolean(v);
				// add key only
				if (flag) {
					args.add(argument);
				}
			}
			// add key and value
			else if (!o.hasArgs()) {
				args.add(argument);
				args.add(v);
			}
			// options with multiple args are not supported yet
			else {
				throw new IllegalArgumentException("Option '" + o + "' is not supported yet.");
			}
		}
	});

	return CliFrontendParser.parse(commandLineOptions, args.toArray(new String[args.size()]), true);
}
 
Example #15
Source File: LocalExecutor.java    From flink with Apache License 2.0 5 votes vote down vote up
private static Options collectCommandLineOptions(List<CustomCommandLine<?>> commandLines) {
	final Options customOptions = new Options();
	for (CustomCommandLine<?> customCommandLine : commandLines) {
		customCommandLine.addRunOptions(customOptions);
	}
	return CliFrontendParser.mergeOptions(
		CliFrontendParser.getRunCommandOptions(),
		customOptions);
}
 
Example #16
Source File: StandaloneJobClusterConfigurationParserFactory.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public Options getOptions() {
	final Options options = new Options();
	options.addOption(CONFIG_DIR_OPTION);
	options.addOption(REST_PORT_OPTION);
	options.addOption(JOB_CLASS_NAME_OPTION);
	options.addOption(JOB_ID_OPTION);
	options.addOption(DYNAMIC_PROPERTY_OPTION);
	options.addOption(CliFrontendParser.SAVEPOINT_PATH_OPTION);
	options.addOption(CliFrontendParser.SAVEPOINT_ALLOW_NON_RESTORED_OPTION);

	return options;
}
 
Example #17
Source File: DeploymentEntry.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Parses the given command line options from the deployment properties. Ignores properties
 * that are not defined by options.
 */
public CommandLine getCommandLine(Options commandLineOptions) throws Exception {
	final List<String> args = new ArrayList<>();

	properties.asMap().forEach((k, v) -> {
		// only add supported options
		if (commandLineOptions.hasOption(k)) {
			final Option o = commandLineOptions.getOption(k);
			final String argument = "--" + o.getLongOpt();
			// options without args
			if (!o.hasArg()) {
				final Boolean flag = Boolean.parseBoolean(v);
				// add key only
				if (flag) {
					args.add(argument);
				}
			}
			// add key and value
			else if (!o.hasArgs()) {
				args.add(argument);
				args.add(v);
			}
			// options with multiple args are not supported yet
			else {
				throw new IllegalArgumentException("Option '" + o + "' is not supported yet.");
			}
		}
	});

	return CliFrontendParser.parse(commandLineOptions, args.toArray(new String[args.size()]), true);
}