You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by fr...@apache.org on 2016/11/21 14:17:15 UTC

svn commit: r1770690 - /jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/Scheduler.java

Author: frm
Date: Mon Nov 21 14:17:15 2016
New Revision: 1770690

URL: http://svn.apache.org/viewvc?rev=1770690&view=rev
Log:
OAK-5135 - Force the Scheduler to shut down if needed

If the Scheduler is not able to shut down gracefully after a consistent amount
of time, ask the underlying implementation to force the shutdown. Print an
ERROR message only if the forced shutdown fails.

Modified:
    jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/Scheduler.java

Modified: jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/Scheduler.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/Scheduler.java?rev=1770690&r1=1770689&r2=1770690&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/Scheduler.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/Scheduler.java Mon Nov 21 14:17:15 2016
@@ -123,18 +123,23 @@ public class Scheduler implements Closea
     }
 
     /**
-     * Close this scheduler and wait 5 second for currently executing tasks to finish.
-     * Logs a warning if not all tasks finished executing after 5 seconds.
+     * Close this scheduler.
      * @see ScheduledExecutorService#shutdown()
      */
     @Override
     public void close() {
         try {
             executor.shutdown();
-            if (executor.awaitTermination(5, SECONDS)) {
+            if (executor.awaitTermination(60, SECONDS)) {
                 LOG.debug("The scheduler {} was successfully shut down", name);
             } else {
-                LOG.warn("The scheduler {} takes too long to shutdown", name);
+                LOG.warn("The scheduler {} takes too long to shut down, forcing termination", name);
+                executor.shutdownNow();
+                if (executor.awaitTermination(60, SECONDS)) {
+                    LOG.debug("The scheduler {} was successfully shut down", name);
+                } else {
+                    LOG.error("The scheduler {} takes too long to shutdown", name);
+                }
             }
         } catch (InterruptedException e) {
             LOG.warn("Interrupt while shutting down he scheduler {}", name, e);