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/08/05 07:33:30 UTC

[GitHub] [pulsar] Jason918 commented on a change in pull request #11517: [Issue 11412] Add shutdownGracefully for ManagedLedgerFactoryImpl

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



##########
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:
       Great idea, shutdownAsync is more flexible. 




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