aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject aurora git commit: Expose stats on undelivered event bus events
Date Tue, 27 Dec 2016 22:33:17 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 31f095da4 -> 21ad18ec7


Expose stats on undelivered event bus events

Bugs closed: AURORA-1834

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


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

Branch: refs/heads/master
Commit: 21ad18ec7e6b7104714b97c5d3348f7f2e97fc0a
Parents: 31f095d
Author: Mehrdad Nurolahzade <mehrdad@nurolahzade.com>
Authored: Tue Dec 27 23:32:26 2016 +0100
Committer: Stephan Erb <serb@apache.org>
Committed: Tue Dec 27 23:32:26 2016 +0100

----------------------------------------------------------------------
 .../scheduler/events/PubsubEventModule.java       | 18 ++++++++++--------
 .../scheduler/events/PubsubEventModuleTest.java   |  2 ++
 2 files changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/21ad18ec/src/main/java/org/apache/aurora/scheduler/events/PubsubEventModule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/events/PubsubEventModule.java b/src/main/java/org/apache/aurora/scheduler/events/PubsubEventModule.java
index f9c8a57..0ca7e23 100644
--- a/src/main/java/org/apache/aurora/scheduler/events/PubsubEventModule.java
+++ b/src/main/java/org/apache/aurora/scheduler/events/PubsubEventModule.java
@@ -52,6 +52,8 @@ public final class PubsubEventModule extends AbstractModule {
 
   @VisibleForTesting
   static final String EXCEPTIONS_STAT = "event_bus_exceptions";
+  @VisibleForTesting
+  static final String EVENT_BUS_DEAD_EVENTS = "event_bus_dead_events";
 
   @VisibleForTesting
   PubsubEventModule(Logger log) {
@@ -87,7 +89,14 @@ public final class PubsubEventModule extends AbstractModule {
         }
     );
 
-    eventBus.register(new DeadEventHandler());
+    final AtomicLong deadEventCounter = statsProvider.makeCounter(EVENT_BUS_DEAD_EVENTS);
+    eventBus.register(new Object() {
+      @Subscribe
+      public void logDeadEvent(DeadEvent event) {
+        deadEventCounter.incrementAndGet();
+        log.warn(String.format(DEAD_EVENT_MESSAGE, event.getEvent()));
+      }
+    });
     return eventBus;
   }
 
@@ -97,13 +106,6 @@ public final class PubsubEventModule extends AbstractModule {
     return eventBus::post;
   }
 
-  private class DeadEventHandler {
-    @Subscribe
-    public void logDeadEvent(DeadEvent event) {
-      log.warn(String.format(DEAD_EVENT_MESSAGE, event.getEvent()));
-    }
-  }
-
   static class RegisterSubscribers extends AbstractIdleService {
     private final EventBus eventBus;
     private final Set<EventSubscriber> subscribers;

http://git-wip-us.apache.org/repos/asf/aurora/blob/21ad18ec/src/test/java/org/apache/aurora/scheduler/events/PubsubEventModuleTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/events/PubsubEventModuleTest.java b/src/test/java/org/apache/aurora/scheduler/events/PubsubEventModuleTest.java
index 2676e3c..692adeb 100644
--- a/src/test/java/org/apache/aurora/scheduler/events/PubsubEventModuleTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/events/PubsubEventModuleTest.java
@@ -64,6 +64,7 @@ public class PubsubEventModuleTest extends EasyMockTest {
     control.replay();
 
     getInjector().getInstance(EventBus.class).post("hello");
+    assertEquals(1L, statsProvider.getLongValue(PubsubEventModule.EVENT_BUS_DEAD_EVENTS));
   }
 
   @Test
@@ -84,6 +85,7 @@ public class PubsubEventModuleTest extends EasyMockTest {
     assertEquals(0L, statsProvider.getLongValue(PubsubEventModule.EXCEPTIONS_STAT));
     injector.getInstance(EventBus.class).post("hello");
     assertEquals(1L, statsProvider.getLongValue(PubsubEventModule.EXCEPTIONS_STAT));
+    assertEquals(0L, statsProvider.getLongValue(PubsubEventModule.EVENT_BUS_DEAD_EVENTS));
   }
 
   static class ThrowingSubscriber implements PubsubEvent.EventSubscriber {


Mime
View raw message