org.apache.flink.runtime.entrypoint.FlinkParseException Java Examples

The following examples show how to use org.apache.flink.runtime.entrypoint.FlinkParseException. 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: StandaloneApplicationClusterConfigurationParserFactoryTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testEntrypointClusterConfigWOSavepointSettingsToConfigurationParsing() throws FlinkParseException {
	final JobID jobID = JobID.generate();
	final String[] args = {
			"-c", confDirPath,
			"--job-id", jobID.toHexString()
	};

	final StandaloneApplicationClusterConfiguration clusterConfiguration = commandLineParser.parse(args);
	final Configuration configuration = StandaloneApplicationClusterEntryPoint
			.loadConfigurationFromClusterConfig(clusterConfiguration);

	final String strJobId = configuration.get(PipelineOptionsInternal.PIPELINE_FIXED_JOB_ID);
	assertThat(JobID.fromHexString(strJobId), is(equalTo(jobID)));
	assertThat(SavepointRestoreSettings.fromConfiguration(configuration), is(equalTo(SavepointRestoreSettings.none())));
}
 
Example #2
Source File: StandaloneApplicationClusterConfigurationParserFactoryTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testShortOptions() throws FlinkParseException {
	final String jobClassName = "foobar";
	final JobID jobId = new JobID();
	final String savepointRestorePath = "s3://foo/bar";

	final String[] args = {
		"-c", confDirPath,
		"-j", jobClassName,
		"-jid", jobId.toString(),
		"-s", savepointRestorePath,
		"-n"};

	final StandaloneApplicationClusterConfiguration clusterConfiguration = commandLineParser.parse(args);

	assertThat(clusterConfiguration.getConfigDir(), is(equalTo(confDirPath)));
	assertThat(clusterConfiguration.getJobClassName(), is(equalTo(jobClassName)));
	assertThat(clusterConfiguration.getJobId(), is(equalTo(jobId)));

	final SavepointRestoreSettings savepointRestoreSettings = clusterConfiguration.getSavepointRestoreSettings();
	assertThat(savepointRestoreSettings.restoreSavepoint(), is(true));
	assertThat(savepointRestoreSettings.getRestorePath(), is(equalTo(savepointRestorePath)));
	assertThat(savepointRestoreSettings.allowNonRestoredState(), is(true));
}
 
Example #3
Source File: StandaloneJobClusterConfigurationParserFactoryTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testEntrypointClusterConfigurationParsing() throws FlinkParseException {
	final String key = "key";
	final String value = "value";
	final int restPort = 1234;
	final String arg1 = "arg1";
	final String arg2 = "arg2";
	final String[] args = {"--configDir", confDirPath, "--webui-port", String.valueOf(restPort), "--job-classname", JOB_CLASS_NAME, String.format("-D%s=%s", key, value), arg1, arg2};

	final StandaloneJobClusterConfiguration clusterConfiguration = commandLineParser.parse(args);

	assertThat(clusterConfiguration.getConfigDir(), is(equalTo(confDirPath)));
	assertThat(clusterConfiguration.getJobClassName(), is(equalTo(JOB_CLASS_NAME)));
	assertThat(clusterConfiguration.getRestPort(), is(equalTo(restPort)));
	final Properties dynamicProperties = clusterConfiguration.getDynamicProperties();

	assertThat(dynamicProperties, hasEntry(key, value));

	assertThat(clusterConfiguration.getArgs(), arrayContaining(arg1, arg2));

	assertThat(clusterConfiguration.getSavepointRestoreSettings(), is(equalTo(SavepointRestoreSettings.none())));

	assertThat(clusterConfiguration.getJobId(), is(nullValue()));
}
 
