aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zma...@apache.org
Subject aurora git commit: Reset `framework_registered` metric on disconnection.
Date Wed, 29 Mar 2017 20:35:34 GMT
Repository: aurora
Updated Branches:
  refs/heads/master c32f14c75 -> 3a9aabda9


Reset `framework_registered` metric on disconnection.

Previously the `framework_registered` metric only transitioned from 0 to 1 on
the first registration. On disconnection and registration loss, the metric was
not updated to reflect the loss of registration.

To make this metric more useful, I have moved this metric from the
`SchedulerLifecycle`, where it was tied to the boolean controlling the
LEADER_AWAITING_REGISTRATION -> ACTIVE transtion, to `MesosCallbackHandler`. In
`MesosCallbackHandler` it can easily be updated to reflect the current state
of registration.

Bugs closed: AURORA-1910

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


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

Branch: refs/heads/master
Commit: 3a9aabda9c37fb3595baf6b0c50f3f705c0f17cd
Parents: c32f14c
Author: Zameer Manji <zmanji@apache.org>
Authored: Wed Mar 29 13:35:21 2017 -0700
Committer: Zameer Manji <zmanji@apache.org>
Committed: Wed Mar 29 13:35:21 2017 -0700

----------------------------------------------------------------------
 .../org/apache/aurora/scheduler/SchedulerLifecycle.java  | 11 -----------
 .../aurora/scheduler/mesos/MesosCallbackHandler.java     |  9 ++++++++-
 .../apache/aurora/scheduler/SchedulerLifecycleTest.java  |  3 ---
 .../aurora/scheduler/mesos/MesosCallbackHandlerTest.java |  4 ++++
 4 files changed, 12 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/3a9aabda/src/main/java/org/apache/aurora/scheduler/SchedulerLifecycle.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/SchedulerLifecycle.java b/src/main/java/org/apache/aurora/scheduler/SchedulerLifecycle.java
index 4e354b6..aa09aff 100644
--- a/src/main/java/org/apache/aurora/scheduler/SchedulerLifecycle.java
+++ b/src/main/java/org/apache/aurora/scheduler/SchedulerLifecycle.java
@@ -170,9 +170,6 @@ public class SchedulerLifecycle implements EventSubscriber {
   }
 
   @VisibleForTesting
-  static final String REGISTERED_GAUGE = "framework_registered";
-
-  @VisibleForTesting
   static String stateGaugeName(State state) {
     return "scheduler_lifecycle_" + state;
   }
