flume-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject git commit: FLUME-1296: Lifecycle supervisor should check if the monitor service is still running before supervising
Date Mon, 10 Dec 2012 20:38:38 GMT
Updated Branches:
  refs/heads/trunk e4ed73c14 -> 8de68ea63


FLUME-1296: Lifecycle supervisor should check if the monitor service is still running before
supervising

(Hari Shreedharan via Brock Noland)


Project: http://git-wip-us.apache.org/repos/asf/flume/repo
Commit: http://git-wip-us.apache.org/repos/asf/flume/commit/8de68ea6
Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/8de68ea6
Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/8de68ea6

Branch: refs/heads/trunk
Commit: 8de68ea636c956b0fe7d2cc18ab21bc26d077405
Parents: e4ed73c
Author: Brock Noland <brock@apache.org>
Authored: Mon Dec 10 14:38:13 2012 -0600
Committer: Brock Noland <brock@apache.org>
Committed: Mon Dec 10 14:38:13 2012 -0600

----------------------------------------------------------------------
 .../flume/lifecycle/LifecycleSupervisor.java       |   25 ++++++++++++---
 1 files changed, 20 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flume/blob/8de68ea6/flume-ng-core/src/main/java/org/apache/flume/lifecycle/LifecycleSupervisor.java
----------------------------------------------------------------------
diff --git a/flume-ng-core/src/main/java/org/apache/flume/lifecycle/LifecycleSupervisor.java
b/flume-ng-core/src/main/java/org/apache/flume/lifecycle/LifecycleSupervisor.java
index 78eda05..59d780a 100644
--- a/flume-ng-core/src/main/java/org/apache/flume/lifecycle/LifecycleSupervisor.java
+++ b/flume-ng-core/src/main/java/org/apache/flume/lifecycle/LifecycleSupervisor.java
@@ -27,6 +27,7 @@ import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.flume.FlumeException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -80,13 +81,19 @@ public class LifecycleSupervisor implements LifecycleAware {
 
     if (monitorService != null) {
       monitorService.shutdown();
-
-      while (!monitorService.isTerminated()) {
+      try{
+        monitorService.awaitTermination(10, TimeUnit.SECONDS);
+      } catch (InterruptedException e) {
+        logger.error("Interrupted while waiting for monitor service to stop");
+      }
+      if(!monitorService.isTerminated()) {
+        monitorService.shutdownNow();
         try {
-          monitorService.awaitTermination(500, TimeUnit.MILLISECONDS);
+          while(!monitorService.isTerminated()) {
+            monitorService.awaitTermination(10, TimeUnit.SECONDS);
+          }
         } catch (InterruptedException e) {
-          logger.debug("Interrupted while waiting for monitor service to stop");
-          monitorService.shutdownNow();
+          logger.error("Interrupted while waiting for monitor service to stop");
         }
       }
     }
@@ -95,6 +102,7 @@ public class LifecycleSupervisor implements LifecycleAware {
         .entrySet()) {
 
       if (entry.getKey().getLifecycleState().equals(LifecycleState.START)) {
+        entry.getValue().status.desiredState = LifecycleState.STOP;
         entry.getKey().stop();
       }
     }
@@ -114,6 +122,13 @@ public class LifecycleSupervisor implements LifecycleAware {
 
   public synchronized void supervise(LifecycleAware lifecycleAware,
       SupervisorPolicy policy, LifecycleState desiredState) {
+    if(this.monitorService.isShutdown()
+        || this.monitorService.isTerminated()
+        || this.monitorService.isTerminating()){
+      throw new FlumeException("Supervise called on " + lifecycleAware + " " +
+          "after shutdown has been initiated. " + lifecycleAware + " will not" +
+          " be started");
+    }
 
     Preconditions.checkState(!supervisedProcesses.containsKey(lifecycleAware),
         "Refusing to supervise " + lifecycleAware + " more than once");


Mime
View raw message