coderzc commented on code in PR #18420:
URL: https://github.com/apache/pulsar/pull/18420#discussion_r1051898668
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/ImmutableBucket.java:
##########
@@ -54,7 +65,28 @@ CompletableFuture<List<DelayedIndex>>
asyncLoadNextBucketSnapshotEntry(boolean i
final long bucketId = getAndUpdateBucketId();
CompletableFuture<Integer> loadMetaDataFuture = new
CompletableFuture<>();
if (isRecover) {
- // TODO Recover bucket snapshot
+ final long cutoffTime = cutoffTimeSupplier.get();
+ // Load Metadata of bucket snapshot
+
bucketSnapshotStorage.getBucketSnapshotMetadata(bucketId).thenAccept(snapshotMetadata
-> {
+
List<DelayedMessageIndexBucketSnapshotFormat.SnapshotSegmentMetadata>
metadataList =
+ snapshotMetadata.getMetadataListList();
+
+ // Skip all already reach schedule time snapshot segments
+ int nextSnapshotEntryIndex = 0;
+ while (nextSnapshotEntryIndex < metadataList.size()
+ &&
metadataList.get(nextSnapshotEntryIndex).getMaxScheduleTimestamp() <=
cutoffTime) {
+ nextSnapshotEntryIndex++;
+ }
+
+ this.setLastSegmentEntryId(metadataList.size());
+
this.recoverDelayedIndexBitMapAndNumber(nextSnapshotEntryIndex, metadataList);
+
+ int nextSegmentEntryId = nextSnapshotEntryIndex + 1;
+ loadMetaDataFuture.complete(nextSegmentEntryId);
+ }).exceptionally(ex -> {
+ loadMetaDataFuture.completeExceptionally(ex);
Review Comment:
It seems that he still needs `loadMetaDataFuture`, but I improve the code,
make the code easy to read
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]