use of org.apache.flink.runtime.entrypoint.FlinkParseException in project flink by apache.
the class CommandLineParser method parse.
public T parse(@Nonnull String[] args) throws FlinkParseException {
final DefaultParser parser = new DefaultParser();
final Options options = parserResultFactory.getOptions();
final CommandLine commandLine;
try {
commandLine = parser.parse(options, args, true);
} catch (ParseException e) {
throw new FlinkParseException("Failed to parse the command line arguments.", e);
}
return parserResultFactory.createResult(commandLine);
}
use of org.apache.flink.runtime.entrypoint.FlinkParseException in project flink by apache.
the class ConfigurationParserUtils method loadCommonConfiguration.
/**
* Generate configuration from only the config file and dynamic properties.
*
* @param args the commandline arguments
* @param cmdLineSyntax the syntax for this application
* @return generated configuration
* @throws FlinkParseException if the configuration cannot be generated
*/
public static Configuration loadCommonConfiguration(String[] args, String cmdLineSyntax) throws FlinkParseException {
final CommandLineParser<ClusterConfiguration> commandLineParser = new CommandLineParser<>(new ClusterConfigurationParserFactory());
final ClusterConfiguration clusterConfiguration;
try {
clusterConfiguration = commandLineParser.parse(args);
} catch (FlinkParseException e) {
LOG.error("Could not parse the command line options.", e);
commandLineParser.printHelp(cmdLineSyntax);
throw e;
}
final Configuration dynamicProperties = ConfigurationUtils.createConfiguration(clusterConfiguration.getDynamicProperties());
return GlobalConfiguration.loadConfiguration(clusterConfiguration.getConfigDir(), dynamicProperties);
}
use of org.apache.flink.runtime.entrypoint.FlinkParseException in project flink by apache.
the class StandaloneApplicationClusterConfigurationParserFactoryTest method testInvalidJobIdThrows.
@Test
public void testInvalidJobIdThrows() {
final String invalidJobId = "0xINVALID";
final String[] args = { "--configDir", confDirPath, "--job-classname", "foobar", "--job-id", invalidJobId };
try {
commandLineParser.parse(args);
fail("Did not throw expected FlinkParseException");
} catch (FlinkParseException e) {
Optional<IllegalArgumentException> cause = ExceptionUtils.findThrowable(e, IllegalArgumentException.class);
assertTrue(cause.isPresent());
assertThat(cause.get().getMessage(), containsString(invalidJobId));
}
}
use of org.apache.flink.runtime.entrypoint.FlinkParseException in project flink by apache.
the class TaskManagerRunner method runTaskManagerProcessSecurely.
public static void runTaskManagerProcessSecurely(String[] args) {
Configuration configuration = null;
try {
configuration = loadConfiguration(args);
} catch (FlinkParseException fpe) {
LOG.error("Could not load the configuration.", fpe);
System.exit(FAILURE_EXIT_CODE);
}
runTaskManagerProcessSecurely(checkNotNull(configuration));
}
Aggregations