Java Code Examples for org.apache.flink.client.cli.CliFrontendParser#parse()

The following examples show how to use org.apache.flink.client.cli.CliFrontendParser#parse() . 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: 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);
}
 
Example 2
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 3
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);
}