codelipenghui commented on a change in pull request #11517:
URL: https://github.com/apache/pulsar/pull/11517#discussion_r682653388



##########
File path: 
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerFactoryImpl.java
##########
@@ -472,8 +484,87 @@ void close(ManagedLedger ledger) {
         entryCacheManager.removeEntryCache(ledger.getName());
     }
 
+    @Override
+    public void shutdownGracefully() throws ManagedLedgerException, 
InterruptedException {
+        if (closed) {
+            throw new 
ManagedLedgerException.ManagedLedgerFactoryClosedException();
+        }
+        closed = true;
+
+        statsTask.cancel(true);
+        flushCursorsTask.cancel(true);
+
+        int closedLedgerNum = 0;
+
+        while (!ledgers.isEmpty()) { //use while loop for ledgers added during 
shutdown.
+            List<String> ledgerNames = new ArrayList<>(this.ledgers.keySet());
+            int numLedgers = ledgerNames.size();
+            final CountDownLatch latch = new CountDownLatch(numLedgers);

Review comment:
       How about make the `shutdownGracefully()` asynchronously?




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


Reply via email to