Search in sources :

Example 1 with SavepointRestoreSettings

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());
}
Also used : HashMap(java.util.HashMap) JarActionHandlerConfig(org.apache.flink.runtime.webmonitor.handlers.JarActionHandler.JarActionHandlerConfig) SavepointRestoreSettings(org.apache.flink.runtime.jobgraph.SavepointRestoreSettings) Test(org.junit.Test)

Example 2 with SavepointRestoreSettings

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));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) JobID(org.apache.flink.api.common.JobID) SavepointRestoreSettings(org.apache.flink.runtime.jobgraph.SavepointRestoreSettings) Test(org.junit.Test)

Example 3 with SavepointRestoreSettings

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());
}
Also used : CommandLine(org.apache.commons.cli.CommandLine) SavepointRestoreSettings(org.apache.flink.runtime.jobgraph.SavepointRestoreSettings)

Example 4 with SavepointRestoreSettings

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));
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) Configuration(org.apache.flink.configuration.Configuration) JobID(org.apache.flink.api.common.JobID) SavepointRestoreSettings(org.apache.flink.runtime.jobgraph.SavepointRestoreSettings) Test(org.junit.Test)

Example 5 with SavepointRestoreSettings

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));
}
Also used : JobExecutionResult(org.apache.flink.api.common.JobExecutionResult) RemoteStreamEnvironment(org.apache.flink.streaming.api.environment.RemoteStreamEnvironment) JobID(org.apache.flink.api.common.JobID) SavepointRestoreSettings(org.apache.flink.runtime.jobgraph.SavepointRestoreSettings) Test(org.junit.Test)

Aggregations

SavepointRestoreSettings (org.apache.flink.runtime.jobgraph.SavepointRestoreSettings)22 Test (org.junit.Test)12 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)9 Configuration (org.apache.flink.configuration.Configuration)7 JobID (org.apache.flink.api.common.JobID)5 File (java.io.File)4 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)3 CheckpointConfig (org.apache.flink.streaming.api.environment.CheckpointConfig)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 GlobalConfiguration (org.apache.flink.configuration.GlobalConfiguration)2 CheckpointRecoveryFactory (org.apache.flink.runtime.checkpoint.CheckpointRecoveryFactory)2 CompletedCheckpoint (org.apache.flink.runtime.checkpoint.CompletedCheckpoint)2 PerJobCheckpointRecoveryFactory (org.apache.flink.runtime.checkpoint.PerJobCheckpointRecoveryFactory)2 StandaloneCheckpointRecoveryFactory (org.apache.flink.runtime.checkpoint.StandaloneCheckpointRecoveryFactory)2 StandaloneCompletedCheckpointStore (org.apache.flink.runtime.checkpoint.StandaloneCompletedCheckpointStore)2 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)2 JobMasterBuilder (org.apache.flink.runtime.jobmaster.utils.JobMasterBuilder)2 RemoteStreamEnvironment (org.apache.flink.streaming.api.environment.RemoteStreamEnvironment)2 ActorRef (akka.actor.ActorRef)1 ActorSystem (akka.actor.ActorSystem)1