use of io.pravega.shared.controller.tracing.RPCTracingTags.GET_SEGMENTS_IMMEDIATELY_FOLLOWING in project pravega by pravega.
the class ControllerServiceImpl method getSegmentsImmediatelyFollowing.
@Override
public void getSegmentsImmediatelyFollowing(SegmentId segmentId, StreamObserver<SuccessorResponse> responseObserver) {
String segment = NameUtils.getQualifiedStreamSegmentName(segmentId.getStreamInfo().getScope(), segmentId.getStreamInfo().getStream(), segmentId.getSegmentId());
RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), GET_SEGMENTS_IMMEDIATELY_FOLLOWING, segment);
log.info(requestTag.getRequestId(), "getSegmentsImmediatelyFollowing called for segment {} ", segment);
authenticateExecuteAndProcessResults(() -> this.grpcAuthHelper.checkAuthorization(authorizationResource.ofStreamInScope(segmentId.getStreamInfo().getScope(), segmentId.getStreamInfo().getStream()), AuthHandler.Permissions.READ), delegationToken -> controllerService.getSegmentsImmediatelyFollowing(segmentId, requestTag.getRequestId()).thenApply(ModelHelper::createSuccessorResponse).thenApply(response -> {
response.setDelegationToken(delegationToken);
return response.build();
}), responseObserver);
}
use of io.pravega.shared.controller.tracing.RPCTracingTags.GET_SEGMENTS_IMMEDIATELY_FOLLOWING in project pravega by pravega.
the class ControllerImpl method getSuccessors.
@Override
public CompletableFuture<StreamSegmentsWithPredecessors> getSuccessors(Segment segment) {
Exceptions.checkNotClosed(closed.get(), this);
final long requestId = requestIdGenerator.get();
long traceId = LoggerHelpers.traceEnter(log, "getSuccessors", segment, requestId);
final CompletableFuture<SuccessorResponse> resultFuture = this.retryConfig.runAsync(() -> {
RPCAsyncCallback<SuccessorResponse> callback = new RPCAsyncCallback<>(requestId, "getSuccessors", segment);
new ControllerClientTagger(client, timeoutMillis).withTag(requestId, GET_SEGMENTS_IMMEDIATELY_FOLLOWING, segment.getScopedName()).getSegmentsImmediatelyFollowing(ModelHelper.decode(segment), callback);
return callback.getFuture();
}, this.executor);
return resultFuture.thenApplyAsync(successors -> {
log.debug(requestId, "Received the following data from the controller {}", successors.getSegmentsList());
Map<SegmentWithRange, List<Long>> result = new HashMap<>();
for (SuccessorResponse.SegmentEntry entry : successors.getSegmentsList()) {
result.put(encode(entry.getSegment()), entry.getValueList());
}
return new StreamSegmentsWithPredecessors(result, successors.getDelegationToken());
}, this.executor).whenComplete((x, e) -> {
if (e != null) {
log.warn(requestId, "getSuccessors of segment {} failed: ", segment.getSegmentId(), e);
}
LoggerHelpers.traceLeave(log, "getSuccessors", traceId, requestId);
});
}
Aggregations