You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by gr...@apache.org on 2018/08/01 20:24:21 UTC
[04/16] mesos git commit: Added per-framework 'subscribed' metric and
helpers.
Added per-framework 'subscribed' metric and helpers.
Review: https://reviews.apache.org/r/66820/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/9b7b5e7c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/9b7b5e7c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/9b7b5e7c
Branch: refs/heads/master
Commit: 9b7b5e7c1261fda3327cc2f1ef4c00ff600d3f6f
Parents: 45fa059
Author: Gilbert Song <so...@gmail.com>
Authored: Wed Aug 1 07:58:06 2018 -0700
Committer: Greg Mann <gr...@gmail.com>
Committed: Wed Aug 1 13:07:54 2018 -0700
----------------------------------------------------------------------
src/master/master.cpp | 17 ++++++++++++-----
src/master/master.hpp | 6 +++++-
src/master/metrics.cpp | 12 ++++++++++--
src/master/metrics.hpp | 3 +++
4 files changed, 30 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/9b7b5e7c/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 2af976f..8f76f30 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -458,6 +458,13 @@ void Framework::untrackUnderRole(const string& role)
}
+void Framework::setFrameworkState(const Framework::State& _state)
+{
+ state = _state;
+ metrics.subscribed = state == Framework::State::ACTIVE ? 1 : 0;
+}
+
+
void Master::initialize()
{
LOG(INFO) << "Master " << info_.id() << " (" << info_.hostname() << ")"
@@ -3162,7 +3169,7 @@ void Master::_subscribe(
// NOTE: We do this after recovering resources (above) so that
// the allocator has the correct view of the framework's share.
if (!framework->active()) {
- framework->state = Framework::State::ACTIVE;
+ framework->setFrameworkState(Framework::State::ACTIVE);
allocator->activateFramework(framework->id());
}
@@ -3279,7 +3286,7 @@ void Master::disconnect(Framework* framework)
LOG(INFO) << "Disconnecting framework " << *framework;
- framework->state = Framework::State::DISCONNECTED;
+ framework->setFrameworkState(Framework::State::DISCONNECTED);
if (framework->pid.isSome()) {
// Remove the framework from authenticated. This is safe because
@@ -3302,7 +3309,7 @@ void Master::deactivate(Framework* framework, bool rescind)
LOG(INFO) << "Deactivating framework " << *framework;
- framework->state = Framework::State::INACTIVE;
+ framework->setFrameworkState(Framework::State::INACTIVE);
// Tell the allocator to stop allocating resources to this framework.
allocator->deactivateFramework(framework->id());
@@ -10010,7 +10017,7 @@ Try<Nothing> Master::activateRecoveredFramework(
}
// Activate the framework.
- framework->state = Framework::State::ACTIVE;
+ framework->setFrameworkState(Framework::State::ACTIVE);
allocator->activateFramework(framework->id());
// Export framework metrics if a principal is specified in `FrameworkInfo`.
@@ -10160,7 +10167,7 @@ void Master::_failoverFramework(Framework* framework)
// NOTE: We do this after recovering resources (above) so that
// the allocator has the correct view of the framework's share.
if (!framework->active()) {
- framework->state = Framework::State::ACTIVE;
+ framework->setFrameworkState(Framework::State::ACTIVE);
allocator->activateFramework(framework->id());
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/9b7b5e7c/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index 4bb64ca..6c92d33 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -1829,6 +1829,7 @@ private:
Master& operator=(const Master&); // No assigning.
friend struct Framework;
+ friend struct FrameworkMetrics;
friend struct Metrics;
friend struct Slave;
friend struct SlavesWriter;
@@ -2917,6 +2918,8 @@ struct Framework
void trackUnderRole(const std::string& role);
void untrackUnderRole(const std::string& role);
+ void setFrameworkState(const State& _state);
+
Master* const master;
FrameworkInfo info;
@@ -3026,7 +3029,6 @@ private:
info(_info),
roles(protobuf::framework::getRoles(_info)),
capabilities(_info.capabilities()),
- state(state),
registeredTime(time),
reregisteredTime(time),
completedTasks(masterFlags.max_completed_tasks_per_framework),
@@ -3035,6 +3037,8 @@ private:
{
CHECK(_info.has_id());
+ setFrameworkState(state);
+
foreach (const std::string& role, roles) {
// NOTE: It's possible that we're already being tracked under the role
// because a framework can unsubscribe from a role while it still has
http://git-wip-us.apache.org/repos/asf/mesos/blob/9b7b5e7c/src/master/metrics.cpp
----------------------------------------------------------------------
diff --git a/src/master/metrics.cpp b/src/master/metrics.cpp
index a778322..70ac72d 100644
--- a/src/master/metrics.cpp
+++ b/src/master/metrics.cpp
@@ -549,10 +549,18 @@ void Metrics::incrementTasksStates(
FrameworkMetrics::FrameworkMetrics(const FrameworkInfo& _frameworkInfo)
- : frameworkInfo(_frameworkInfo) {}
+ : frameworkInfo(_frameworkInfo),
+ subscribed(
+ getFrameworkMetricPrefix(frameworkInfo) + "subscribed")
+{
+ process::metrics::add(subscribed);
+}
-FrameworkMetrics::~FrameworkMetrics() {}
+FrameworkMetrics::~FrameworkMetrics()
+{
+ process::metrics::remove(subscribed);
+}
string getFrameworkMetricPrefix(const FrameworkInfo& frameworkInfo)
http://git-wip-us.apache.org/repos/asf/mesos/blob/9b7b5e7c/src/master/metrics.hpp
----------------------------------------------------------------------
diff --git a/src/master/metrics.hpp b/src/master/metrics.hpp
index 4765e07..68bf415 100644
--- a/src/master/metrics.hpp
+++ b/src/master/metrics.hpp
@@ -22,6 +22,7 @@
#include <process/metrics/counter.hpp>
#include <process/metrics/pull_gauge.hpp>
+#include <process/metrics/push_gauge.hpp>
#include <process/metrics/metrics.hpp>
#include <stout/hashmap.hpp>
@@ -222,6 +223,8 @@ struct FrameworkMetrics
~FrameworkMetrics();
const FrameworkInfo frameworkInfo;
+
+ process::metrics::PushGauge subscribed;
};