use of org.apache.flink.runtime.rest.messages.job.savepoints.stop.StopWithSavepointRequestBody in project flink by apache.
the class SavepointHandlerRequestBodyTest method testStopWithSavepointRequestCanBeParsedFromEmptyObject.
@Test
public void testStopWithSavepointRequestCanBeParsedFromEmptyObject() throws JsonProcessingException {
final StopWithSavepointRequestBody defaultParseResult = getDefaultParseResult(StopWithSavepointRequestBody.class);
assertThat(defaultParseResult.shouldDrain(), is(false));
assertThat(defaultParseResult.getTargetDirectory().isPresent(), is(false));
}
use of org.apache.flink.runtime.rest.messages.job.savepoints.stop.StopWithSavepointRequestBody 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