Search in sources :

Example 11 with SavepointRestoreSettings

use of org.apache.flink.runtime.jobgraph.SavepointRestoreSettings in project flink by apache.

the class StandaloneApplicationClusterConfigurationParserFactoryTest method testSavepointRestoreSettingsParsing.

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

Example 12 with SavepointRestoreSettings

use of org.apache.flink.runtime.jobgraph.SavepointRestoreSettings in project flink by apache.

the class JarRunHandler method getSavepointRestoreSettings.

private SavepointRestoreSettings getSavepointRestoreSettings(@Nonnull final HandlerRequest<JarRunRequestBody> 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 RestoreMode restoreMode = Optional.ofNullable(requestBody.getRestoreMode()).orElseGet(SavepointConfigOptions.RESTORE_MODE::defaultValue);
    final SavepointRestoreSettings savepointRestoreSettings;
    if (savepointPath != null) {
        savepointRestoreSettings = SavepointRestoreSettings.forPath(savepointPath, allowNonRestoredState, restoreMode);
    } else {
        savepointRestoreSettings = SavepointRestoreSettings.none();
    }
    return savepointRestoreSettings;
}
Also used : RestoreMode(org.apache.flink.runtime.jobgraph.RestoreMode) SavepointRestoreSettings(org.apache.flink.runtime.jobgraph.SavepointRestoreSettings)

Example 13 with SavepointRestoreSettings

use of org.apache.flink.runtime.jobgraph.SavepointRestoreSettings in project flink by apache.

the class JarRunHandlerParameterTest method validateDefaultGraph.

@Override
JobGraph validateDefaultGraph() {
    JobGraph jobGraph = super.validateDefaultGraph();
    final SavepointRestoreSettings savepointRestoreSettings = jobGraph.getSavepointRestoreSettings();
    assertFalse(savepointRestoreSettings.allowNonRestoredState());
    Assert.assertNull(savepointRestoreSettings.getRestorePath());
    return jobGraph;
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) SavepointRestoreSettings(org.apache.flink.runtime.jobgraph.SavepointRestoreSettings)

Example 14 with SavepointRestoreSettings

use of org.apache.flink.runtime.jobgraph.SavepointRestoreSettings in project flink by apache.

the class JarRunHandlerParameterTest method validateGraph.

@Override
JobGraph validateGraph() {
    JobGraph jobGraph = super.validateGraph();
    final SavepointRestoreSettings savepointRestoreSettings = jobGraph.getSavepointRestoreSettings();
    Assert.assertTrue(savepointRestoreSettings.allowNonRestoredState());
    assertEquals(RESTORE_PATH, savepointRestoreSettings.getRestorePath());
    return jobGraph;
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) SavepointRestoreSettings(org.apache.flink.runtime.jobgraph.SavepointRestoreSettings)

Example 15 with SavepointRestoreSettings

use of org.apache.flink.runtime.jobgraph.SavepointRestoreSettings in project beam by apache.

the class FlinkSavepointTest method restoreFromSavepointLegacy.

private void restoreFromSavepointLegacy(Pipeline pipeline, String savepointDir) throws ExecutionException, InterruptedException {
    JobGraph jobGraph = getJobGraph(pipeline);
    SavepointRestoreSettings savepointSettings = SavepointRestoreSettings.forPath(savepointDir);
    jobGraph.setSavepointRestoreSettings(savepointSettings);
    flinkCluster.submitJob(jobGraph).get();
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) SavepointRestoreSettings(org.apache.flink.runtime.jobgraph.SavepointRestoreSettings)

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