Skip to content

Commit

Permalink
improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
coderzc committed Dec 19, 2022
1 parent b223ed4 commit 9e0aed6
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ private CompletableFuture<List<DelayedIndex>> asyncLoadNextBucketSnapshotEntry(b

return snapshotCreateFuture.thenCompose(__ -> {
final long bucketId = getAndUpdateBucketId();
CompletableFuture<Integer> loadMetaDataFuture = new CompletableFuture<>();
final CompletableFuture<Integer> loadMetaDataFuture;
if (isRecover) {
final long cutoffTime = cutoffTimeSupplier.get();
// Load Metadata of bucket snapshot
bucketSnapshotStorage.getBucketSnapshotMetadata(bucketId).thenAccept(snapshotMetadata -> {
loadMetaDataFuture = bucketSnapshotStorage.getBucketSnapshotMetadata(bucketId)
.thenApply(snapshotMetadata -> {
List<DelayedMessageIndexBucketSnapshotFormat.SnapshotSegmentMetadata> metadataList =
snapshotMetadata.getMetadataListList();

Expand All @@ -81,14 +82,10 @@ private CompletableFuture<List<DelayedIndex>> asyncLoadNextBucketSnapshotEntry(b
this.setLastSegmentEntryId(metadataList.size());
this.recoverDelayedIndexBitMapAndNumber(nextSnapshotEntryIndex, metadataList);

int nextSegmentEntryId = nextSnapshotEntryIndex + 1;
loadMetaDataFuture.complete(nextSegmentEntryId);
}).exceptionally(ex -> {
loadMetaDataFuture.completeExceptionally(ex);
return null;
return nextSnapshotEntryIndex + 1;
});
} else {
loadMetaDataFuture.complete(currentSegmentEntryId + 1);
loadMetaDataFuture = CompletableFuture.completedFuture(currentSegmentEntryId + 1);
}

return loadMetaDataFuture.thenCompose(nextSegmentEntryId -> {
Expand Down

0 comments on commit 9e0aed6

Please sign in to comment.