use of org.apache.flink.runtime.rest.messages.job.savepoints.stop.StopWithSavepointTriggerHeaders in project flink by apache.
the class RestClusterClient method stopWithSavepoint.
@Override
public CompletableFuture<String> stopWithSavepoint(final JobID jobId, final boolean advanceToEndOfTime, @Nullable final String savepointDirectory, final SavepointFormatType formatType) {
final StopWithSavepointTriggerHeaders stopWithSavepointTriggerHeaders = StopWithSavepointTriggerHeaders.getInstance();
final SavepointTriggerMessageParameters stopWithSavepointTriggerMessageParameters = stopWithSavepointTriggerHeaders.getUnresolvedMessageParameters();
stopWithSavepointTriggerMessageParameters.jobID.resolve(jobId);
final CompletableFuture<TriggerResponse> responseFuture = sendRequest(stopWithSavepointTriggerHeaders, stopWithSavepointTriggerMessageParameters, new StopWithSavepointRequestBody(savepointDirectory, advanceToEndOfTime, formatType, null));
return responseFuture.thenCompose(savepointTriggerResponseBody -> {
final TriggerId savepointTriggerId = savepointTriggerResponseBody.getTriggerId();
return pollSavepointAsync(jobId, savepointTriggerId);
}).thenApply(savepointInfo -> {
if (savepointInfo.getFailureCause() != null) {
throw new CompletionException(savepointInfo.getFailureCause());
}
return savepointInfo.getLocation();
});
}
Aggregations