Example #4
Source File: StandaloneJobClusterConfigurationParserFactoryTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testShortOptions() throws FlinkParseException {
	final String jobClassName = "foobar";
	final JobID jobId = new JobID();
	final String savepointRestorePath = "s3://foo/bar";

	final String[] args = {
		"-c", confDirPath,
		"-j", jobClassName,
		"-jid", jobId.toString(),
		"-s", savepointRestorePath,
		"-n"};

	final StandaloneJobClusterConfiguration clusterConfiguration = commandLineParser.parse(args);

	assertThat(clusterConfiguration.getConfigDir(), is(equalTo(confDirPath)));
	assertThat(clusterConfiguration.getJobClassName(), is(equalTo(jobClassName)));
	assertThat(clusterConfiguration.getJobId(), is(equalTo(jobId)));

	final SavepointRestoreSettings savepointRestoreSettings = clusterConfiguration.getSavepointRestoreSettings();
	assertThat(savepointRestoreSettings.restoreSavepoint(), is(true));
	assertThat(savepointRestoreSettings.getRestorePath(), is(equalTo(savepointRestorePath)));
	assertThat(savepointRestoreSettings.allowNonRestoredState(), is(true));
}
 
Example #5
Source File: ConfigurationParserUtils.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #6
Source File: TaskManagerRunner.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
static Configuration loadConfiguration(String[] args) 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(TaskManagerRunner.class.getSimpleName());
		throw e;
	}

	final Configuration dynamicProperties = ConfigurationUtils.createConfiguration(clusterConfiguration.getDynamicProperties());
	return GlobalConfiguration.loadConfiguration(clusterConfiguration.getConfigDir(), dynamicProperties);
}
 
Example #7
Source File: TaskManagerRunnerConfigurationTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testLoadDynamicalProperties() throws IOException, FlinkParseException {
	final File tmpDir = temporaryFolder.newFolder();
	final File confFile = new File(tmpDir, GlobalConfiguration.FLINK_CONF_FILENAME);
	final PrintWriter pw1 = new PrintWriter(confFile);
	final long managedMemory = 1024 * 1024 * 256;
	pw1.println(JobManagerOptions.ADDRESS.key() + ": localhost");
	pw1.println(TaskManagerOptions.MANAGED_MEMORY_SIZE.key() + ": " + managedMemory + "b");
	pw1.close();

	final String jmHost = "host1";
	final int jmPort = 12345;
	String[] args = new String[] {
		"--configDir", tmpDir.toString(),
		"-D" + JobManagerOptions.ADDRESS.key() + "=" + jmHost,
		"-D" + JobManagerOptions.PORT.key() + "=" + jmPort
	};
	Configuration configuration = TaskManagerRunner.loadConfiguration(args);
	assertEquals(MemorySize.parse(managedMemory + "b"), configuration.get(TaskManagerOptions.MANAGED_MEMORY_SIZE));
	assertEquals(jmHost, configuration.get(JobManagerOptions.ADDRESS));
	assertEquals(jmPort, configuration.getInteger(JobManagerOptions.PORT));
}
 
Example #8
Source File: StandaloneApplicationClusterConfigurationParserFactoryTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testEntrypointClusterConfigurationParsing() throws FlinkParseException {
	final String key = "key";
	final String value = "value";
	final int restPort = 1234;
	final String arg1 = "arg1";
	final String arg2 = "arg2";
	final String[] args = {"--configDir", confDirPath, "--webui-port", String.valueOf(restPort), "--job-classname", JOB_CLASS_NAME, String.format("-D%s=%s", key, value), arg1, arg2};

	final StandaloneApplicationClusterConfiguration clusterConfiguration = commandLineParser.parse(args);

	assertThat(clusterConfiguration.getConfigDir(), is(equalTo(confDirPath)));
	assertThat(clusterConfiguration.getJobClassName(), is(equalTo(JOB_CLASS_NAME)));
	assertThat(clusterConfiguration.getRestPort(), is(equalTo(restPort)));
	final Properties dynamicProperties = clusterConfiguration.getDynamicProperties();

	assertThat(dynamicProperties, hasEntry(key, value));

	assertThat(clusterConfiguration.getArgs(), arrayContaining(arg1, arg2));

	assertThat(clusterConfiguration.getSavepointRestoreSettings(), is(equalTo(SavepointRestoreSettings.none())));

	assertThat(clusterConfiguration.getJobId(), is(nullValue()));
}
 
