You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/11/07 15:42:44 UTC

[GitHub] [pulsar] gaoran10 commented on a change in pull request #12523: add a metric to get earliest time in the backlog

gaoran10 commented on a change in pull request #12523:
URL: https://github.com/apache/pulsar/pull/12523#discussion_r744277301



##########
File path: managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
##########
@@ -1141,6 +1144,53 @@ public long getEstimatedBacklogSize() {
         }
     }
 
+    @Override
+    public long getEarliestMessagePublishTimeInBacklog() {
+        PositionImpl pos = getMarkDeletePositionOfSlowestConsumer();
+
+        return getEarliestMessagePublishTimeOfPos(pos);
+    }
+
+    public long getEarliestMessagePublishTimeOfPos(PositionImpl pos) {
+        if (pos == null) {
+            return 0L;
+        }
+        PositionImpl nextPos = getNextValidPosition(pos);
+
+        CompletableFuture<Long> future = new CompletableFuture<>();
+        asyncReadEntry(nextPos, new ReadEntryCallback() {
+            @Override
+            public void readEntryComplete(Entry entry, Object ctx) {
+                ByteBuf metadataAndPayload = entry.getDataBuffer();

Review comment:
       It seems that after getting the timestamp we could release the ByteBuf data.




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org