use of org.apache.flink.runtime.rest.messages.job.savepoints.SavepointInfo in project flink by apache.
the class StopWithSavepointHandlersTest method testProvidedTriggerId.
@Test
public void testProvidedTriggerId() throws Exception {
final OperationResult<String> successfulResult = OperationResult.success(COMPLETED_SAVEPOINT_EXTERNAL_POINTER);
AtomicReference<AsynchronousJobOperationKey> keyReference = new AtomicReference<>();
final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder().setStopWithSavepointFunction(setReferenceToOperationKey(keyReference)).setGetSavepointStatusFunction(getResultIfKeyMatches(successfulResult, keyReference)).build();
final TriggerId providedTriggerId = new TriggerId();
final TriggerId returnedTriggerId = savepointTriggerHandler.handleRequest(triggerSavepointRequest(DEFAULT_REQUESTED_SAVEPOINT_TARGET_DIRECTORY, SavepointFormatType.CANONICAL, providedTriggerId), testingRestfulGateway).get().getTriggerId();
assertEquals(providedTriggerId, returnedTriggerId);
AsynchronousOperationResult<SavepointInfo> savepointResponseBody;
savepointResponseBody = savepointStatusHandler.handleRequest(savepointStatusRequest(providedTriggerId), testingRestfulGateway).get();
assertThat(savepointResponseBody.queueStatus().getId(), equalTo(QueueStatus.Id.COMPLETED));
assertThat(savepointResponseBody.resource(), notNullValue());
assertThat(savepointResponseBody.resource().getLocation(), equalTo(COMPLETED_SAVEPOINT_EXTERNAL_POINTER));
}
use of org.apache.flink.runtime.rest.messages.job.savepoints.SavepointInfo in project flink by apache.
the class SavepointHandlersTest method testQueryStatusOfUnknownOperationReturnsError.
@Test
public void testQueryStatusOfUnknownOperationReturnsError() throws HandlerRequestException, RestHandlerException {
final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder().setGetSavepointStatusFunction(key -> FutureUtils.completedExceptionally(new UnknownOperationKeyException(key))).build();
final CompletableFuture<AsynchronousOperationResult<SavepointInfo>> statusFuture = savepointStatusHandler.handleRequest(savepointStatusRequest(new TriggerId()), testingRestfulGateway);
assertThat(statusFuture, RestMatchers.respondsWithError(HttpResponseStatus.NOT_FOUND));
}
use of org.apache.flink.runtime.rest.messages.job.savepoints.SavepointInfo 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