Example #9
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 #10
Source File: PythonDriverOptionsParserFactory.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public PythonDriverOptions createResult(@Nonnull CommandLine commandLine) throws FlinkParseException {
	String entryPointModule = null;
	String entryPointScript = null;

	if (commandLine.hasOption(PY_OPTION.getOpt()) && commandLine.hasOption(PYMODULE_OPTION.getOpt())) {
		throw new FlinkParseException("Cannot use options -py and -pym simultaneously.");
	} else if (commandLine.hasOption(PY_OPTION.getOpt())) {
		entryPointScript = commandLine.getOptionValue(PY_OPTION.getOpt());
	} else if (commandLine.hasOption(PYMODULE_OPTION.getOpt())) {
		entryPointModule = commandLine.getOptionValue(PYMODULE_OPTION.getOpt());
	} else {
		throw new FlinkParseException(
			"The Python entry point has not been specified. It can be specified with options -py or -pym");
	}

	return new PythonDriverOptions(
		entryPointModule,
		entryPointScript,
		commandLine.getArgList());
}
 
Example #11
Source File: PythonDriverOptionsParserFactoryTest.java    From flink with Apache License 2.0 6 votes vote down vote up
private void verifyPythonDriverOptionsParsing(final String[] args) throws FlinkParseException {
	final PythonDriverOptions pythonCommandOptions = commandLineParser.parse(args);

	// verify the parsed python entrypoint module
	assertEquals("xxx", pythonCommandOptions.getEntrypointModule());

	// verify the parsed python library files
	final List<Path> pythonMainFile = pythonCommandOptions.getPythonLibFiles();
	assertNotNull(pythonMainFile);
	assertEquals(4, pythonMainFile.size());
	assertEquals(
		pythonMainFile.stream().map(Path::getName).collect(Collectors.joining(",")),
		"xxx.py,a.py,b.py,c.py");

	// verify the python program arguments
	final List<String> programArgs = pythonCommandOptions.getProgramArgs();
	assertEquals(2, programArgs.size());
	assertEquals("--input", programArgs.get(0));
	assertEquals("in.txt", programArgs.get(1));
}
 
Example #12
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 #13
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 #14
Source File: StandaloneJobClusterConfigurationParserFactoryTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testEntrypointClusterConfigurationParsing() throws FlinkParseException {
	final String key = "key";
	final String value = "value";
	final int restPort = 1234;
	final String arg1 = "arg1";
	final String arg2 = "arg2";
	final String[] args = {"--configDir", confDirPath, "--webui-port", String.valueOf(restPort), "--job-classname", JOB_CLASS_NAME, String.format("-D%s=%s", key, value), arg1, arg2};

	final StandaloneJobClusterConfiguration clusterConfiguration = commandLineParser.parse(args);

	assertThat(clusterConfiguration.getConfigDir(), is(equalTo(confDirPath)));
	assertThat(clusterConfiguration.getJobClassName(), is(equalTo(JOB_CLASS_NAME)));
	assertThat(clusterConfiguration.getRestPort(), is(equalTo(restPort)));
	final Properties dynamicProperties = clusterConfiguration.getDynamicProperties();

	assertThat(dynamicProperties, hasEntry(key, value));

	assertThat(clusterConfiguration.getArgs(), arrayContaining(arg1, arg2));

	assertThat(clusterConfiguration.getSavepointRestoreSettings(), is(equalTo(SavepointRestoreSettings.none())));

	assertThat(clusterConfiguration.getJobId(), is(nullValue()));
}
 
Example #15
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 #16
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 #17
Source File: StandaloneJobClusterConfigurationParserFactoryTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testShortOptions() throws FlinkParseException {
	final String jobClassName = "foobar";
	final JobID jobId = new JobID();
	final String savepointRestorePath = "s3://foo/bar";

	final String[] args = {
		"-c", confDirPath,
		"-j", jobClassName,
		"-jid", jobId.toString(),
		"-s", savepointRestorePath,
		"-n"};

	final StandaloneJobClusterConfiguration clusterConfiguration = commandLineParser.parse(args);

	assertThat(clusterConfiguration.getConfigDir(), is(equalTo(confDirPath)));
	assertThat(clusterConfiguration.getJobClassName(), is(equalTo(jobClassName)));
	assertThat(clusterConfiguration.getJobId(), is(equalTo(jobId)));

	final SavepointRestoreSettings savepointRestoreSettings = clusterConfiguration.getSavepointRestoreSettings();
	assertThat(savepointRestoreSettings.restoreSavepoint(), is(true));
	assertThat(savepointRestoreSettings.getRestorePath(), is(equalTo(savepointRestorePath)));
	assertThat(savepointRestoreSettings.allowNonRestoredState(), is(true));
}
 
