You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2014/05/03 02:19:26 UTC
[1/2] git commit: Exposed the event queue in ProcessBase as protected.
Repository: mesos
Updated Branches:
refs/heads/master 554eb7ad3 -> b323f291b
Exposed the event queue in ProcessBase as protected.
Review: https://reviews.apache.org/r/20991
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/20d2c439
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/20d2c439
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/20d2c439
Branch: refs/heads/master
Commit: 20d2c43960f9c5e38315eac1a632de1a017bcba0
Parents: 554eb7a
Author: Dominic Hamon <dh...@twopensource.com>
Authored: Fri May 2 16:57:32 2014 -0700
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Fri May 2 16:59:28 2014 -0700
----------------------------------------------------------------------
3rdparty/libprocess/include/process/process.hpp | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/20d2c439/3rdparty/libprocess/include/process/process.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/process.hpp b/3rdparty/libprocess/include/process/process.hpp
index d6bdccf..c29cd21 100644
--- a/3rdparty/libprocess/include/process/process.hpp
+++ b/3rdparty/libprocess/include/process/process.hpp
@@ -162,6 +162,19 @@ protected:
assets[name] = asset;
}
+ void lock()
+ {
+ pthread_mutex_lock(&m);
+ }
+
+ void unlock()
+ {
+ pthread_mutex_unlock(&m);
+ }
+
+ // Queue of received events, requires lock()ed access!
+ std::deque<Event*> events;
+
private:
friend class SocketManager;
friend class ProcessManager;
@@ -181,15 +194,10 @@ private:
// Mutex protecting internals.
// TODO(benh): Consider replacing with a spinlock, on multi-core systems.
pthread_mutex_t m;
- void lock() { pthread_mutex_lock(&m); }
- void unlock() { pthread_mutex_unlock(&m); }
// Enqueue the specified message, request, or function call.
void enqueue(Event* event, bool inject = false);
- // Queue of received events.
- std::deque<Event*> events;
-
// Delegates for messages.
std::map<std::string, UPID> delegates;
[2/2] git commit: Added metric for event queue size in the master.
Posted by bm...@apache.org.
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 <dh...@twopensource.com>
Authored: Fri May 2 16:59:37 2014 -0700
Committer: Benjamin Mahler <bm...@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"));