Java Code Examples for org.apache.flink.runtime.jobgraph.SavepointRestoreSettings#none()

The following examples show how to use org.apache.flink.runtime.jobgraph.SavepointRestoreSettings#none() . 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: ClassPathJobGraphRetrieverTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testJobGraphRetrieval() throws FlinkException {
	final int parallelism = 42;
	final Configuration configuration = new Configuration();
	configuration.setInteger(CoreOptions.DEFAULT_PARALLELISM, parallelism);
	final JobID jobId = new JobID();

	final ClassPathJobGraphRetriever classPathJobGraphRetriever = new ClassPathJobGraphRetriever(
		jobId,
		SavepointRestoreSettings.none(),
		PROGRAM_ARGUMENTS,
		TestJob.class.getCanonicalName());

	final JobGraph jobGraph = classPathJobGraphRetriever.retrieveJobGraph(configuration);

	assertThat(jobGraph.getName(), is(equalTo(TestJob.class.getCanonicalName() + "-suffix")));
	assertThat(jobGraph.getMaximumParallelism(), is(parallelism));
	assertEquals(jobGraph.getJobID(), jobId);
}
 
Example 2
Source File: ClassPathJobGraphRetrieverTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testJobGraphRetrievalJobClassNameHasPrecedenceOverClassPath() throws FlinkException, FileNotFoundException {
	final File testJar = new File("non-existing");

	final ClassPathJobGraphRetriever classPathJobGraphRetriever = new ClassPathJobGraphRetriever(
		new JobID(),
		SavepointRestoreSettings.none(),
		PROGRAM_ARGUMENTS,
		// Both a class name is specified and a JAR "is" on the class path
		// The class name should have precedence.
		TestJob.class.getCanonicalName(),
		() -> Collections.singleton(testJar));

	final JobGraph jobGraph = classPathJobGraphRetriever.retrieveJobGraph(new Configuration());

	assertThat(jobGraph.getName(), is(equalTo(TestJob.class.getCanonicalName() + "-suffix")));
}
 
Example 3
Source File: JarRunHandler.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private SavepointRestoreSettings getSavepointRestoreSettings(
		final @Nonnull HandlerRequest<JarRunRequestBody, JarRunMessageParameters> request)
			throws RestHandlerException {

	final JarRunRequestBody requestBody = request.getRequestBody();

	final boolean allowNonRestoredState = fromRequestBodyOrQueryParameter(
		requestBody.getAllowNonRestoredState(),
		() -> getQueryParameter(request, AllowNonRestoredStateQueryParameter.class),
		false,
		log);
	final String savepointPath = fromRequestBodyOrQueryParameter(
		emptyToNull(requestBody.getSavepointPath()),
		() -> emptyToNull(getQueryParameter(request, SavepointPathQueryParameter.class)),
		null,
		log);
	final SavepointRestoreSettings savepointRestoreSettings;
	if (savepointPath != null) {
		savepointRestoreSettings = SavepointRestoreSettings.forPath(
			savepointPath,
			allowNonRestoredState);
	} else {
		savepointRestoreSettings = SavepointRestoreSettings.none();
	}
	return savepointRestoreSettings;
}
 
Example 4
Source File: ClassPathJobGraphRetrieverTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testJobGraphRetrieval() throws FlinkException {
	final int parallelism = 42;
	final Configuration configuration = new Configuration();
	configuration.setInteger(CoreOptions.DEFAULT_PARALLELISM, parallelism);
	final JobID jobId = new JobID();

	final ClassPathJobGraphRetriever classPathJobGraphRetriever = new ClassPathJobGraphRetriever(
		jobId,
		SavepointRestoreSettings.none(),
		PROGRAM_ARGUMENTS,
		TestJob.class.getCanonicalName());

	final JobGraph jobGraph = classPathJobGraphRetriever.retrieveJobGraph(configuration);

	assertThat(jobGraph.getName(), is(equalTo(TestJob.class.getCanonicalName() + "-suffix")));
	assertThat(jobGraph.getMaximumParallelism(), is(parallelism));
	assertEquals(jobGraph.getJobID(), jobId);
}
 
Example 5
Source File: ClassPathJobGraphRetrieverTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testJobGraphRetrievalJobClassNameHasPrecedenceOverClassPath() throws FlinkException, FileNotFoundException {
	final File testJar = new File("non-existing");

	final ClassPathJobGraphRetriever classPathJobGraphRetriever = new ClassPathJobGraphRetriever(
		new JobID(),
		SavepointRestoreSettings.none(),
		PROGRAM_ARGUMENTS,
		// Both a class name is specified and a JAR "is" on the class path
		// The class name should have precedence.
		TestJob.class.getCanonicalName(),
		() -> Collections.singleton(testJar));

	final JobGraph jobGraph = classPathJobGraphRetriever.retrieveJobGraph(new Configuration());

	assertThat(jobGraph.getName(), is(equalTo(TestJob.class.getCanonicalName() + "-suffix")));
}
 
