use of io.pravega.shared.controller.tracing.RPCTracingTags.SEAL_STREAM in project pravega by pravega.
the class ControllerImpl method sealStream.
@Override
public CompletableFuture<Boolean> sealStream(final String scope, final String streamName) {
Exceptions.checkNotClosed(closed.get(), this);
Exceptions.checkNotNullOrEmpty(scope, "scope");
Exceptions.checkNotNullOrEmpty(streamName, "streamName");
final long requestId = requestIdGenerator.get();
long traceId = LoggerHelpers.traceEnter(log, "sealStream", scope, streamName, requestId);
final CompletableFuture<UpdateStreamStatus> result = this.retryConfig.runAsync(() -> {
RPCAsyncCallback<UpdateStreamStatus> callback = new RPCAsyncCallback<>(requestId, "sealStream", scope, streamName);
new ControllerClientTagger(client, timeoutMillis).withTag(requestId, SEAL_STREAM, scope, streamName).sealStream(ModelHelper.createStreamInfo(scope, streamName), callback);
return callback.getFuture();
}, this.executor);
return result.thenApplyAsync(x -> {
switch(x.getStatus()) {
case FAILURE:
log.warn(requestId, "Failed to seal stream: {}", streamName);
throw new ControllerFailureException("Failed to seal stream: " + streamName);
case SCOPE_NOT_FOUND:
log.warn(requestId, "Scope not found: {}", scope);
throw new InvalidStreamException("Scope does not exist: " + scope);
case STREAM_NOT_FOUND:
log.warn(requestId, "Stream does not exist: {}", streamName);
throw new InvalidStreamException("Stream does not exist: " + streamName);
case SUCCESS:
log.info(requestId, "Successfully sealed stream: {}", streamName);
return true;
case UNRECOGNIZED:
default:
throw new ControllerFailureException("Unknown return status sealing stream " + streamName + " " + x.getStatus());
}
}, this.executor).whenComplete((x, e) -> {
if (e != null) {
log.warn(requestId, "sealStream {}/{} failed: ", scope, streamName, e);
}
LoggerHelpers.traceLeave(log, "sealStream", traceId, scope, streamName, requestId);
});
}
Aggregations