use of io.pravega.common.tracing.RequestTag in project pravega by pravega.
the class ControllerServiceImpl method commitTransaction.
@Override
public void commitTransaction(TxnRequest request, StreamObserver<TxnStatus> responseObserver) {
final UUID txnId = ModelHelper.encode(request.getTxnId());
RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), COMMIT_TRANSACTION, request.getStreamInfo().getScope(), request.getStreamInfo().getStream(), txnId.toString());
log.info(requestTag.getRequestId(), "commitTransaction called for stream {}/{}, txnId={}.", request.getStreamInfo().getScope(), request.getStreamInfo().getStream(), txnId);
authenticateExecuteAndProcessResults(() -> this.grpcAuthHelper.checkAuthorization(authorizationResource.ofStreamInScope(request.getStreamInfo().getScope(), request.getStreamInfo().getStream()), AuthHandler.Permissions.READ_UPDATE), delegationToken -> controllerService.commitTransaction(request.getStreamInfo().getScope(), request.getStreamInfo().getStream(), txnId, request.getWriterId(), request.getTimestamp(), requestTag.getRequestId()), responseObserver);
}
use of io.pravega.common.tracing.RequestTag in project pravega by pravega.
the class ControllerServiceImpl method deleteReaderGroup.
@Override
public void deleteReaderGroup(ReaderGroupInfo request, StreamObserver<DeleteReaderGroupStatus> responseObserver) {
String scope = request.getScope();
String rgName = request.getReaderGroup();
String rgId = request.getReaderGroupId();
RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), DELETE_READER_GROUP, scope, rgName);
log.info(requestTag.getRequestId(), "deleteReaderGroup called for Reader Group {}/{}.", scope, rgName);
AuthHandler.Permissions requiredPermission = this.isRGStreamWritesWithReadPermEnabled ? AuthHandler.Permissions.READ : AuthHandler.Permissions.READ_UPDATE;
authenticateExecuteAndProcessResults(() -> this.grpcAuthHelper.checkAuthorizationAndCreateToken(authorizationResource.ofReaderGroupsInScope(scope), requiredPermission), delegationToken -> controllerService.deleteReaderGroup(scope, rgName, rgId, requestTag.getRequestId()), responseObserver, requestTag);
}
use of io.pravega.common.tracing.RequestTag in project pravega by pravega.
the class ControllerServiceImpl method checkScopeExists.
@Override
public void checkScopeExists(ScopeInfo request, StreamObserver<Controller.ExistsResponse> responseObserver) {
RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), CHECK_SCOPE_EXISTS, request.getScope());
String scope = request.getScope();
log.info(requestTag.getRequestId(), "checkScopeExists called for scope {}.", request);
final AuthContext ctx;
if (this.grpcAuthHelper.isAuthEnabled()) {
ctx = AuthContext.current();
} else {
ctx = null;
}
Supplier<String> stringSupplier = () -> {
String result = this.grpcAuthHelper.checkAuthorization(authorizationResource.ofScope(scope), AuthHandler.Permissions.READ, ctx);
log.debug("Result of authorization for [{}] and READ permission is: [{}]", authorizationResource.ofScopes(), result);
return result;
};
Function<String, CompletableFuture<Controller.ExistsResponse>> scopeFn = delegationToken -> controllerService.getScope(scope, 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, scopeFn, responseObserver, requestTag);
}
use of io.pravega.common.tracing.RequestTag in project pravega by pravega.
the class ControllerServiceImpl method deleteScopeRecursive.
@Override
public void deleteScopeRecursive(ScopeInfo request, StreamObserver<DeleteScopeStatus> responseObserver) {
RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(ControllerService.nextRequestId(), DELETE_SCOPE_RECURSIVE, request.getScope());
log.info(requestTag.getRequestId(), "deleteScopeRecursive called for scope {}.", request.getScope());
authenticateExecuteAndProcessResults(() -> this.grpcAuthHelper.checkAuthorization(authorizationResource.ofScopes(), AuthHandler.Permissions.READ_UPDATE), delegationToken -> controllerService.deleteScopeRecursive(request.getScope(), requestTag.getRequestId()), responseObserver, requestTag);
}
use of io.pravega.common.tracing.RequestTag in project pravega by pravega.
the class ControllerServiceImpl method scale.
@Override
public void scale(ScaleRequest request, StreamObserver<ScaleResponse> responseObserver) {
RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), SCALE_STREAM, request.getStreamInfo().getScope(), request.getStreamInfo().getStream(), String.valueOf(request.getScaleTimestamp()));
log.info(requestTag.getRequestId(), "scale 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.scale(request.getStreamInfo().getScope(), request.getStreamInfo().getStream(), request.getSealedSegmentsList(), request.getNewKeyRangesList().stream().collect(Collectors.toMap(ScaleRequest.KeyRangeEntry::getStart, ScaleRequest.KeyRangeEntry::getEnd)), request.getScaleTimestamp(), requestTag.getRequestId()), responseObserver);
}
Aggregations