Example 6
Source File: JarRunHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
private SavepointRestoreSettings getSavepointRestoreSettings(
		final @Nonnull HandlerRequest<JarRunRequestBody, JarRunMessageParameters> request)
			throws RestHandlerException {

	final JarRunRequestBody requestBody = request.getRequestBody();

	final boolean allowNonRestoredState = fromRequestBodyOrQueryParameter(
		requestBody.getAllowNonRestoredState(),
		() -> getQueryParameter(request, AllowNonRestoredStateQueryParameter.class),
		false,
		log);
	final String savepointPath = fromRequestBodyOrQueryParameter(
		emptyToNull(requestBody.getSavepointPath()),
		() -> emptyToNull(getQueryParameter(request, SavepointPathQueryParameter.class)),
		null,
		log);
	final SavepointRestoreSettings savepointRestoreSettings;
	if (savepointPath != null) {
		savepointRestoreSettings = SavepointRestoreSettings.forPath(
			savepointPath,
			allowNonRestoredState);
	} else {
		savepointRestoreSettings = SavepointRestoreSettings.none();
	}
	return savepointRestoreSettings;
}
 
Example 7
Source File: JarRunHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
private SavepointRestoreSettings getSavepointRestoreSettings(
		final @Nonnull HandlerRequest<JarRunRequestBody, JarRunMessageParameters> request)
			throws RestHandlerException {

	final JarRunRequestBody requestBody = request.getRequestBody();

	final boolean allowNonRestoredState = fromRequestBodyOrQueryParameter(
		requestBody.getAllowNonRestoredState(),
		() -> getQueryParameter(request, AllowNonRestoredStateQueryParameter.class),
		false,
		log);
	final String savepointPath = fromRequestBodyOrQueryParameter(
		emptyToNull(requestBody.getSavepointPath()),
		() -> emptyToNull(getQueryParameter(request, SavepointPathQueryParameter.class)),
		null,
		log);
	final SavepointRestoreSettings savepointRestoreSettings;
	if (savepointPath != null) {
		savepointRestoreSettings = SavepointRestoreSettings.forPath(
			savepointPath,
			allowNonRestoredState);
	} else {
		savepointRestoreSettings = SavepointRestoreSettings.none();
	}
	return savepointRestoreSettings;
}
 
Example 8
Source File: ClassPathJobGraphRetrieverTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testJobGraphRetrievalFromJar() throws FlinkException, FileNotFoundException {
	final File testJar = TestJob.getTestJobJar();
	final ClassPathJobGraphRetriever classPathJobGraphRetriever = new ClassPathJobGraphRetriever(
		new JobID(),
		SavepointRestoreSettings.none(),
		PROGRAM_ARGUMENTS,
		// No class name specified, but the test JAR "is" on the class path
		null,
		() -> Collections.singleton(testJar));

	final JobGraph jobGraph = classPathJobGraphRetriever.retrieveJobGraph(new Configuration());

	assertThat(jobGraph.getName(), is(equalTo(TestJob.class.getCanonicalName() + "-suffix")));
}
 
Example 9
Source File: CliFrontendParser.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public static SavepointRestoreSettings createSavepointRestoreSettings(CommandLine commandLine) {
	if (commandLine.hasOption(SAVEPOINT_PATH_OPTION.getOpt())) {
		String savepointPath = commandLine.getOptionValue(SAVEPOINT_PATH_OPTION.getOpt());
		boolean allowNonRestoredState = commandLine.hasOption(SAVEPOINT_ALLOW_NON_RESTORED_OPTION.getOpt());
		return SavepointRestoreSettings.forPath(savepointPath, allowNonRestoredState);
	} else {
		return SavepointRestoreSettings.none();
	}
}
 
Example 10
Source File: ClassPathJobGraphRetrieverTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testJobGraphRetrievalFromJar() throws FlinkException, FileNotFoundException {
	final File testJar = TestJob.getTestJobJar();
	final ClassPathJobGraphRetriever classPathJobGraphRetriever = new ClassPathJobGraphRetriever(
		new JobID(),
		SavepointRestoreSettings.none(),
		PROGRAM_ARGUMENTS,
		// No class name specified, but the test JAR "is" on the class path
		null,
		() -> Collections.singleton(testJar));

	final JobGraph jobGraph = classPathJobGraphRetriever.retrieveJobGraph(new Configuration());

	assertThat(jobGraph.getName(), is(equalTo(TestJob.class.getCanonicalName() + "-suffix")));
}
 
Example 11
Source File: CliFrontendParser.java    From flink with Apache License 2.0 5 votes vote down vote up
public static SavepointRestoreSettings createSavepointRestoreSettings(CommandLine commandLine) {
	if (commandLine.hasOption(SAVEPOINT_PATH_OPTION.getOpt())) {
		String savepointPath = commandLine.getOptionValue(SAVEPOINT_PATH_OPTION.getOpt());
		boolean allowNonRestoredState = commandLine.hasOption(SAVEPOINT_ALLOW_NON_RESTORED_OPTION.getOpt());
		return SavepointRestoreSettings.forPath(savepointPath, allowNonRestoredState);
	} else {
		return SavepointRestoreSettings.none();
	}
}
 
Example 12
Source File: CliFrontendParser.java    From flink with Apache License 2.0 5 votes vote down vote up
public static SavepointRestoreSettings createSavepointRestoreSettings(CommandLine commandLine) {
	if (commandLine.hasOption(SAVEPOINT_PATH_OPTION.getOpt())) {
		String savepointPath = commandLine.getOptionValue(SAVEPOINT_PATH_OPTION.getOpt());
		boolean allowNonRestoredState = commandLine.hasOption(SAVEPOINT_ALLOW_NON_RESTORED_OPTION.getOpt());
		return SavepointRestoreSettings.forPath(savepointPath, allowNonRestoredState);
	} else {
		return SavepointRestoreSettings.none();
	}
}