You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by si...@apache.org on 2018/09/04 19:30:00 UTC

[bookkeeper] branch master updated: Fix EntryLoggerAllocator.stop

This is an automated email from the ASF dual-hosted git repository.

sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new af9d4c3  Fix EntryLoggerAllocator.stop
af9d4c3 is described below

commit af9d4c312ef1640fbbfb6765943c9a83242a4f37
Author: cguttapalem <cg...@salesforce.com>
AuthorDate: Tue Sep 4 12:29:51 2018 -0700

    Fix EntryLoggerAllocator.stop
    
    Descriptions of the changes in this PR:
    
    - make sure EntryLoggerAllocator.stop terminates pending allocatorExecutor's task.
    Otherwise tests would flap, since even after EntryLoggerAllocator.stop, there is
    possibility of new entrylog creation, which is not expected.
    
    Author: cguttapalem <cg...@salesforce.com>
    
    Reviewers: Andrey Yegorov <None>, Enrico Olivelli <eo...@gmail.com>, Sijie Guo <si...@apache.org>
    
    This closes #1627 from reddycharan/entryalocshut
---
 .../org/apache/bookkeeper/bookie/EntryLoggerAllocator.java   | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLoggerAllocator.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLoggerAllocator.java
index 10e7715..3ddd8e2 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLoggerAllocator.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLoggerAllocator.java
@@ -40,6 +40,8 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
 import lombok.extern.slf4j.Slf4j;
 import org.apache.bookkeeper.bookie.EntryLogger.BufferedLogChannel;
 import org.apache.bookkeeper.conf.ServerConfiguration;
@@ -203,6 +205,16 @@ class EntryLoggerAllocator {
     void stop() {
         // wait until the preallocation finished.
         allocatorExecutor.shutdown();
+        try {
+            if (!allocatorExecutor.awaitTermination(5, TimeUnit.SECONDS)) {
+                log.warn("Timedout while awaiting for allocatorExecutor's termination, so force shuttingdown");
+            }
+        } catch (InterruptedException e) {
+            log.warn("Got InterruptedException while awaiting termination of allocatorExecutor, so force shuttingdown");
+            Thread.currentThread().interrupt();
+        }
+        allocatorExecutor.shutdownNow();
+
         log.info("Stopped entry logger preallocator.");
     }