use of io.pravega.common.tracing.RequestTag in project pravega by pravega.
the class ControllerServiceImpl method listSubscribers.
@Override
public void listSubscribers(StreamInfo request, StreamObserver<SubscribersResponse> responseObserver) {
String scope = request.getScope();
String stream = request.getStream();
RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), LIST_SUBSCRIBERS, scope, stream);
log.info(requestTag.getRequestId(), "listSubscribers called for stream {}/{}.", scope, stream);
authenticateExecuteAndProcessResults(() -> this.grpcAuthHelper.checkAuthorization(authorizationResource.ofStreamInScope(scope, stream), AuthHandler.Permissions.READ_UPDATE), delegationToken -> controllerService.listSubscribers(scope, stream, requestTag.getRequestId()), responseObserver, requestTag);
}
use of io.pravega.common.tracing.RequestTag in project pravega by pravega.
the class ControllerServiceImpl method getEpochSegments.
@Override
public void getEpochSegments(GetEpochSegmentsRequest request, StreamObserver<SegmentRanges> responseObserver) {
RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), GET_EPOCH_SEGMENTS, request.getStreamInfo().getScope(), request.getStreamInfo().getStream(), Integer.toString(request.getEpoch()));
log.info(requestTag.getRequestId(), "getEpochSegments called for stream {}/{} and epoch {}", request.getStreamInfo().getScope(), request.getStreamInfo().getStream(), request.getEpoch());
authenticateExecuteAndProcessResults(() -> this.grpcAuthHelper.checkAuthorizationAndCreateToken(authorizationResource.ofStreamInScope(request.getStreamInfo().getScope(), request.getStreamInfo().getStream()), AuthHandler.Permissions.READ_UPDATE), delegationToken -> {
logIfEmpty(delegationToken, "getEpochSegments", request.getStreamInfo().getScope(), request.getStreamInfo().getStream());
return controllerService.getEpochSegments(request.getStreamInfo().getScope(), request.getStreamInfo().getStream(), request.getEpoch(), requestTag.getRequestId()).thenApply(segmentRanges -> SegmentRanges.newBuilder().addAllSegmentRanges(segmentRanges).setDelegationToken(delegationToken).build());
}, responseObserver, requestTag);
}
use of io.pravega.common.tracing.RequestTag in project pravega by pravega.
the class ControllerServiceImpl method getSegments.
@Override
public void getSegments(GetSegmentsRequest request, StreamObserver<SegmentsAtTime> responseObserver) {
RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), GET_SEGMENTS, request.getStreamInfo().getScope(), request.getStreamInfo().getStream());
final StreamInfo streamInfo = request.getStreamInfo();
final String scope = streamInfo.getScope();
final String stream = streamInfo.getStream();
log.debug(requestTag.getRequestId(), "getSegments called for stream " + scope + "/" + stream);
// Older clients will not set requestPermissions, so it'll be set as "". Newer clients will set it as `NONE`.
// For backward compatibility, this operation returns a delegation token for older clients along with the
// segments. For newer clients, it doesn't.
final boolean shouldReturnDelegationToken = !streamInfo.getAccessOperation().equals(StreamInfo.AccessOperation.NONE);
authenticateExecuteAndProcessResults(() -> {
if (shouldReturnDelegationToken) {
// by this method for both reads and writes.
return this.grpcAuthHelper.checkAuthorizationAndCreateToken(authorizationResource.ofStreamInScope(scope, stream), AuthHandler.Permissions.READ_UPDATE);
} else {
return this.grpcAuthHelper.checkAuthorization(authorizationResource.ofStreamInScope(scope, stream), AuthHandler.Permissions.READ);
}
}, authorizationResult -> {
logIfEmpty(authorizationResult, "getSegments", scope, stream);
return controllerService.getSegmentsAtHead(scope, stream, requestTag.getRequestId()).thenApply(segments -> {
SegmentsAtTime.Builder builder = SegmentsAtTime.newBuilder();
if (shouldReturnDelegationToken) {
builder.setDelegationToken(authorizationResult);
}
for (Entry<SegmentId, Long> entry : segments.entrySet()) {
builder.addSegments(SegmentLocation.newBuilder().setSegmentId(entry.getKey()).setOffset(entry.getValue()).build());
}
return builder.build();
});
}, responseObserver);
}
use of io.pravega.common.tracing.RequestTag in project pravega by pravega.
the class ControllerServiceImpl method isStreamCutValid.
@Override
public void isStreamCutValid(Controller.StreamCut request, StreamObserver<Controller.StreamCutValidityResponse> responseObserver) {
RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), IS_STREAMCUT_VALID, request.getStreamInfo().getScope(), request.getStreamInfo().getStream());
log.info(requestTag.getRequestId(), "isStreamCutValid called for stream {}/{} streamcut {}.", request.getStreamInfo().getScope(), request.getStreamInfo().getStream(), request.getCutMap());
authenticateExecuteAndProcessResults(() -> this.grpcAuthHelper.checkAuthorizationAndCreateToken(authorizationResource.ofStreamInScope(request.getStreamInfo().getScope(), request.getStreamInfo().getStream()), AuthHandler.Permissions.READ), delegationToken -> controllerService.isStreamCutValid(request.getStreamInfo().getScope(), request.getStreamInfo().getStream(), request.getCutMap(), requestTag.getRequestId()).thenApply(bRes -> Controller.StreamCutValidityResponse.newBuilder().setResponse(bRes).build()), responseObserver);
}
use of io.pravega.common.tracing.RequestTag in project pravega by pravega.
the class ControllerServiceImpl method createReaderGroup.
@Override
public void createReaderGroup(ReaderGroupConfiguration request, StreamObserver<CreateReaderGroupResponse> responseObserver) {
String scope = request.getScope();
String rgName = request.getReaderGroupName();
RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), CREATE_READER_GROUP, scope, rgName);
log.info(requestTag.getRequestId(), "createReaderGroup 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.createReaderGroup(scope, rgName, ModelHelper.encode(request), System.currentTimeMillis(), requestTag.getRequestId()), responseObserver, requestTag);
}
Aggregations