use of org.apache.flink.runtime.jobgraph.SavepointRestoreSettings in project flink by apache.
the class JarActionHandlerTest method testSavepointRestoreSettings.
/**
* Test that the savepoint settings are correctly parsed.
*/
@Test
public void testSavepointRestoreSettings() throws Exception {
Map<String, String> pathParams = new HashMap<>();
// required
pathParams.put("jarid", "required");
// the following should be ignored, because they are parsed from the query params
pathParams.put("savepointPath", "ignored");
pathParams.put("allowNonRestoredState", "ignored");
// <-- everything goes here
Map<String, String> queryParams = new HashMap<>();
// Nothing configured
JarActionHandlerConfig config = JarActionHandlerConfig.fromParams(pathParams, queryParams);
assertEquals(SavepointRestoreSettings.none(), config.getSavepointRestoreSettings());
// Set path
queryParams.put("savepointPath", "the-savepoint-path");
queryParams.put("allowNonRestoredState", "");
SavepointRestoreSettings expected = SavepointRestoreSettings.forPath("the-savepoint-path", false);
config = JarActionHandlerConfig.fromParams(pathParams, queryParams);
assertEquals(expected, config.getSavepointRestoreSettings());
// Set flag
queryParams.put("allowNonRestoredState", "true");
expected = SavepointRestoreSettings.forPath("the-savepoint-path", true);
config = JarActionHandlerConfig.fromParams(pathParams, queryParams);
assertEquals(expected, config.getSavepointRestoreSettings());
}
use of org.apache.flink.runtime.jobgraph.SavepointRestoreSettings in project flink by apache.
the class StandaloneApplicationClusterConfigurationParserFactoryTest method testShortOptions.
@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));
}
use of org.apache.flink.runtime.jobgraph.SavepointRestoreSettings in project flink by apache.
the class CliFrontendRunTest method testRestoreMode.
private void testRestoreMode(String flag, String arg, RestoreMode expectedMode) throws Exception {
String[] parameters = { "-s", "expectedSavepointPath", "-n", flag, arg, getTestJarPath() };
CommandLine commandLine = CliFrontendParser.parse(CliFrontendParser.RUN_OPTIONS, parameters, true);
ProgramOptions programOptions = ProgramOptions.create(commandLine);
ExecutionConfigAccessor executionOptions = ExecutionConfigAccessor.fromProgramOptions(programOptions, Collections.emptyList());
SavepointRestoreSettings savepointSettings = executionOptions.getSavepointRestoreSettings();
assertTrue(savepointSettings.restoreSavepoint());
assertEquals(expectedMode, savepointSettings.getRestoreMode());
assertEquals("expectedSavepointPath", savepointSettings.getRestorePath());
assertTrue(savepointSettings.allowNonRestoredState());
}
use of org.apache.flink.runtime.jobgraph.SavepointRestoreSettings in project flink by apache.
the class DefaultPackagedProgramRetrieverTest method testSavepointRestoreSettings.
@Test
public void testSavepointRestoreSettings() throws FlinkException, IOException, ProgramInvocationException {
final Configuration configuration = new Configuration();
final SavepointRestoreSettings savepointRestoreSettings = SavepointRestoreSettings.forPath("foobar", true);
final JobID jobId = new JobID();
configuration.setString(PipelineOptionsInternal.PIPELINE_FIXED_JOB_ID, jobId.toHexString());
SavepointRestoreSettings.toConfiguration(savepointRestoreSettings, configuration);
final String expectedSuffix = "suffix";
final PackagedProgramRetriever retrieverUnderTest = DefaultPackagedProgramRetriever.create(null, testJobEntryClassClasspathProvider.getJobClassName(), ClasspathProvider.parametersForTestJob(expectedSuffix), new Configuration());
final JobGraph jobGraph = retrieveJobGraph(retrieverUnderTest, configuration);
assertThat(jobGraph.getSavepointRestoreSettings(), is(savepointRestoreSettings));
assertThat(jobGraph.getJobID(), is(jobId));
}
use of org.apache.flink.runtime.jobgraph.SavepointRestoreSettings in project flink by apache.
the class RemoteStreamEnvironmentTest method testRemoteExecutionWithSavepoint.
@Test
public void testRemoteExecutionWithSavepoint() throws Exception {
SavepointRestoreSettings restoreSettings = SavepointRestoreSettings.forPath("fakePath");
JobID jobID = new JobID();
TestExecutorServiceLoader testExecutorServiceLoader = new TestExecutorServiceLoader(jobID);
RemoteStreamEnvironment env = new RemoteStreamEnvironment(testExecutorServiceLoader, "fakeHost", 1, null, new String[] {}, null, restoreSettings);
env.fromElements(1).map(x -> x * 2);
JobExecutionResult actualResult = env.execute("fakeJobName");
assertThat(actualResult.getJobID(), is(jobID));
assertThat(testExecutorServiceLoader.getActualSavepointRestoreSettings(), is(restoreSettings));
}
Aggregations