use of io.pravega.shared.controller.tracing.RPCTracingTags.UPDATE_READER_GROUP in project pravega by pravega.
the class ControllerImpl method updateReaderGroup.
@Override
public CompletableFuture<Long> updateReaderGroup(String scope, String rgName, final ReaderGroupConfig rgConfig) {
Exceptions.checkNotClosed(closed.get(), this);
Exceptions.checkNotNullOrEmpty(scope, "scope");
Exceptions.checkNotNullOrEmpty(rgName, "rgName");
Preconditions.checkNotNull(rgConfig, "rgConfig");
final long requestId = requestIdGenerator.get();
long traceId = LoggerHelpers.traceEnter(log, "updateReaderGroup", rgConfig, requestId);
final CompletableFuture<UpdateReaderGroupResponse> result = this.retryConfig.runAsync(() -> {
RPCAsyncCallback<UpdateReaderGroupResponse> callback = new RPCAsyncCallback<>(requestId, "updateReaderGroup", scope, rgName, rgConfig);
new ControllerClientTagger(client, timeoutMillis).withTag(requestId, UPDATE_READER_GROUP, scope, rgName).updateReaderGroup(ModelHelper.decode(scope, rgName, rgConfig), callback);
return callback.getFuture();
}, this.executor);
return result.thenApplyAsync(x -> {
final String rgScopedName = NameUtils.getScopedReaderGroupName(scope, rgName);
switch(x.getStatus()) {
case FAILURE:
log.warn(requestId, "Failed to update Reader Group: {}", rgScopedName);
throw new ControllerFailureException("Failed to update Reader Group: " + rgScopedName);
case INVALID_CONFIG:
log.warn(requestId, "Failed to update Reader Group {} as Config was invalid: {}", rgScopedName, rgConfig);
throw new ReaderGroupConfigRejectedException("Invalid Reader Group Config: " + rgConfig.toString());
case RG_NOT_FOUND:
log.warn(requestId, "Failed to update Reader Group {} as Reader Group was not found.", rgScopedName);
throw new ReaderGroupNotFoundException(rgScopedName);
case SUCCESS:
log.info(requestId, "Reader Group updated successfully: {}", rgScopedName);
return x.getGeneration();
case UNRECOGNIZED:
default:
throw new ControllerFailureException("Unknown return status updating reader group " + rgScopedName + " " + x.getStatus());
}
}, this.executor).whenComplete((x, e) -> {
if (e != null) {
log.warn(requestId, "updateReaderGroup {}/{} failed: ", scope, rgName, e);
}
LoggerHelpers.traceLeave(log, "updateReaderGroup", traceId, rgConfig, requestId);
});
}
Aggregations