use of io.pravega.client.stream.impl.StreamSegments in project pravega by pravega.
the class ControllerImpl method getEpochSegments.
@Override
public CompletableFuture<StreamSegments> getEpochSegments(final String scope, final String stream, int epoch) {
Exceptions.checkNotClosed(closed.get(), this);
Exceptions.checkNotNullOrEmpty(scope, "scope");
Exceptions.checkNotNullOrEmpty(stream, "stream");
Exceptions.checkArgument(epoch >= 0, "epoch", "Should be a positive integer");
final long requestId = requestIdGenerator.get();
long traceId = LoggerHelpers.traceEnter(log, "getEpochSegments", scope, stream, epoch, requestId);
final CompletableFuture<SegmentRanges> result = this.retryConfig.runAsync(() -> {
RPCAsyncCallback<SegmentRanges> callback = new RPCAsyncCallback<>(traceId, "getEpochSegments", scope, stream, Integer.toString(epoch));
GetEpochSegmentsRequest request = GetEpochSegmentsRequest.newBuilder().setStreamInfo(ModelHelper.createStreamInfo(scope, stream)).setEpoch(epoch).build();
new ControllerClientTagger(client, timeoutMillis).withTag(requestId, GET_EPOCH_SEGMENTS, scope, stream, Integer.toString(epoch)).getEpochSegments(request, callback);
return callback.getFuture();
}, this.executor);
return result.thenApplyAsync(x -> getStreamSegments(x, requestId), this.executor).whenComplete((x, e) -> {
if (e != null) {
log.warn(requestId, "getEpochSegments for {}/{} with epoch {} failed: ", scope, stream, epoch, e);
}
LoggerHelpers.traceLeave(log, "getEpochSegments", traceId, requestId);
});
}
use of io.pravega.client.stream.impl.StreamSegments in project pravega by pravega.
the class ControllerImpl method convert.
private TxnSegments convert(CreateTxnResponse response) {
NavigableMap<Double, SegmentWithRange> rangeMap = new TreeMap<>();
for (SegmentRange r : response.getActiveSegmentsList()) {
Preconditions.checkState(r.getMinKey() <= r.getMaxKey());
rangeMap.put(r.getMaxKey(), new SegmentWithRange(encode(r.getSegmentId()), r.getMinKey(), r.getMaxKey()));
}
StreamSegments segments = new StreamSegments(rangeMap);
return new TxnSegments(segments, encode(response.getTxnId()));
}
use of io.pravega.client.stream.impl.StreamSegments in project pravega by pravega.
the class ControllerImpl method getStreamSegments.
private StreamSegments getStreamSegments(final SegmentRanges ranges, long requestId) {
log.debug(requestId, "Received the following data from the controller {}", ranges.getSegmentRangesList());
NavigableMap<Double, SegmentWithRange> rangeMap = new TreeMap<>();
for (SegmentRange r : ranges.getSegmentRangesList()) {
Preconditions.checkState(r.getMinKey() <= r.getMaxKey(), "Min keyrange %s was not less than maximum keyRange %s for segment %s", r.getMinKey(), r.getMaxKey(), r.getSegmentId());
rangeMap.put(r.getMaxKey(), new SegmentWithRange(encode(r.getSegmentId()), r.getMinKey(), r.getMaxKey()));
}
return new StreamSegments(rangeMap);
}
Aggregations