use of io.pravega.common.tracing.RequestTag in project pravega by pravega.
the class ControllerServiceImpl method getDelegationToken.
@Override
public void getDelegationToken(StreamInfo request, StreamObserver<DelegationToken> responseObserver) {
RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), GET_OR_REFRESH_DELEGATION_TOKEN_FOR, request.getScope(), request.getStream());
log.info(requestTag.getRequestId(), "getDelegationToken called for stream {}/{}.", request.getScope(), request.getStream());
authenticateExecuteAndProcessResults(this.delegationTokenSupplier(request), delegationToken -> {
logIfEmpty(delegationToken, "getDelegationToken", request.getScope(), request.getStream());
return CompletableFuture.completedFuture(DelegationToken.newBuilder().setDelegationToken(delegationToken).build());
}, responseObserver);
}
use of io.pravega.common.tracing.RequestTag in project pravega by pravega.
the class ControllerServiceImpl method checkStreamExists.
@Override
public void checkStreamExists(StreamInfo request, StreamObserver<Controller.ExistsResponse> responseObserver) {
RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), CHECK_STREAM_EXISTS);
String scope = request.getScope();
String stream = request.getStream();
log.info(requestTag.getRequestId(), "checkStream exists called for {}/{}.", scope, stream);
final AuthContext ctx;
if (this.grpcAuthHelper.isAuthEnabled()) {
ctx = AuthContext.current();
} else {
ctx = null;
}
Supplier<String> stringSupplier = () -> {
String result = this.grpcAuthHelper.checkAuthorization(authorizationResource.ofStreamInScope(scope, stream), AuthHandler.Permissions.READ, ctx);
log.debug("Result of authorization for [{}] and READ permission is: [{}]", authorizationResource.ofScopes(), result);
return result;
};
Function<String, CompletableFuture<Controller.ExistsResponse>> streamFn = delegationToken -> controllerService.getStream(scope, stream, requestTag.getRequestId()).handle((response, e) -> {
boolean exists;
if (e != null) {
if (Exceptions.unwrap(e) instanceof StoreException.DataNotFoundException) {
exists = false;
} else {
throw new CompletionException(e);
}
} else {
exists = true;
}
return Controller.ExistsResponse.newBuilder().setExists(exists).build();
});
authenticateExecuteAndProcessResults(stringSupplier, streamFn, responseObserver, requestTag);
}
use of io.pravega.common.tracing.RequestTag in project pravega by pravega.
the class ControllerServiceImpl method listStreamsInScope.
@Override
public void listStreamsInScope(Controller.StreamsInScopeRequest request, StreamObserver<Controller.StreamsInScopeResponse> responseObserver) {
String scopeName = request.getScope().getScope();
RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), LIST_STREAMS_IN_SCOPE, scopeName);
log.info(requestTag.getRequestId(), "listStream called for scope {}.", scopeName);
final AuthContext ctx = this.grpcAuthHelper.isAuthEnabled() ? AuthContext.current() : null;
Function<String, CompletableFuture<Controller.StreamsInScopeResponse>> streamsFn = delegationToken -> listWithFilter(request.getContinuationToken().getToken(), pageLimit, (x, y) -> controllerService.listStreams(scopeName, x, y, requestTag.getRequestId()), x -> grpcAuthHelper.isAuthorized(authorizationResource.ofStreamInScope(scopeName, x), AuthHandler.Permissions.READ, ctx), x -> StreamInfo.newBuilder().setScope(scopeName).setStream(x).build(), requestTag.getRequestId()).handle((response, ex) -> {
if (ex != null) {
if (Exceptions.unwrap(ex) instanceof StoreException.DataNotFoundException) {
return Controller.StreamsInScopeResponse.newBuilder().setStatus(Controller.StreamsInScopeResponse.Status.SCOPE_NOT_FOUND).build();
} else {
throw new CompletionException(ex);
}
} else {
return Controller.StreamsInScopeResponse.newBuilder().addAllStreams(response.getKey()).setContinuationToken(Controller.ContinuationToken.newBuilder().setToken(response.getValue()).build()).setStatus(Controller.StreamsInScopeResponse.Status.SUCCESS).build();
}
});
authenticateExecuteAndProcessResults(() -> {
String result = this.grpcAuthHelper.checkAuthorization(authorizationResource.ofScope(scopeName), AuthHandler.Permissions.READ, ctx);
log.debug("Result of authorization for [{}] and READ permission is: [{}]", authorizationResource.ofScope(scopeName), result);
return result;
}, streamsFn, responseObserver, requestTag);
}
use of io.pravega.common.tracing.RequestTag in project pravega by pravega.
the class ControllerServiceImpl method updateReaderGroup.
@Override
public void updateReaderGroup(ReaderGroupConfiguration request, StreamObserver<UpdateReaderGroupResponse> responseObserver) {
String scope = request.getScope();
String rgName = request.getReaderGroupName();
RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), UPDATE_READER_GROUP, scope, rgName);
log.info(requestTag.getRequestId(), "updateReaderGroup called for ReaderGroup {}/{}.", scope, rgName);
AuthHandler.Permissions requiredPermission = this.isRGStreamWritesWithReadPermEnabled ? AuthHandler.Permissions.READ : AuthHandler.Permissions.READ_UPDATE;
authenticateExecuteAndProcessResults(() -> this.grpcAuthHelper.checkAuthorizationAndCreateToken(authorizationResource.ofReaderGroupsInScope(scope), requiredPermission), delegationToken -> controllerService.updateReaderGroup(scope, rgName, ModelHelper.encode(request), requestTag.getRequestId()), responseObserver, requestTag);
}
use of io.pravega.common.tracing.RequestTag in project pravega by pravega.
the class ControllerServiceImpl method getKeyValueTableConfiguration.
@Override
public void getKeyValueTableConfiguration(KeyValueTableInfo request, StreamObserver<Controller.KeyValueTableConfigResponse> responseObserver) {
RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), GET_KEY_VALUE_TABLE_CONFIGURATION, request.getScope(), request.getKvtName());
log.info(requestTag.getRequestId(), "{} called for {}/{}.", GET_KEY_VALUE_TABLE_CONFIGURATION, request.getScope(), request.getKvtName());
authenticateExecuteAndProcessResults(() -> this.grpcAuthHelper.checkAuthorization(authorizationResource.ofKeyValueTableInScope(request.getScope(), request.getKvtName()), AuthHandler.Permissions.READ), delegationToken -> controllerService.getKeyValueTableConfiguration(request.getScope(), request.getKvtName(), requestTag.getRequestId()), responseObserver, requestTag);
}
Aggregations