Example #18
Source File: TaskManagerRunner.java    From flink with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
static Configuration loadConfiguration(String[] args) 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(TaskManagerRunner.class.getSimpleName());
		throw e;
	}

	final Configuration dynamicProperties = ConfigurationUtils.createConfiguration(clusterConfiguration.getDynamicProperties());
	return GlobalConfiguration.loadConfiguration(clusterConfiguration.getConfigDir(), dynamicProperties);
}
 
Example #19
Source File: StandaloneApplicationClusterConfigurationParserFactoryTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testEntrypointClusterConfigurationToConfigurationParsing() throws FlinkParseException {
	final JobID jobID = JobID.generate();
	final SavepointRestoreSettings savepointRestoreSettings = SavepointRestoreSettings.forPath("/test/savepoint/path", true);
	final String key = DeploymentOptions.TARGET.key();
	final String value = "testDynamicExecutorConfig";
	final int restPort = 1234;
	final String arg1 = "arg1";
	final String arg2 = "arg2";
	final String[] args = {
			"--configDir", confDirPath,
			"--job-id", jobID.toHexString(),
			"--fromSavepoint", savepointRestoreSettings.getRestorePath(),
			"--allowNonRestoredState",
			"--webui-port", String.valueOf(restPort),
			"--job-classname", JOB_CLASS_NAME,
			String.format("-D%s=%s", key, value),
			arg1, arg2};

	final StandaloneApplicationClusterConfiguration clusterConfiguration = commandLineParser.parse(args);
	assertThat(clusterConfiguration.getJobClassName(), is(equalTo(JOB_CLASS_NAME)));
	assertThat(clusterConfiguration.getArgs(), arrayContaining(arg1, arg2));

	final Configuration configuration = StandaloneApplicationClusterEntryPoint
			.loadConfigurationFromClusterConfig(clusterConfiguration);

	final String strJobId = configuration.get(PipelineOptionsInternal.PIPELINE_FIXED_JOB_ID);
	assertThat(JobID.fromHexString(strJobId), is(equalTo(jobID)));
	assertThat(SavepointRestoreSettings.fromConfiguration(configuration), is(equalTo(savepointRestoreSettings)));

	assertThat(configuration.get(RestOptions.PORT), is(equalTo(restPort)));
	assertThat(configuration.get(DeploymentOptions.TARGET), is(equalTo(value)));
}
 
Example #20
Source File: StandaloneApplicationClusterConfigurationParserFactoryTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testSavepointRestoreSettingsParsing() throws FlinkParseException {
	final String restorePath = "foobar";
	final String[] args = {"-c", confDirPath, "-j", JOB_CLASS_NAME, "-s", restorePath, "-n"};
	final StandaloneApplicationClusterConfiguration standaloneApplicationClusterConfiguration = commandLineParser.parse(args);

	final SavepointRestoreSettings savepointRestoreSettings = standaloneApplicationClusterConfiguration.getSavepointRestoreSettings();

	assertThat(savepointRestoreSettings.restoreSavepoint(), is(true));
	assertThat(savepointRestoreSettings.getRestorePath(), is(equalTo(restorePath)));
	assertThat(savepointRestoreSettings.allowNonRestoredState(), is(true));
}
 
Example #21
Source File: StandaloneApplicationClusterConfigurationParserFactory.java    From flink with Apache License 2.0 5 votes vote down vote up
private int getRestPort(CommandLine commandLine) throws FlinkParseException {
	final String restPortString = commandLine.getOptionValue(REST_PORT_OPTION.getOpt(), "-1");
	try {
		return Integer.parseInt(restPortString);
	} catch (NumberFormatException e) {
		throw createFlinkParseException(REST_PORT_OPTION, e);
	}
}
 