@@ -193,14 +190,6 @@ public class SchedulerLifecycle implements EventSubscriber {
     requireNonNull(delayedActions);
     requireNonNull(shutdownRegistry);
 
-    statsProvider.makeGauge(
-        REGISTERED_GAUGE,
-        new Supplier<Integer>() {
-          @Override
-          public Integer get() {
-            return registrationAcked.get() ? 1 : 0;
-          }
-        });
     for (final State state : State.values()) {
       statsProvider.makeGauge(
           stateGaugeName(state),

http://git-wip-us.apache.org/repos/asf/aurora/blob/3a9aabda/src/main/java/org/apache/aurora/scheduler/mesos/MesosCallbackHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/mesos/MesosCallbackHandler.java b/src/main/java/org/apache/aurora/scheduler/mesos/MesosCallbackHandler.java
index 800edfa..5bf1e4e 100644
--- a/src/main/java/org/apache/aurora/scheduler/mesos/MesosCallbackHandler.java
+++ b/src/main/java/org/apache/aurora/scheduler/mesos/MesosCallbackHandler.java
@@ -19,6 +19,7 @@ import java.time.Instant;
 import java.time.temporal.ChronoUnit;
 import java.util.List;
 import java.util.concurrent.Executor;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
 import javax.inject.Inject;
 import javax.inject.Qualifier;
@@ -102,6 +103,7 @@ public interface MesosCallbackHandler {
     private final AtomicLong inverseOffersReceived;
     private final AtomicLong disconnects;
     private final AtomicLong executorsLost;
+    private final AtomicBoolean frameworkRegistered;
 
     /**
      * Binding annotation for the executor the incoming Mesos message handler uses.
@@ -184,6 +186,8 @@ public interface MesosCallbackHandler {
       this.inverseOffersReceived = statsProvider.makeCounter("scheduler_inverse_offers");
       this.disconnects = statsProvider.makeCounter("scheduler_framework_disconnects");
       this.executorsLost = statsProvider.makeCounter("scheduler_lost_executors");
+      this.frameworkRegistered = new AtomicBoolean(false);
+      statsProvider.makeGauge("framework_registered", () -> frameworkRegistered.get()
? 1 : 0);
     }
 
     @Override
@@ -193,12 +197,14 @@ public interface MesosCallbackHandler {
       storage.write(
           (Storage.MutateWork.NoResult.Quiet) storeProvider ->
               storeProvider.getSchedulerStore().saveFrameworkId(frameworkId.getValue()));
+      frameworkRegistered.set(true);
       eventSink.post(new PubsubEvent.DriverRegistered());
     }
 
     @Override
     public void handleReregistration(MasterInfo masterInfo) {
       log.info("Framework re-registered with master " + masterInfo);
+      frameworkRegistered.set(true);
       reRegisters.incrementAndGet();
     }
 
@@ -228,7 +234,8 @@ public interface MesosCallbackHandler {
     @Override
     public void handleDisconnection() {
       log.warn("Framework disconnected.");
-      this.disconnects.incrementAndGet();
+      disconnects.incrementAndGet();
+      frameworkRegistered.set(false);
       eventSink.post(new PubsubEvent.DriverDisconnected());
     }
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/3a9aabda/src/test/java/org/apache/aurora/scheduler/SchedulerLifecycleTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/SchedulerLifecycleTest.java b/src/test/java/org/apache/aurora/scheduler/SchedulerLifecycleTest.java
index 051c520..70479ef 100644
--- a/src/test/java/org/apache/aurora/scheduler/SchedulerLifecycleTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/SchedulerLifecycleTest.java
@@ -84,7 +84,6 @@ public class SchedulerLifecycleTest extends EasyMockTest {
         shutdownRegistry,
         statsProvider,
         serviceManager);
-    assertEquals(0, statsProvider.getValue(SchedulerLifecycle.REGISTERED_GAUGE));
     assertEquals(1, statsProvider.getValue(stateGaugeName(State.IDLE)));
     return shutdownCommand;
   }
@@ -137,10 +136,8 @@ public class SchedulerLifecycleTest extends EasyMockTest {
     assertEquals(1, statsProvider.getValue(stateGaugeName(State.STORAGE_PREPARED)));
     leaderListener.onLeading(leaderControl);
     assertEquals(1, statsProvider.getValue(stateGaugeName(State.LEADER_AWAITING_REGISTRATION)));
-    assertEquals(0, statsProvider.getValue(SchedulerLifecycle.REGISTERED_GAUGE));
     schedulerLifecycle.registered(new DriverRegistered());
     assertEquals(1, statsProvider.getValue(stateGaugeName(State.ACTIVE)));
-    assertEquals(1, statsProvider.getValue(SchedulerLifecycle.REGISTERED_GAUGE));
     triggerFailover.getValue().run();
   }
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/3a9aabda/src/test/java/org/apache/aurora/scheduler/mesos/MesosCallbackHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/mesos/MesosCallbackHandlerTest.java
b/src/test/java/org/apache/aurora/scheduler/mesos/MesosCallbackHandlerTest.java
index 52041b5..b955d61 100644
--- a/src/test/java/org/apache/aurora/scheduler/mesos/MesosCallbackHandlerTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/mesos/MesosCallbackHandlerTest.java
@@ -211,7 +211,9 @@ public class MesosCallbackHandlerTest extends EasyMockTest {
 
     control.replay();
 
+    assertEquals(0L, statsProvider.getLongValue("framework_registered"));
     handler.handleRegistration(FRAMEWORK, MASTER);
+    assertEquals(1L, statsProvider.getLongValue("framework_registered"));
   }
 
   @Test
@@ -220,6 +222,7 @@ public class MesosCallbackHandlerTest extends EasyMockTest {
 
     handler.handleReregistration(MASTER);
     assertEquals(1L, statsProvider.getLongValue("scheduler_framework_reregisters"));
+    assertEquals(1L, statsProvider.getLongValue("framework_registered"));
   }
 
   @Test
@@ -294,6 +297,7 @@ public class MesosCallbackHandlerTest extends EasyMockTest {
 
     handler.handleDisconnection();
     assertEquals(1L, statsProvider.getLongValue("scheduler_framework_disconnects"));
+    assertEquals(0L, statsProvider.getLongValue("framework_registered"));
   }
 
   @Test


Mime
View raw message