mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bmah...@apache.org
Subject [2/2] git commit: Added metric for event queue size in the master.
Date Sat, 03 May 2014 00:19:27 GMT
Added metric for event queue size in the master.

Review: https://reviews.apache.org/r/21032


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

Branch: refs/heads/master
Commit: b323f291bdec89e801f39467c89412f90e28fdd2
Parents: 20d2c43
Author: Dominic Hamon <dhamon@twopensource.com>
Authored: Fri May 2 16:59:37 2014 -0700
Committer: Benjamin Mahler <bmahler@twitter.com>
Committed: Fri May 2 17:05:44 2014 -0700

----------------------------------------------------------------------
 src/master/master.cpp      |  3 ++-
 src/master/master.hpp      | 29 +++++++++++++++++++++++++++--
 src/tests/master_tests.cpp |  2 ++
 3 files changed, 31 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/b323f291/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index e7b6657..e8a6124 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -221,7 +221,8 @@ Master::Master(
     repairer(_repairer),
     files(_files),
     contender(_contender),
-    detector(_detector)
+    detector(_detector),
+    metrics(*this)
 {
   // NOTE: We populate 'info_' here instead of inside 'initialize()'
   // because 'StandaloneMasterDetector' needs access to the info.

http://git-wip-us.apache.org/repos/asf/mesos/blob/b323f291/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index 6ae6ae4..0a350b0 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -36,6 +36,7 @@
 #include <process/timer.hpp>
 
 #include <process/metrics/counter.hpp>
+#include <process/metrics/gauge.hpp>
 #include <process/metrics/metrics.hpp>
 
 #include <stout/cache.hpp>
@@ -468,7 +469,7 @@ private:
 
   struct Metrics
   {
-    Metrics()
+    Metrics(const Master& master)
       : dropped_messages(
             "master/dropped_messages"),
         framework_registration_messages(
@@ -480,7 +481,10 @@ private:
         slave_reregistration_messages(
             "master/slave_reregistration_messages"),
         recovery_slave_removals(
-            "master/recovery_slave_removals")
+            "master/recovery_slave_removals"),
+        event_queue_size(
+            "master/event_queue_size",
+            defer(master, &Master::_event_queue_size))
     {
       process::metrics::add(dropped_messages);
 
@@ -491,6 +495,8 @@ private:
       process::metrics::add(slave_reregistration_messages);
 
       process::metrics::add(recovery_slave_removals);
+
+      process::metrics::add(event_queue_size);
     }
 
     ~Metrics()
@@ -504,6 +510,8 @@ private:
       process::metrics::remove(slave_reregistration_messages);
 
       process::metrics::remove(recovery_slave_removals);
+
+      process::metrics::remove(event_queue_size);
     }
 
     // Message counters.
@@ -519,8 +527,25 @@ private:
 
     // Recovery counters.
     process::metrics::Counter recovery_slave_removals;
+
+    // Process metrics.
+    process::metrics::Gauge event_queue_size;
   } metrics;
 
+  // Gauge handlers.
+  double _event_queue_size()
+  {
+    size_t size;
+
+    lock();
+    {
+      size = events.size();
+    }
+    unlock();
+
+    return static_cast<double>(size);
+  }
+
   process::Time startTime; // Start time used to calculate uptime.
 };
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/b323f291/src/tests/master_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_tests.cpp b/src/tests/master_tests.cpp
index 534afee..d407834 100644
--- a/src/tests/master_tests.cpp
+++ b/src/tests/master_tests.cpp
@@ -1290,6 +1290,8 @@ TEST_F(MasterTest, MetricsInStatsEndpoint)
 
   EXPECT_EQ(1u, stats.values.count("master/recovery_slave_removals"));
 
+  EXPECT_EQ(1u, stats.values.count("master/event_queue_size"));
+
   EXPECT_EQ(1u, stats.values.count("registrar/queued_operations"));
   EXPECT_EQ(1u, stats.values.count("registrar/registry_size_bytes"));
 


Mime
View raw message