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/09/19 14:31:08 UTC

[GitHub] [pulsar] gaoran10 commented on a change in pull request #12096: Improve statistical indicators

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



##########
File path: managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
##########
@@ -3964,5 +3966,19 @@ private void updateLastLedgerCreatedTimeAndScheduleRolloverTask() {
                     safeRun(this::rollCurrentLedgerIfFull), this.maximumRolloverTimeMs, TimeUnit.MILLISECONDS);
         }
     }
+    public CompletableFuture<LedgerEntry> getLastEntry() {
+        if (lastConfirmedEntry.getEntryId() == -1){
+            return new CompletableFuture<>();

Review comment:
       The new CompletableFuture is not complete. You could use this `CompletableFuture.completedFuture(null)`.

##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
##########
@@ -1248,6 +1252,21 @@ public void openLedgerComplete(ManagedLedger ledger, Object ctx) {
                                             topics.remove(topic, topicFuture);
                                         });
                                     } else {
+                                        ManagedLedgerImpl managedLedger =
+                                                (ManagedLedgerImpl) persistentTopic.getManagedLedger();
+                                        CompletableFuture<LedgerEntry> entryFuture = managedLedger.getLastEntry();
+                                        entryFuture.whenCompleteAsync((ledgerEntry, e)->{
+                                            if (e != null) {
+                                                log.error("fetch lastEntry error---{}", e.getMessage());

Review comment:
       ```suggestion
                                                   log.error("Failed to get last entry {}.", managedLedger.getLastConfirmedEntry(), e);
   ```

##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
##########
@@ -1248,6 +1252,21 @@ public void openLedgerComplete(ManagedLedger ledger, Object ctx) {
                                             topics.remove(topic, topicFuture);
                                         });
                                     } else {
+                                        ManagedLedgerImpl managedLedger =
+                                                (ManagedLedgerImpl) persistentTopic.getManagedLedger();
+                                        CompletableFuture<LedgerEntry> entryFuture = managedLedger.getLastEntry();
+                                        entryFuture.whenCompleteAsync((ledgerEntry, e)->{
+                                            if (e != null) {
+                                                log.error("fetch lastEntry error---{}", e.getMessage());

Review comment:
       If message count recovery failed, the topic creation should fail.




-- 
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