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 2016/03/23 03:21:32 UTC
mesos git commit: Added a metric for the number of times the
allocation algorithm has run.
Repository: mesos
Updated Branches:
refs/heads/master 39e503a74 -> d3d06cd92
Added a metric for the number of times the allocation algorithm has run.
Review: https://reviews.apache.org/r/43879
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d3d06cd9
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d3d06cd9
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d3d06cd9
Branch: refs/heads/master
Commit: d3d06cd92d84d1b8d0fb85ce28fc01dea7da6879
Parents: 39e503a
Author: Benjamin Bannier <be...@mesosphere.io>
Authored: Tue Mar 22 18:51:47 2016 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Tue Mar 22 18:51:47 2016 -0700
----------------------------------------------------------------------
docs/monitoring.md | 8 +++++
src/master/allocator/mesos/hierarchical.cpp | 2 ++
src/master/allocator/mesos/metrics.cpp | 5 ++-
src/master/allocator/mesos/metrics.hpp | 4 +++
src/tests/hierarchical_allocator_tests.cpp | 39 ++++++++++++++++++++++++
5 files changed, 57 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/d3d06cd9/docs/monitoring.md
----------------------------------------------------------------------
diff --git a/docs/monitoring.md b/docs/monitoring.md
index a746682..c03372b 100644
--- a/docs/monitoring.md
+++ b/docs/monitoring.md
@@ -868,6 +868,14 @@ and resource allocations in the allocator.
</thead>
<tr>
<td>
+ <code>allocator/mesos/allocation_runs</code>
+ </td>
+ <td>Number of times the allocation algorithm has run</td>
+ <td>Counter</td>
+</tr>
+<tr>
+<tr>
+ <td>
<code>allocator/mesos/event_queue_dispatches</code>
</td>
<td>Number of dispatch events in the event queue</td>
http://git-wip-us.apache.org/repos/asf/mesos/blob/d3d06cd9/src/master/allocator/mesos/hierarchical.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.cpp b/src/master/allocator/mesos/hierarchical.cpp
index 800496a..c56990d 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -1160,6 +1160,8 @@ void HierarchicalAllocatorProcess::allocate(
void HierarchicalAllocatorProcess::allocate(
const hashset<SlaveID>& slaveIds_)
{
+ ++metrics.allocation_runs;
+
// Compute the offerable resources, per framework:
// (1) For reserved resources on the slave, allocate these to a
// framework having the corresponding role.
http://git-wip-us.apache.org/repos/asf/mesos/blob/d3d06cd9/src/master/allocator/mesos/metrics.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/metrics.cpp b/src/master/allocator/mesos/metrics.cpp
index 719adc7..9fa96f5 100644
--- a/src/master/allocator/mesos/metrics.cpp
+++ b/src/master/allocator/mesos/metrics.cpp
@@ -43,10 +43,12 @@ Metrics::Metrics(const HierarchicalAllocatorProcess& _allocator)
event_queue_dispatches_(
"allocator/event_queue_dispatches",
process::defer(
- allocator, &HierarchicalAllocatorProcess::_event_queue_dispatches))
+ allocator, &HierarchicalAllocatorProcess::_event_queue_dispatches)),
+ allocation_runs("allocator/mesos/allocation_runs")
{
process::metrics::add(event_queue_dispatches);
process::metrics::add(event_queue_dispatches_);
+ process::metrics::add(allocation_runs);
// Create and install gauges for the total and allocated
// amount of standard scalar resources.
@@ -83,6 +85,7 @@ Metrics::~Metrics()
{
process::metrics::remove(event_queue_dispatches);
process::metrics::remove(event_queue_dispatches_);
+ process::metrics::remove(allocation_runs);
foreach (const Gauge& gauge, resources_total) {
process::metrics::remove(gauge);
http://git-wip-us.apache.org/repos/asf/mesos/blob/d3d06cd9/src/master/allocator/mesos/metrics.hpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/metrics.hpp b/src/master/allocator/mesos/metrics.hpp
index 2c5ef3a..6b91e27 100644
--- a/src/master/allocator/mesos/metrics.hpp
+++ b/src/master/allocator/mesos/metrics.hpp
@@ -20,6 +20,7 @@
#include <string>
#include <vector>
+#include <process/metrics/counter.hpp>
#include <process/metrics/gauge.hpp>
#include <process/pid.hpp>
@@ -55,6 +56,9 @@ struct Metrics
// uses a name deprecated in 0.29. This metric should be removed with 0.30.
process::metrics::Gauge event_queue_dispatches_;
+ // Number of times the allocation algorithm has run.
+ process::metrics::Counter allocation_runs;
+
// Gauges for the total amount of each resource in the cluster.
std::vector<process::metrics::Gauge> resources_total;
http://git-wip-us.apache.org/repos/asf/mesos/blob/d3d06cd9/src/tests/hierarchical_allocator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/hierarchical_allocator_tests.cpp b/src/tests/hierarchical_allocator_tests.cpp
index 55c2d52..176b429 100644
--- a/src/tests/hierarchical_allocator_tests.cpp
+++ b/src/tests/hierarchical_allocator_tests.cpp
@@ -2530,6 +2530,45 @@ TEST_F(HierarchicalAllocatorTest, ResourceMetrics)
}
+// This test checks that the number of times the allocation
+// algorithm has run is correctly reflected in the metric.
+TEST_F(HierarchicalAllocatorTest, AllocationRunsMetric)
+{
+ // Pausing the clock is not necessary, but ensures that the test
+ // doesn't rely on the batch allocation in the allocator, which
+ // would slow down the test.
+ Clock::pause();
+
+ initialize();
+
+ size_t allocations = 0;
+
+ JSON::Object expected;
+
+ expected.values = { {"allocator/mesos/allocation_runs", allocations} };
+
+ JSON::Value metrics = Metrics();
+
+ EXPECT_TRUE(metrics.contains(expected));
+
+ SlaveInfo agent = createSlaveInfo("cpus:2;mem:1024;disk:0");
+ allocator->addSlave(agent.id(), agent, None(), agent.resources(), {});
+ ++allocations; // Adding an agent triggers allocations.
+
+ FrameworkInfo framework = createFrameworkInfo("role");
+ allocator->addFramework(framework.id(), framework, {});
+ ++allocations; // Adding a framework triggers allocations.
+
+ Clock::settle();
+
+ expected.values = { {"allocator/mesos/allocation_runs", allocations} };
+
+ metrics = Metrics();
+
+ EXPECT_TRUE(metrics.contains(expected));
+}
+
+
// This test ensures that resource allocation is done according to each role's
// weight. This is done by having six agents and three frameworks and making
// sure each framework gets the appropriate number of resources.