use of io.pravega.segmentstore.storage.metadata.MetadataTransaction in project pravega by pravega.
the class SystemJournal method validateSegment.
/**
* Validate that all information for given segment in given snapshot exists in transaction.
*/
private CompletableFuture<Void> validateSegment(MetadataTransaction txn, String segmentName) {
return txn.get(segmentName).thenComposeAsync(m -> {
val segmentMetadata = (SegmentMetadata) m;
Preconditions.checkState(null != segmentMetadata, "Segment metadata must not be null.");
val chunkName = new AtomicReference<>(segmentMetadata.getFirstChunk());
return Futures.loop(() -> chunkName.get() != null, () -> txn.get(chunkName.get()).thenAcceptAsync(mm -> {
Preconditions.checkState(null != mm, "Chunk metadata must not be null.");
val chunkMetadata = (ChunkMetadata) mm;
chunkName.set(chunkMetadata.getNextChunk());
}, executor), executor);
}, executor);
}
Aggregations