Search in sources :

Example 1 with StreamCutRangeResponse

use of io.pravega.controller.stream.api.grpc.v1.Controller.StreamCutRangeResponse in project pravega by pravega.

the class ControllerImpl method getSegmentsBetweenStreamCuts.

private CompletableFuture<StreamSegmentSuccessors> getSegmentsBetweenStreamCuts(final StreamCut fromStreamCut, final StreamCut toStreamCut, long requestId) {
    Exceptions.checkNotClosed(closed.get(), this);
    final Stream stream = fromStreamCut.asImpl().getStream();
    long traceId = LoggerHelpers.traceEnter(log, "getSegments", stream);
    final CompletableFuture<StreamCutRangeResponse> resultFuture = this.retryConfig.runAsync(() -> {
        RPCAsyncCallback<StreamCutRangeResponse> callback = new RPCAsyncCallback<>(traceId, GET_SEGMENTS_BETWEEN_STREAM_CUTS);
        new ControllerClientTagger(client, timeoutMillis).withTag(requestId, GET_SUCCESSORS_FROM_CUT, stream.getScope(), stream.getStreamName()).getSegmentsBetween(ModelHelper.decode(stream.getScope(), stream.getStreamName(), getStreamCutMap(fromStreamCut), getStreamCutMap(toStreamCut)), callback);
        return callback.getFuture();
    }, this.executor);
    return resultFuture.thenApplyAsync(response -> {
        log.debug(requestId, "Received the following data from the controller {}", response.getSegmentsList());
        return new StreamSegmentSuccessors(response.getSegmentsList().stream().map(ModelHelper::encode).collect(Collectors.toSet()), response.getDelegationToken());
    }, this.executor);
}
Also used : StreamCutRangeResponse(io.pravega.controller.stream.api.grpc.v1.Controller.StreamCutRangeResponse) StreamSegmentSuccessors(io.pravega.client.stream.impl.StreamSegmentSuccessors) Stream(io.pravega.client.stream.Stream)

Aggregations

Stream (io.pravega.client.stream.Stream)1 StreamSegmentSuccessors (io.pravega.client.stream.impl.StreamSegmentSuccessors)1 StreamCutRangeResponse (io.pravega.controller.stream.api.grpc.v1.Controller.StreamCutRangeResponse)1