use of io.pravega.common.tracing.RequestTag in project pravega by pravega.
the class ControllerServiceImpl method getStreamConfiguration.
@Override
public void getStreamConfiguration(StreamInfo request, StreamObserver<StreamConfig> responseObserver) {
RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), GET_STREAM_CONFIGURATION);
String scope = request.getScope();
String stream = request.getStream();
log.info(requestTag.getRequestId(), "{} called for {}/{}.", GET_STREAM_CONFIGURATION, 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<StreamConfig>> streamFn = delegationToken -> controllerService.getStream(scope, stream, requestTag.getRequestId()).handle((response, e) -> {
if (e != null) {
throw new CompletionException(e);
} else {
return decode(scope, stream, response);
}
});
authenticateExecuteAndProcessResults(stringSupplier, streamFn, responseObserver, requestTag);
}
use of io.pravega.common.tracing.RequestTag in project pravega by pravega.
the class ControllerServiceImpl method deleteScope.
@Override
public void deleteScope(ScopeInfo request, StreamObserver<DeleteScopeStatus> responseObserver) {
RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), DELETE_SCOPE, request.getScope());
log.info(requestTag.getRequestId(), "deleteScope called for scope {}.", request.getScope());
authenticateExecuteAndProcessResults(() -> this.grpcAuthHelper.checkAuthorization(authorizationResource.ofScopes(), AuthHandler.Permissions.READ_UPDATE), delegationToken -> controllerService.deleteScope(request.getScope(), requestTag.getRequestId()), responseObserver, requestTag);
}
use of io.pravega.common.tracing.RequestTag in project pravega by pravega.
the class ControllerServiceImpl method createScope.
@Override
public void createScope(ScopeInfo request, StreamObserver<CreateScopeStatus> responseObserver) {
RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), CREATE_SCOPE, request.getScope());
log.info(requestTag.getRequestId(), "createScope called for scope {}.", request.getScope());
authenticateExecuteAndProcessResults(() -> this.grpcAuthHelper.checkAuthorization(authorizationResource.ofScopes(), AuthHandler.Permissions.READ_UPDATE), delegationToken -> controllerService.createScope(request.getScope(), requestTag.getRequestId()), responseObserver, requestTag);
}
use of io.pravega.common.tracing.RequestTag in project pravega by pravega.
the class ControllerServiceImpl method createTransaction.
@Override
public void createTransaction(CreateTxnRequest request, StreamObserver<Controller.CreateTxnResponse> responseObserver) {
RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), CREATE_TRANSACTION, request.getStreamInfo().getScope(), request.getStreamInfo().getStream(), Long.toString(request.getLease()));
log.info(requestTag.getRequestId(), "createTransaction called for stream {}/{}.", request.getStreamInfo().getScope(), request.getStreamInfo().getStream());
authenticateExecuteAndProcessResults(() -> this.grpcAuthHelper.checkAuthorizationAndCreateToken(authorizationResource.ofStreamInScope(request.getStreamInfo().getScope(), request.getStreamInfo().getStream()), AuthHandler.Permissions.READ_UPDATE), delegationToken -> controllerService.createTransaction(request.getStreamInfo().getScope(), request.getStreamInfo().getStream(), request.getLease(), requestTag.getRequestId()).thenApply(pair -> Controller.CreateTxnResponse.newBuilder().setDelegationToken(delegationToken).setTxnId(decode(pair.getKey())).addAllActiveSegments(pair.getValue()).build()), responseObserver, requestTag);
}
use of io.pravega.common.tracing.RequestTag in project pravega by pravega.
the class ControllerServiceImpl method truncateStream.
@Override
public void truncateStream(Controller.StreamCut request, StreamObserver<UpdateStreamStatus> responseObserver) {
RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), TRUNCATE_STREAM, request.getStreamInfo().getScope(), request.getStreamInfo().getStream());
log.info(requestTag.getRequestId(), "truncateStream called for stream {}/{}.", request.getStreamInfo().getScope(), request.getStreamInfo().getStream());
authenticateExecuteAndProcessResults(() -> this.grpcAuthHelper.checkAuthorization(authorizationResource.ofStreamInScope(request.getStreamInfo().getScope(), request.getStreamInfo().getStream()), AuthHandler.Permissions.READ_UPDATE), delegationToken -> controllerService.truncateStream(request.getStreamInfo().getScope(), request.getStreamInfo().getStream(), ModelHelper.encode(request), requestTag.getRequestId()), responseObserver, requestTag);
}
Aggregations