use of org.apache.flink.runtime.rest.messages.TriggerId in project flink by apache.
the class AbstractAsynchronousOperationHandlersTest method testCloseShouldFinishOnFirstServedResult.
/**
* Tests that the future returned by {@link
* AbstractAsynchronousOperationHandlers.StatusHandler#closeAsync()} completes when the result
* of the asynchronous operation is served.
*/
@Test
public void testCloseShouldFinishOnFirstServedResult() throws Exception {
final CompletableFuture<Acknowledge> acknowledgeFuture = new CompletableFuture<>();
testingTriggerHandler.setGatewayCallback((request, gateway) -> acknowledgeFuture);
final TriggerId triggerId = testingTriggerHandler.handleRequest(triggerOperationRequest(), DUMMY_GATEWAY).get().getTriggerId();
final CompletableFuture<Void> closeFuture = testingStatusHandler.closeAsync();
testingStatusHandler.handleRequest(statusOperationRequest(triggerId), DUMMY_GATEWAY).get();
assertThat(closeFuture.isDone(), is(false));
acknowledgeFuture.complete(Acknowledge.get());
testingStatusHandler.handleRequest(statusOperationRequest(triggerId), DUMMY_GATEWAY).get();
assertThat(closeFuture.isDone(), is(true));
}
use of org.apache.flink.runtime.rest.messages.TriggerId 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.TriggerId 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