Search in sources :

Example 1 with RequestTag

use of io.pravega.common.tracing.RequestTag in project pravega by pravega.

the class ControllerServiceImpl method updateStream.

@Override
public void updateStream(StreamConfig request, StreamObserver<UpdateStreamStatus> responseObserver) {
    String scope = request.getStreamInfo().getScope();
    String stream = request.getStreamInfo().getStream();
    RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), UPDATE_STREAM, scope, stream);
    log.info(requestTag.getRequestId(), "updateStream called for stream {}/{}.", scope, stream);
    Supplier<String> authorizationSupplier = () -> this.grpcAuthHelper.checkAuthorization(StreamAuthParams.toResourceString(scope, stream), AuthHandler.Permissions.READ_UPDATE);
    authenticateExecuteAndProcessResults(authorizationSupplier, authorizationResult -> controllerService.updateStream(scope, stream, ModelHelper.encode(request), requestTag.getRequestId()), responseObserver, requestTag);
}
Also used : RequestTag(io.pravega.common.tracing.RequestTag)

Example 2 with RequestTag

use of io.pravega.common.tracing.RequestTag in project pravega by pravega.

the class ControllerServiceImpl method createStream.

@Override
public void createStream(StreamConfig request, StreamObserver<CreateStreamStatus> responseObserver) {
    String scope = request.getStreamInfo().getScope();
    String stream = request.getStreamInfo().getStream();
    RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), CREATE_STREAM, scope, stream);
    log.info(requestTag.getRequestId(), "createStream called for stream {}/{}.", scope, stream);
    StreamAuthParams streamAuthParams = new StreamAuthParams(scope, stream, this.isRGStreamWritesWithReadPermEnabled);
    AuthHandler.Permissions requiredPermission = streamAuthParams.requiredPermissionForWrites();
    log.debug(requestTag.getRequestId(), "Creating stream : requiredPermission is [{}], for scope [{}] and stream [{}]", requiredPermission, scope, stream);
    authenticateExecuteAndProcessResults(() -> this.grpcAuthHelper.checkAuthorizationAndCreateToken(authorizationResource.ofStreamsInScope(scope), requiredPermission), delegationToken -> controllerService.createStream(scope, stream, ModelHelper.encode(request), System.currentTimeMillis(), requestTag.getRequestId()), responseObserver, requestTag);
}
Also used : AuthHandler(io.pravega.auth.AuthHandler) StreamAuthParams(io.pravega.controller.server.security.auth.StreamAuthParams) RequestTag(io.pravega.common.tracing.RequestTag)

Example 3 with RequestTag

use of io.pravega.common.tracing.RequestTag in project pravega by pravega.

the class ControllerServiceImpl method getURI.

@Override
public void getURI(SegmentId request, StreamObserver<NodeUri> responseObserver) {
    String segment = NameUtils.getQualifiedStreamSegmentName(request.getStreamInfo().getScope(), request.getStreamInfo().getStream(), request.getSegmentId());
    RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), GET_URI, segment);
    log.info(requestTag.getRequestId(), "getURI called for segment {}.", segment);
    authenticateExecuteAndProcessResults(() -> this.grpcAuthHelper.checkAuthorization(StreamAuthParams.toResourceString(request.getStreamInfo().getScope(), request.getStreamInfo().getStream()), AuthHandler.Permissions.READ), delegationToken -> controllerService.getURI(request), responseObserver);
}
Also used : RequestTag(io.pravega.common.tracing.RequestTag)

Example 4 with RequestTag

use of io.pravega.common.tracing.RequestTag in project pravega by pravega.

the class ControllerServiceImpl method getCurrentSegmentsKeyValueTable.

@Override
public void getCurrentSegmentsKeyValueTable(KeyValueTableInfo request, StreamObserver<SegmentRanges> responseObserver) {
    RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), GET_CURRENT_SEGMENTS_KEY_VALUE_TABLE, request.getScope(), request.getKvtName());
    log.info(requestTag.getRequestId(), "getCurrentSegmentsKeyValueTable called for kvtable {}/{}.", request.getScope(), request.getKvtName());
    authenticateExecuteAndProcessResults(() -> this.grpcAuthHelper.checkAuthorizationAndCreateToken(authorizationResource.ofKeyValueTableInScope(request.getScope(), request.getKvtName()), AuthHandler.Permissions.READ_UPDATE), delegationToken -> {
        logIfEmpty(delegationToken, "getCurrentSegmentsKeyValueTable", request.getScope(), request.getKvtName());
        return controllerService.getCurrentSegmentsKeyValueTable(request.getScope(), request.getKvtName(), requestTag.getRequestId()).thenApply(segmentRanges -> SegmentRanges.newBuilder().addAllSegmentRanges(segmentRanges).setDelegationToken(delegationToken).build());
    }, responseObserver);
}
Also used : RequestTag(io.pravega.common.tracing.RequestTag)

Example 5 with RequestTag

use of io.pravega.common.tracing.RequestTag in project pravega by pravega.

the class ControllerServiceImpl method noteTimestampFromWriter.

// region watermarking apis
@Override
public void noteTimestampFromWriter(Controller.TimestampFromWriter request, StreamObserver<Controller.TimestampResponse> responseObserver) {
    StreamInfo streamInfo = request.getPosition().getStreamInfo();
    RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), NOTE_TIMESTAMP_FROM_WRITER, streamInfo.getScope(), streamInfo.getStream(), request.getWriter());
    log.info(requestTag.getRequestId(), "noteWriterMark called for stream {}/{}, writer={} time={}", streamInfo.getScope(), streamInfo.getStream(), request.getWriter(), request.getTimestamp());
    authenticateExecuteAndProcessResults(() -> this.grpcAuthHelper.checkAuthorization(authorizationResource.ofStreamInScope(streamInfo.getScope(), streamInfo.getStream()), AuthHandler.Permissions.READ_UPDATE), delegationToken -> controllerService.noteTimestampFromWriter(streamInfo.getScope(), streamInfo.getStream(), request.getWriter(), request.getTimestamp(), request.getPosition().getCutMap(), requestTag.getRequestId()), responseObserver, requestTag);
}
Also used : StreamInfo(io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo) RequestTag(io.pravega.common.tracing.RequestTag)

Aggregations

RequestTag (io.pravega.common.tracing.RequestTag)43 AuthHandler (io.pravega.auth.AuthHandler)16 UUID (java.util.UUID)16 StreamInfo (io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo)15 StreamAuthParams (io.pravega.controller.server.security.auth.StreamAuthParams)13 VisibleForTesting (com.google.common.annotations.VisibleForTesting)12 Strings (com.google.common.base.Strings)12 Throwables (com.google.common.base.Throwables)12 ImmutableMap (com.google.common.collect.ImmutableMap)12 Status (io.grpc.Status)12 StreamObserver (io.grpc.stub.StreamObserver)12 AuthenticationException (io.pravega.auth.AuthenticationException)12 AuthorizationException (io.pravega.auth.AuthorizationException)12 ModelHelper (io.pravega.client.control.impl.ModelHelper)12 ModelHelper.decode (io.pravega.client.control.impl.ModelHelper.decode)12 Exceptions (io.pravega.common.Exceptions)12 RequestTracker (io.pravega.common.tracing.RequestTracker)12 TagLogger (io.pravega.common.tracing.TagLogger)12 ControllerService (io.pravega.controller.server.ControllerService)12 GrpcAuthHelper (io.pravega.controller.server.security.auth.GrpcAuthHelper)12