use of io.pravega.client.batch.StreamSegmentsIterator in project pravega by pravega.
the class BatchClientFactoryImpl method getStreamSegmentInfo.
private StreamSegmentsIterator getStreamSegmentInfo(final Stream stream, final StreamCut startStreamCut, final StreamCut endStreamCut) {
log.debug("Start stream cut: {}, End stream cut: {}", startStreamCut, endStreamCut);
StreamSegmentsInfoImpl.validateStreamCuts(startStreamCut, endStreamCut);
StreamSegmentSuccessors segments = getAndHandleExceptions(controller.getSegments(startStreamCut, endStreamCut), RuntimeException::new);
final SortedSet<Segment> segmentSet = new TreeSet<>(segments.getSegments());
final DelegationTokenProvider tokenProvider = DelegationTokenProviderFactory.create(controller, stream.getScope(), stream.getStreamName(), AccessOperation.READ);
log.debug("List of Segments between the start and end stream cuts : {}", segmentSet);
val futures = segmentSet.stream().map(s -> getSegmentRange(s, startStreamCut, endStreamCut, tokenProvider)).collect(Collectors.toList());
List<SegmentRange> results = Futures.getThrowingException(Futures.allOfWithResults(futures));
return StreamSegmentsInfoImpl.builder().segmentRangeIterator(results.iterator()).startStreamCut(startStreamCut).endStreamCut(endStreamCut).build();
}
Aggregations