aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zma...@apache.org
Subject aurora git commit: Add listener to trigger scheduler shutdown on service failure.
Date Mon, 26 Oct 2015 21:04:04 GMT
Repository: aurora
Updated Branches:
  refs/heads/master ed2cfb7da -> e6f940b24


Add listener to trigger scheduler shutdown on service failure.

Bugs closed: AURORA-1511

Reviewed at https://reviews.apache.org/r/39631/


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

Branch: refs/heads/master
Commit: e6f940b245b903c30c1c05cc18769919e5915ba5
Parents: ed2cfb7
Author: Zameer Manji <zmanji@apache.org>
Authored: Mon Oct 26 14:03:52 2015 -0700
Committer: Zameer Manji <zmanji@apache.org>
Committed: Mon Oct 26 14:03:52 2015 -0700

----------------------------------------------------------------------
 config/legacy_untested_classes.txt              |  3 ++-
 src/main/java/org/apache/aurora/GuavaUtils.java | 20 ++++++++++++++++++++
 .../scheduler/SchedulerServicesModule.java      | 19 +++++++++++++++----
 3 files changed, 37 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/e6f940b2/config/legacy_untested_classes.txt
----------------------------------------------------------------------
diff --git a/config/legacy_untested_classes.txt b/config/legacy_untested_classes.txt
index 0f1e6be..70d1dd0 100644
--- a/config/legacy_untested_classes.txt
+++ b/config/legacy_untested_classes.txt
@@ -1,3 +1,4 @@
+org/apache/aurora/GuavaUtils$LifecycleShutdownListener
 org/apache/aurora/Protobufs$1
 org/apache/aurora/auth/CapabilityValidator$AuditCheck
 org/apache/aurora/auth/UnsecureAuthModule$UnsecureCapabilityValidator
@@ -67,7 +68,7 @@ org/apache/aurora/scheduler/storage/mem/MemTaskStore$Task
 org/apache/aurora/scheduler/storage/mem/Util
 org/apache/aurora/scheduler/storage/mem/Util$1
 org/apache/aurora/scheduler/testing/FakeStatsProvider$3
+org/apache/aurora/scheduler/zookeeper/guice/client/ZooKeeperClientModule$1
 org/apache/aurora/scheduler/zookeeper/guice/client/ZooKeeperClientModule$LocalClientProvider
 org/apache/aurora/scheduler/zookeeper/guice/client/ZooKeeperClientModule$TestServerService
-org/apache/aurora/scheduler/zookeeper/guice/client/ZooKeeperClientModule$1
 org/apache/aurora/scheduler/zookeeper/guice/client/flagged/FlaggedClientConfig

http://git-wip-us.apache.org/repos/asf/aurora/blob/e6f940b2/src/main/java/org/apache/aurora/GuavaUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/GuavaUtils.java b/src/main/java/org/apache/aurora/GuavaUtils.java
index e3e90e3..5cdd9a9 100644
--- a/src/main/java/org/apache/aurora/GuavaUtils.java
+++ b/src/main/java/org/apache/aurora/GuavaUtils.java
@@ -15,6 +15,7 @@ package org.apache.aurora;
 
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
+import java.util.logging.Logger;
 import java.util.stream.Collector;
 
 import com.google.common.collect.ImmutableList;
@@ -23,6 +24,9 @@ import com.google.common.collect.ImmutableSet;
 import com.google.common.util.concurrent.Service;
 import com.google.common.util.concurrent.Service.State;
 import com.google.common.util.concurrent.ServiceManager;
+import com.google.inject.Inject;
+
+import org.apache.aurora.common.application.Lifecycle;
 
 import static java.util.stream.Collector.Characteristics.UNORDERED;
 
@@ -34,6 +38,22 @@ public final class GuavaUtils {
     // Utility class.
   }
 
+  public static class LifecycleShutdownListener extends ServiceManager.Listener {
+    private final Lifecycle lifecycle;
+    private static final Logger LOG = Logger.getLogger(LifecycleShutdownListener.class.getName());
+
+    @Inject
+    LifecycleShutdownListener(Lifecycle lifecycle) {
+      this.lifecycle = lifecycle;
+    }
+
+    @Override
+    public void failure(Service service) {
+      LOG.severe("Service: " + service + " failed unexpectedly. Triggering shutdown.");
+      lifecycle.shutdown();
+    }
+  }
+
   /**
    * Collector to create a Guava ImmutableSet.
    */

http://git-wip-us.apache.org/repos/asf/aurora/blob/e6f940b2/src/main/java/org/apache/aurora/scheduler/SchedulerServicesModule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/SchedulerServicesModule.java b/src/main/java/org/apache/aurora/scheduler/SchedulerServicesModule.java
index 7b110b9..a28b59f 100644
--- a/src/main/java/org/apache/aurora/scheduler/SchedulerServicesModule.java
+++ b/src/main/java/org/apache/aurora/scheduler/SchedulerServicesModule.java
@@ -26,6 +26,7 @@ import com.google.inject.binder.LinkedBindingBuilder;
 import com.google.inject.multibindings.Multibinder;
 
 import org.apache.aurora.GuavaUtils;
+import org.apache.aurora.GuavaUtils.LifecycleShutdownListener;
 import org.apache.aurora.GuavaUtils.ServiceManagerIface;
 import org.apache.aurora.scheduler.SchedulerLifecycle.SchedulerActive;
 
@@ -68,14 +69,24 @@ public class SchedulerServicesModule extends AbstractModule {
   @Provides
   @Singleton
   @AppStartup
-  ServiceManagerIface provideAppStartupServiceManager(@AppStartup Set<Service> services)
{
-    return GuavaUtils.serviceManager(new ServiceManager(services));
+  ServiceManagerIface provideAppStartupServiceManager(
+      @AppStartup Set<Service> services,
+      LifecycleShutdownListener listener) {
+
+    ServiceManager manager = new ServiceManager(services);
+    manager.addListener(listener);
+    return GuavaUtils.serviceManager(manager);
   }
 
   @Provides
   @Singleton
   @SchedulerActive
-  ServiceManagerIface provideSchedulerActiveServiceManager(@SchedulerActive Set<Service>
services) {
-    return GuavaUtils.serviceManager(new ServiceManager(services));
+  ServiceManagerIface provideSchedulerActiveServiceManager(
+      @SchedulerActive Set<Service> services,
+      LifecycleShutdownListener listener) {
+
+    ServiceManager manager = new ServiceManager(services);
+    manager.addListener(listener);
+    return GuavaUtils.serviceManager(manager);
   }
 }


Mime
View raw message