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

The following examples show how to use org.apache.flink.client.cli.CliArgsException. 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: FlinkYarnSessionCli.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
public static void main(final String[] args) {
	final String configurationDirectory = CliFrontend.getConfigurationDirectoryFromEnv();

	final Configuration flinkConfiguration = GlobalConfiguration.loadConfiguration();

	int retCode;

	try {
		final FlinkYarnSessionCli cli = new FlinkYarnSessionCli(
			flinkConfiguration,
			configurationDirectory,
			"",
			""); // no prefix for the YARN session

		SecurityUtils.install(new SecurityConfiguration(flinkConfiguration));

		retCode = SecurityUtils.getInstalledContext().runSecured(() -> cli.run(args));
	} catch (CliArgsException e) {
		retCode = handleCliArgsException(e);
	} catch (Throwable t) {
		final Throwable strippedThrowable = ExceptionUtils.stripException(t, UndeclaredThrowableException.class);
		retCode = handleError(strippedThrowable);
	}

	System.exit(retCode);
}
 
Example #2
Source File: FlinkYarnSessionCli.java    From flink with Apache License 2.0 6 votes vote down vote up
public static void main(final String[] args) {
	final String configurationDirectory = CliFrontend.getConfigurationDirectoryFromEnv();

	final Configuration flinkConfiguration = GlobalConfiguration.loadConfiguration();

	int retCode;

	try {
		final FlinkYarnSessionCli cli = new FlinkYarnSessionCli(
			flinkConfiguration,
			configurationDirectory,
			"",
			""); // no prefix for the YARN session

		SecurityUtils.install(new SecurityConfiguration(flinkConfiguration));

		retCode = SecurityUtils.getInstalledContext().runSecured(() -> cli.run(args));
	} catch (CliArgsException e) {
		retCode = handleCliArgsException(e);
	} catch (Throwable t) {
		final Throwable strippedThrowable = ExceptionUtils.stripException(t, UndeclaredThrowableException.class);
		retCode = handleError(strippedThrowable);
	}

	System.exit(retCode);
}
 
Example #3
Source File: FlinkYarnSessionCli.java    From flink with Apache License 2.0 6 votes vote down vote up
public static void main(final String[] args) {
	final String configurationDirectory = CliFrontend.getConfigurationDirectoryFromEnv();

	final Configuration flinkConfiguration = GlobalConfiguration.loadConfiguration();

	int retCode;

	try {
		final FlinkYarnSessionCli cli = new FlinkYarnSessionCli(
			flinkConfiguration,
			configurationDirectory,
			"",
			""); // no prefix for the YARN session

		SecurityUtils.install(new SecurityConfiguration(flinkConfiguration));

		retCode = SecurityUtils.getInstalledContext().runSecured(() -> cli.run(args));
	} catch (CliArgsException e) {
		retCode = handleCliArgsException(e, LOG);
	} catch (Throwable t) {
		final Throwable strippedThrowable = ExceptionUtils.stripException(t, UndeclaredThrowableException.class);
		retCode = handleError(strippedThrowable, LOG);
	}

	System.exit(retCode);
}
 
Example #4
Source File: ExecutionContext.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private static RunOptions createRunOptions(CommandLine commandLine) {
	try {
		return new RunOptions(commandLine);
	} catch (CliArgsException e) {
		throw new SqlExecutionException("Invalid deployment run options.", e);
	}
}
 
Example #5
Source File: FlinkYarnSessionCli.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private static int handleCliArgsException(CliArgsException e) {
	LOG.error("Could not parse the command line arguments.", e);

	System.out.println(e.getMessage());
	System.out.println();
	System.out.println("Use the help option (-h or --help) to get help on the command.");
	return 1;
}
 
Example #6
Source File: ExecutionContext.java    From flink with Apache License 2.0 5 votes vote down vote up
private static RunOptions createRunOptions(CommandLine commandLine) {
	try {
		return new RunOptions(commandLine);
	} catch (CliArgsException e) {
		throw new SqlExecutionException("Invalid deployment run options.", e);
	}
}
 
Example #7
Source File: FlinkYarnSessionCli.java    From flink with Apache License 2.0 5 votes vote down vote up
private static int handleCliArgsException(CliArgsException e) {
	LOG.error("Could not parse the command line arguments.", e);

	System.out.println(e.getMessage());
	System.out.println();
	System.out.println("Use the help option (-h or --help) to get help on the command.");
	return 1;
}
 
Example #8
Source File: ExecutionContext.java    From flink with Apache License 2.0 5 votes vote down vote up
private static Configuration createExecutionConfig(
		CommandLine commandLine,
		Options commandLineOptions,
		List<CustomCommandLine> availableCommandLines,
		List<URL> dependencies) throws FlinkException {
	LOG.debug("Available commandline options: {}", commandLineOptions);
	List<String> options = Stream
			.of(commandLine.getOptions())
			.map(o -> o.getOpt() + "=" + o.getValue())
			.collect(Collectors.toList());
	LOG.debug(
			"Instantiated commandline args: {}, options: {}",
			commandLine.getArgList(),
			options);

	final CustomCommandLine activeCommandLine = findActiveCommandLine(
			availableCommandLines,
			commandLine);
	LOG.debug(
			"Available commandlines: {}, active commandline: {}",
			availableCommandLines,
			activeCommandLine);

	Configuration executionConfig = activeCommandLine.applyCommandLineOptionsToConfiguration(
			commandLine);

	try {
		final ProgramOptions programOptions = ProgramOptions.create(commandLine);
		final ExecutionConfigAccessor executionConfigAccessor = ExecutionConfigAccessor.fromProgramOptions(programOptions, dependencies);
		executionConfigAccessor.applyToConfiguration(executionConfig);
	} catch (CliArgsException e) {
		throw new SqlExecutionException("Invalid deployment run options.", e);
	}

	LOG.info("Executor config: {}", executionConfig);
	return executionConfig;
}
 
Example #9
Source File: KubernetesSessionCliTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testKubernetesSessionCliSetsDeploymentTargetCorrectly() throws CliArgsException {
	final KubernetesSessionCli cli = new KubernetesSessionCli(
			new Configuration(),
			tmp.getRoot().getAbsolutePath());

	final String[] args = {};
	final Configuration configuration = cli.getEffectiveConfiguration(args);

	assertEquals(KubernetesSessionClusterExecutor.NAME, configuration.get(DeploymentOptions.TARGET));
}
 
Example #10
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 #11
Source File: KubernetesSessionCli.java    From flink with Apache License 2.0 4 votes vote down vote up
public Configuration getEffectiveConfiguration(String[] args) throws CliArgsException {
	final CommandLine commandLine = cli.parseCommandLineOptions(args, true);
	final Configuration effectiveConfiguration = cli.applyCommandLineOptionsToConfiguration(commandLine);
	effectiveConfiguration.set(DeploymentOptions.TARGET, KubernetesSessionClusterExecutor.NAME);
	return effectiveConfiguration;
}
 
Example #12
Source File: FlinkYarnSessionCliTest.java    From flink with Apache License 2.0 4 votes vote down vote up
private void validateYarnCLIisActive(Configuration configuration) throws FlinkException, CliArgsException {
	final FlinkYarnSessionCli flinkYarnSessionCli = createFlinkYarnSessionCli(configuration);
	final CommandLine testCLIArgs = flinkYarnSessionCli.parseCommandLineOptions(new String[] {}, true);
	assertTrue(flinkYarnSessionCli.isActive(testCLIArgs));
}