use of io.pravega.common.util.AsyncMap in project pravega by pravega.
the class SegmentStateStore method get.
// endregion
// region AsyncMap implementation
@Override
public CompletableFuture<SegmentState> get(String segmentName, Duration timeout) {
String stateSegment = StreamSegmentNameUtils.getStateSegmentName(segmentName);
TimeoutTimer timer = new TimeoutTimer(timeout);
return this.storage.getStreamSegmentInfo(stateSegment, timer.getRemaining()).thenComposeAsync(sp -> {
if (sp.getLength() == 0) {
// Empty state files are treated the same as if they didn't exist.
return CompletableFuture.completedFuture(null);
} else {
return readSegmentState(sp, timer.getRemaining());
}
}, this.executor).exceptionally(this::handleSegmentNotExistsException);
}
Aggregations