Example #22
Source File: PythonDriverOptionsParserFactoryTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private void verifyPythonDriverOptionsParsing(final String[] args) throws FlinkParseException {
	final PythonDriverOptions pythonCommandOptions = commandLineParser.parse(args);

	if (pythonCommandOptions.getEntryPointScript().isPresent()){
		assertEquals("xxx.py", pythonCommandOptions.getEntryPointScript().get());
	} else {
		assertEquals("xxx", pythonCommandOptions.getEntryPointModule());
	}

	// verify the python program arguments
	final List<String> programArgs = pythonCommandOptions.getProgramArgs();
	assertEquals(2, programArgs.size());
	assertEquals("--input", programArgs.get(0));
	assertEquals("in.txt", programArgs.get(1));
}
 
Example #23
Source File: StandaloneApplicationClusterConfigurationParserFactory.java    From flink with Apache License 2.0 5 votes vote down vote up
@Nullable
private static JobID getJobId(CommandLine commandLine) throws FlinkParseException {
	String jobId = commandLine.getOptionValue(JOB_ID_OPTION.getOpt());
	if (jobId == null) {
		return null;
	}
	try {
		return JobID.fromHexString(jobId);
	} catch (IllegalArgumentException e) {
		throw createFlinkParseException(JOB_ID_OPTION, e);
	}
}
 
Example #24
Source File: StandaloneApplicationClusterConfigurationParserFactoryTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testHostOption() throws FlinkParseException {
	final String hostName = "user-specified-hostname";
	final String[] args = {"--configDir", confDirPath, "--job-classname", "foobar", "--host", hostName};
	final StandaloneApplicationClusterConfiguration applicationClusterConfiguration = commandLineParser.parse(args);
	assertThat(applicationClusterConfiguration.getHostname(), is(hostName));
}
 
Example #25
Source File: StatefulFunctionsClusterConfigurationParserFactory.java    From flink-statefun with Apache License 2.0 5 votes vote down vote up
@Nullable
private static JobID getJobId(CommandLine commandLine) throws FlinkParseException {
  String jobId = commandLine.getOptionValue(JOB_ID_OPTION.getOpt());
  if (jobId == null) {
    return null;
  }
  try {
    return JobID.fromHexString(jobId);
  } catch (IllegalArgumentException e) {
    throw createFlinkParseException(JOB_ID_OPTION, e);
  }
}
 
Example #26
Source File: StatefulFunctionsClusterConfigurationParserFactory.java    From stateful-functions with Apache License 2.0 5 votes vote down vote up
private int getRestPort(CommandLine commandLine) throws FlinkParseException {
  final String restPortString = commandLine.getOptionValue(REST_PORT_OPTION.getOpt(), "-1");
  try {
    return Integer.parseInt(restPortString);
  } catch (NumberFormatException e) {
    throw createFlinkParseException(REST_PORT_OPTION, e);
  }
}
 
Example #27
Source File: CommandLineParser.java    From flink with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #28
Source File: CommandLineParser.java    From flink with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #29
Source File: StandaloneApplicationClusterConfigurationParserFactoryTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testOnlyRequiredArguments() throws FlinkParseException {
	final String[] args = {"--configDir", confDirPath};

	final StandaloneApplicationClusterConfiguration clusterConfiguration = commandLineParser.parse(args);

	assertThat(clusterConfiguration.getConfigDir(), is(equalTo(confDirPath)));
	assertThat(clusterConfiguration.getDynamicProperties(), is(equalTo(new Properties())));
	assertThat(clusterConfiguration.getArgs(), is(new String[0]));
	assertThat(clusterConfiguration.getRestPort(), is(equalTo(-1)));
	assertThat(clusterConfiguration.getHostname(), is(nullValue()));
	assertThat(clusterConfiguration.getSavepointRestoreSettings(), is(equalTo(SavepointRestoreSettings.none())));
	assertThat(clusterConfiguration.getJobId(), is(nullValue()));
	assertThat(clusterConfiguration.getJobClassName(),  is(nullValue()));
}
 
Example #30
Source File: StatefulFunctionsClusterConfigurationParserFactory.java    From stateful-functions with Apache License 2.0 5 votes vote down vote up
@Nullable
private static JobID getJobId(CommandLine commandLine) throws FlinkParseException {
  String jobId = commandLine.getOptionValue(JOB_ID_OPTION.getOpt());
  if (jobId == null) {
    return null;
  }
  try {
    return JobID.fromHexString(jobId);
  } catch (IllegalArgumentException e) {
    throw createFlinkParseException(JOB_ID_OPTION, e);
  }
}