Search in sources :

Example 1 with SavepointDisposalStatusHeaders

use of org.apache.flink.runtime.rest.messages.job.savepoints.SavepointDisposalStatusHeaders in project flink by apache.

the class RestClusterClient method disposeSavepoint.

@Override
public CompletableFuture<Acknowledge> disposeSavepoint(String savepointPath) {
    final SavepointDisposalRequest savepointDisposalRequest = new SavepointDisposalRequest(savepointPath);
    final CompletableFuture<TriggerResponse> savepointDisposalTriggerFuture = sendRequest(SavepointDisposalTriggerHeaders.getInstance(), savepointDisposalRequest);
    final CompletableFuture<AsynchronousOperationInfo> savepointDisposalFuture = savepointDisposalTriggerFuture.thenCompose((TriggerResponse triggerResponse) -> {
        final TriggerId triggerId = triggerResponse.getTriggerId();
        final SavepointDisposalStatusHeaders savepointDisposalStatusHeaders = SavepointDisposalStatusHeaders.getInstance();
        final SavepointDisposalStatusMessageParameters savepointDisposalStatusMessageParameters = savepointDisposalStatusHeaders.getUnresolvedMessageParameters();
        savepointDisposalStatusMessageParameters.triggerIdPathParameter.resolve(triggerId);
        return pollResourceAsync(() -> sendRequest(savepointDisposalStatusHeaders, savepointDisposalStatusMessageParameters));
    });
    return savepointDisposalFuture.thenApply((AsynchronousOperationInfo asynchronousOperationInfo) -> {
        if (asynchronousOperationInfo.getFailureCause() == null) {
            return Acknowledge.get();
        } else {
            throw new CompletionException(asynchronousOperationInfo.getFailureCause());
        }
    });
}
Also used : SavepointDisposalStatusHeaders(org.apache.flink.runtime.rest.messages.job.savepoints.SavepointDisposalStatusHeaders) SavepointDisposalStatusMessageParameters(org.apache.flink.runtime.rest.messages.job.savepoints.SavepointDisposalStatusMessageParameters) TriggerId(org.apache.flink.runtime.rest.messages.TriggerId) CompletionException(java.util.concurrent.CompletionException) SavepointDisposalRequest(org.apache.flink.runtime.rest.messages.job.savepoints.SavepointDisposalRequest) TriggerResponse(org.apache.flink.runtime.rest.handler.async.TriggerResponse) AsynchronousOperationInfo(org.apache.flink.runtime.rest.handler.async.AsynchronousOperationInfo)

Aggregations

CompletionException (java.util.concurrent.CompletionException)1 AsynchronousOperationInfo (org.apache.flink.runtime.rest.handler.async.AsynchronousOperationInfo)1 TriggerResponse (org.apache.flink.runtime.rest.handler.async.TriggerResponse)1 TriggerId (org.apache.flink.runtime.rest.messages.TriggerId)1 SavepointDisposalRequest (org.apache.flink.runtime.rest.messages.job.savepoints.SavepointDisposalRequest)1 SavepointDisposalStatusHeaders (org.apache.flink.runtime.rest.messages.job.savepoints.SavepointDisposalStatusHeaders)1 SavepointDisposalStatusMessageParameters (org.apache.flink.runtime.rest.messages.job.savepoints.SavepointDisposalStatusMessageParameters)1