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 2015/06/19 01:50:01 UTC
mesos git commit: Added queue size metric for the allocator.
Repository: mesos
Updated Branches:
refs/heads/master dda49e688 -> 04b214de8
Added queue size metric for the allocator.
Review: https://reviews.apache.org/r/35632
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/04b214de
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/04b214de
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/04b214de
Branch: refs/heads/master
Commit: 04b214de80dc52d534b87aedbbd4d07016d8c0e5
Parents: dda49e6
Author: Benjamin Mahler <be...@gmail.com>
Authored: Thu Jun 18 15:54:35 2015 -0700
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Thu Jun 18 16:04:24 2015 -0700
----------------------------------------------------------------------
src/master/allocator/mesos/hierarchical.hpp | 58 +++++++++++++++---------
src/tests/master_tests.cpp | 4 ++
2 files changed, 40 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/04b214de/src/master/allocator/mesos/hierarchical.hpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.hpp b/src/master/allocator/mesos/hierarchical.hpp
index c220ea6..646ee8c 100644
--- a/src/master/allocator/mesos/hierarchical.hpp
+++ b/src/master/allocator/mesos/hierarchical.hpp
@@ -25,8 +25,11 @@
#include <mesos/resources.hpp>
#include <mesos/type_utils.hpp>
+#include <process/event.hpp>
#include <process/delay.hpp>
#include <process/id.hpp>
+#include <process/metrics/gauge.hpp>
+#include <process/metrics/metrics.hpp>
#include <process/timeout.hpp>
#include <stout/check.hpp>
@@ -67,11 +70,18 @@ template <typename RoleSorter, typename FrameworkSorter>
class HierarchicalAllocatorProcess : public MesosAllocatorProcess
{
public:
- HierarchicalAllocatorProcess();
+ HierarchicalAllocatorProcess()
+ : ProcessBase(process::ID::generate("hierarchical-allocator")),
+ initialized(false),
+ metrics(*this),
+ roleSorter(NULL) {}
- virtual ~HierarchicalAllocatorProcess();
+ virtual ~HierarchicalAllocatorProcess() {}
- process::PID<HierarchicalAllocatorProcess> self();
+ process::PID<HierarchicalAllocatorProcess> self() const
+ {
+ return process::PID<Self>(this);
+ }
void initialize(
const Duration& allocationInterval,
@@ -178,6 +188,24 @@ protected:
void(const FrameworkID&,
const hashmap<SlaveID, Resources>&)> offerCallback;
+ struct Metrics
+ {
+ explicit Metrics(const Self& process)
+ : event_queue_dispatches(
+ "allocator/event_queue_dispatches",
+ process::defer(process.self(), &Self::_event_queue_dispatches))
+ {
+ process::metrics::add(event_queue_dispatches);
+ }
+
+ ~Metrics()
+ {
+ process::metrics::remove(event_queue_dispatches);
+ }
+
+ process::metrics::Gauge event_queue_dispatches;
+ } metrics;
+
struct Framework
{
std::string role;
@@ -189,6 +217,11 @@ protected:
hashset<Filter*> filters; // Active filters for the framework.
};
+ double _event_queue_dispatches()
+ {
+ return static_cast<double>(eventCount<process::DispatchEvent>());
+ }
+
hashmap<FrameworkID, Framework> frameworks;
struct Slave
@@ -263,25 +296,6 @@ public:
template <class RoleSorter, class FrameworkSorter>
-HierarchicalAllocatorProcess<RoleSorter, FrameworkSorter>::HierarchicalAllocatorProcess() // NOLINT(whitespace/line_length)
- : ProcessBase(process::ID::generate("hierarchical-allocator")),
- initialized(false) {}
-
-
-template <class RoleSorter, class FrameworkSorter>
-HierarchicalAllocatorProcess<RoleSorter, FrameworkSorter>::~HierarchicalAllocatorProcess() // NOLINT(whitespace/line_length)
-{}
-
-
-template <class RoleSorter, class FrameworkSorter>
-process::PID<HierarchicalAllocatorProcess<RoleSorter, FrameworkSorter> >
-HierarchicalAllocatorProcess<RoleSorter, FrameworkSorter>::self()
-{
- return process::PID<HierarchicalAllocatorProcess<RoleSorter, FrameworkSorter> >(this); // NOLINT(whitespace/line_length)
-}
-
-
-template <class RoleSorter, class FrameworkSorter>
void
HierarchicalAllocatorProcess<RoleSorter, FrameworkSorter>::initialize(
const Duration& _allocationInterval,
http://git-wip-us.apache.org/repos/asf/mesos/blob/04b214de/src/tests/master_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_tests.cpp b/src/tests/master_tests.cpp
index 62cf87d..962455c 100644
--- a/src/tests/master_tests.cpp
+++ b/src/tests/master_tests.cpp
@@ -1573,12 +1573,16 @@ TEST_F(MasterTest, MetricsInMetricsEndpoint)
EXPECT_EQ(1u, snapshot.values.count("master/disk_used"));
EXPECT_EQ(1u, snapshot.values.count("master/disk_percent"));
+ // Registrar Metrics.
EXPECT_EQ(1u, snapshot.values.count("registrar/queued_operations"));
EXPECT_EQ(1u, snapshot.values.count("registrar/registry_size_bytes"));
EXPECT_EQ(1u, snapshot.values.count("registrar/state_fetch_ms"));
EXPECT_EQ(1u, snapshot.values.count("registrar/state_store_ms"));
+ // Allocator Metrics.
+ EXPECT_EQ(1u, snapshot.values.count("allocator/event_queue_dispatches"));
+
Shutdown();
}