Search in sources :

Example 1 with SegmentMetadataClientFactory

use of io.pravega.client.segment.impl.SegmentMetadataClientFactory in project pravega by pravega.

the class ReaderGroupImpl method unreadBytes.

@Override
public long unreadBytes() {
    @Cleanup StateSynchronizer<ReaderGroupState> synchronizer = createSynchronizer();
    synchronizer.fetchUpdates();
    Optional<Map<Stream, Map<Segment, Long>>> checkPointedPositions = synchronizer.getState().getPositionsForLastCompletedCheckpoint();
    SegmentMetadataClientFactory metaFactory = new SegmentMetadataClientFactoryImpl(controller, connectionFactory);
    if (checkPointedPositions.isPresent()) {
        log.debug("Computing unread bytes based on the last checkPoint position");
        return getUnreadBytes(checkPointedPositions.get(), metaFactory);
    } else {
        log.info("No checkpoints found, using the last known offset to compute unread bytes");
        return getUnreadBytes(synchronizer.getState().getPositions(), metaFactory);
    }
}
Also used : SegmentMetadataClientFactory(io.pravega.client.segment.impl.SegmentMetadataClientFactory) SegmentMetadataClientFactoryImpl(io.pravega.client.segment.impl.SegmentMetadataClientFactoryImpl) Cleanup(lombok.Cleanup) Map(java.util.Map) HashMap(java.util.HashMap) Segment(io.pravega.client.segment.impl.Segment)

Aggregations

Segment (io.pravega.client.segment.impl.Segment)1 SegmentMetadataClientFactory (io.pravega.client.segment.impl.SegmentMetadataClientFactory)1 SegmentMetadataClientFactoryImpl (io.pravega.client.segment.impl.SegmentMetadataClientFactoryImpl)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Cleanup (lombok.Cleanup)1