Search in sources :

Example 1 with StreamSegmentsIterator

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();
}
Also used : lombok.val(lombok.val) Segment(io.pravega.client.segment.impl.Segment) StreamCut(io.pravega.client.stream.StreamCut) SortedSet(java.util.SortedSet) ConnectionFactory(io.pravega.client.connection.impl.ConnectionFactory) SegmentMetadataClientFactoryImpl(io.pravega.client.segment.impl.SegmentMetadataClientFactoryImpl) CompletableFuture(java.util.concurrent.CompletableFuture) ConnectionPoolImpl(io.pravega.client.connection.impl.ConnectionPoolImpl) SegmentMetadataClientFactory(io.pravega.client.segment.impl.SegmentMetadataClientFactory) TreeSet(java.util.TreeSet) StreamCutHelper(io.pravega.client.admin.impl.StreamCutHelper) SegmentRange(io.pravega.client.batch.SegmentRange) Stream(io.pravega.client.stream.Stream) AccessOperation(io.pravega.shared.security.auth.AccessOperation) SegmentInputStreamFactoryImpl(io.pravega.client.segment.impl.SegmentInputStreamFactoryImpl) BatchClientFactory(io.pravega.client.BatchClientFactory) Serializer(io.pravega.client.stream.Serializer) SegmentInputStreamFactory(io.pravega.client.segment.impl.SegmentInputStreamFactory) Futures.getAndHandleExceptions(io.pravega.common.concurrent.Futures.getAndHandleExceptions) ConnectionPool(io.pravega.client.connection.impl.ConnectionPool) SegmentIterator(io.pravega.client.batch.SegmentIterator) lombok.val(lombok.val) SegmentInfo(io.pravega.client.segment.impl.SegmentInfo) DelegationTokenProviderFactory(io.pravega.client.security.auth.DelegationTokenProviderFactory) Collectors(java.util.stream.Collectors) Beta(com.google.common.annotations.Beta) DelegationTokenProvider(io.pravega.client.security.auth.DelegationTokenProvider) SegmentMetadataClient(io.pravega.client.segment.impl.SegmentMetadataClient) StreamSegmentSuccessors(io.pravega.client.stream.impl.StreamSegmentSuccessors) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Optional(java.util.Optional) Preconditions(com.google.common.base.Preconditions) StreamSegmentsIterator(io.pravega.client.batch.StreamSegmentsIterator) Controller(io.pravega.client.control.impl.Controller) Futures(io.pravega.common.concurrent.Futures) ClientConfig(io.pravega.client.ClientConfig) SegmentRange(io.pravega.client.batch.SegmentRange) StreamSegmentSuccessors(io.pravega.client.stream.impl.StreamSegmentSuccessors) TreeSet(java.util.TreeSet) Segment(io.pravega.client.segment.impl.Segment) DelegationTokenProvider(io.pravega.client.security.auth.DelegationTokenProvider)

Aggregations

Beta (com.google.common.annotations.Beta)1 Preconditions (com.google.common.base.Preconditions)1 BatchClientFactory (io.pravega.client.BatchClientFactory)1 ClientConfig (io.pravega.client.ClientConfig)1 StreamCutHelper (io.pravega.client.admin.impl.StreamCutHelper)1 SegmentIterator (io.pravega.client.batch.SegmentIterator)1 SegmentRange (io.pravega.client.batch.SegmentRange)1 StreamSegmentsIterator (io.pravega.client.batch.StreamSegmentsIterator)1 ConnectionFactory (io.pravega.client.connection.impl.ConnectionFactory)1 ConnectionPool (io.pravega.client.connection.impl.ConnectionPool)1 ConnectionPoolImpl (io.pravega.client.connection.impl.ConnectionPoolImpl)1 Controller (io.pravega.client.control.impl.Controller)1 DelegationTokenProvider (io.pravega.client.security.auth.DelegationTokenProvider)1 DelegationTokenProviderFactory (io.pravega.client.security.auth.DelegationTokenProviderFactory)1 Segment (io.pravega.client.segment.impl.Segment)1 SegmentInfo (io.pravega.client.segment.impl.SegmentInfo)1 SegmentInputStreamFactory (io.pravega.client.segment.impl.SegmentInputStreamFactory)1 SegmentInputStreamFactoryImpl (io.pravega.client.segment.impl.SegmentInputStreamFactoryImpl)1 SegmentMetadataClient (io.pravega.client.segment.impl.SegmentMetadataClient)1 SegmentMetadataClientFactory (io.pravega.client.segment.impl.SegmentMetadataClientFactory)1