Search in sources :

Example 1 with FlinkParseException

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);
}
Also used : Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) FlinkParseException(org.apache.flink.runtime.entrypoint.FlinkParseException) ParseException(org.apache.commons.cli.ParseException) FlinkParseException(org.apache.flink.runtime.entrypoint.FlinkParseException) DefaultParser(org.apache.commons.cli.DefaultParser)

Example 2 with FlinkParseException

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);
}
Also used : FlinkParseException(org.apache.flink.runtime.entrypoint.FlinkParseException) Configuration(org.apache.flink.configuration.Configuration) ClusterConfiguration(org.apache.flink.runtime.entrypoint.ClusterConfiguration) GlobalConfiguration(org.apache.flink.configuration.GlobalConfiguration) ClusterConfigurationParserFactory(org.apache.flink.runtime.entrypoint.ClusterConfigurationParserFactory) ClusterConfiguration(org.apache.flink.runtime.entrypoint.ClusterConfiguration) CommandLineParser(org.apache.flink.runtime.entrypoint.parser.CommandLineParser)

Example 3 with FlinkParseException

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));
    }
}
Also used : FlinkParseException(org.apache.flink.runtime.entrypoint.FlinkParseException) Optional(java.util.Optional) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 4 with FlinkParseException

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));
}
Also used : SecurityConfiguration(org.apache.flink.runtime.security.SecurityConfiguration) MetricRegistryConfiguration(org.apache.flink.runtime.metrics.MetricRegistryConfiguration) Configuration(org.apache.flink.configuration.Configuration) FlinkParseException(org.apache.flink.runtime.entrypoint.FlinkParseException)

Aggregations

FlinkParseException (org.apache.flink.runtime.entrypoint.FlinkParseException)4 Configuration (org.apache.flink.configuration.Configuration)2 Optional (java.util.Optional)1 CommandLine (org.apache.commons.cli.CommandLine)1 DefaultParser (org.apache.commons.cli.DefaultParser)1 Options (org.apache.commons.cli.Options)1 ParseException (org.apache.commons.cli.ParseException)1 GlobalConfiguration (org.apache.flink.configuration.GlobalConfiguration)1 ClusterConfiguration (org.apache.flink.runtime.entrypoint.ClusterConfiguration)1 ClusterConfigurationParserFactory (org.apache.flink.runtime.entrypoint.ClusterConfigurationParserFactory)1 CommandLineParser (org.apache.flink.runtime.entrypoint.parser.CommandLineParser)1 MetricRegistryConfiguration (org.apache.flink.runtime.metrics.MetricRegistryConfiguration)1 SecurityConfiguration (org.apache.flink.runtime.security.SecurityConfiguration)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Test (org.junit.Test)1