mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ji...@apache.org
Subject git commit: Added executor metrics for slave.
Date Wed, 06 Aug 2014 19:59:24 GMT
Repository: mesos
Updated Branches:
  refs/heads/master 5e94bf097 -> f63d94472


Added executor metrics for slave.

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


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

Branch: refs/heads/master
Commit: f63d94472b921a3d288874c8053a26db291b9266
Parents: 5e94bf0
Author: Jie Yu <yujie.jay@gmail.com>
Authored: Tue Aug 5 17:14:43 2014 -0700
Committer: Jie Yu <yujie.jay@gmail.com>
Committed: Wed Aug 6 12:59:05 2014 -0700

----------------------------------------------------------------------
 src/slave/slave.cpp       | 67 ++++++++++++++++++++++++++++++++++++++++++
 src/slave/slave.hpp       |  9 ++++++
 src/tests/slave_tests.cpp |  5 ++++
 3 files changed, 81 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/f63d9447/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index f5ccb73..fb40273 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -2599,6 +2599,8 @@ void Slave::executorTerminated(
     case Executor::REGISTERING:
     case Executor::RUNNING:
     case Executor::TERMINATING: {
+      ++metrics.executors_terminated;
+
       executor->state = Executor::TERMINATED;
 
       // Stop monitoring the executor's container.
@@ -3340,6 +3342,48 @@ double Slave::_tasks_running()
 }
 
 
+double Slave::_executors_registering()
+{
+  double count = 0.0;
+  foreachvalue (Framework* framework, frameworks) {
+    foreachvalue (Executor* executor, framework->executors) {
+      if (executor->state == Executor::REGISTERING) {
+        count++;
+      }
+    }
+  }
+  return count;
+}
+
+
+double Slave::_executors_running()
+{
+  double count = 0.0;
+  foreachvalue (Framework* framework, frameworks) {
+    foreachvalue (Executor* executor, framework->executors) {
+      if (executor->state == Executor::RUNNING) {
+        count++;
+      }
+    }
+  }
+  return count;
+}
+
+
+double Slave::_executors_terminating()
+{
+  double count = 0.0;
+  foreachvalue (Framework* framework, frameworks) {
+    foreachvalue (Executor* executor, framework->executors) {
+      if (executor->state == Executor::TERMINATING) {
+        count++;
+      }
+    }
+  }
+  return count;
+}
+
+
 Slave::Metrics::Metrics(const Slave& slave)
   : uptime_secs(
         "slave/uptime_secs",
@@ -3369,6 +3413,17 @@ Slave::Metrics::Metrics(const Slave& slave)
         "slave/tasks_killed"),
     tasks_lost(
         "slave/tasks_lost"),
+    executors_registering(
+        "slave/executors_registering",
+        defer(slave, &Slave::_executors_registering)),
+    executors_running(
+        "slave/executors_running",
+        defer(slave, &Slave::_executors_running)),
+    executors_terminating(
+        "slave/executors_terminating",
+        defer(slave, &Slave::_executors_terminating)),
+    executors_terminated(
+        "slave/executors_terminated"),
     valid_status_updates(
         "slave/valid_status_updates"),
     invalid_status_updates(
@@ -3394,6 +3449,11 @@ Slave::Metrics::Metrics(const Slave& slave)
   process::metrics::add(tasks_killed);
   process::metrics::add(tasks_lost);
 
+  process::metrics::add(executors_registering);
+  process::metrics::add(executors_running);
+  process::metrics::add(executors_terminating);
+  process::metrics::add(executors_terminated);
+
   process::metrics::add(valid_status_updates);
   process::metrics::add(invalid_status_updates);
 
@@ -3420,6 +3480,11 @@ Slave::Metrics::~Metrics()
   process::metrics::remove(tasks_killed);
   process::metrics::remove(tasks_lost);
 
+  process::metrics::remove(executors_registering);
+  process::metrics::remove(executors_running);
+  process::metrics::remove(executors_terminating);
+  process::metrics::remove(executors_terminated);
+
   process::metrics::remove(valid_status_updates);
   process::metrics::remove(invalid_status_updates);
 
@@ -3698,6 +3763,8 @@ void Framework::recoverExecutor(const ExecutorState& state)
   // and all updates are acknowledged) in the previous run, we
   // transition its state to 'TERMINATED' and gc the directories.
   if (run.get().completed) {
+    ++slave->metrics.executors_terminated;
+
     executor->state = Executor::TERMINATED;
 
     CHECK_SOME(run.get().id);

http://git-wip-us.apache.org/repos/asf/mesos/blob/f63d9447/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index c12cd0a..9d4607e 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -371,6 +371,10 @@ private:
   double _tasks_starting();
   double _tasks_running();
 
+  double _executors_registering();
+  double _executors_running();
+  double _executors_terminating();
+
   const Flags flags;
 
   SlaveInfo info;
@@ -421,6 +425,11 @@ private:
     process::metrics::Counter tasks_killed;
     process::metrics::Counter tasks_lost;
 
+    process::metrics::Gauge executors_registering;
+    process::metrics::Gauge executors_running;
+    process::metrics::Gauge executors_terminating;
+    process::metrics::Counter executors_terminated;
+
     process::metrics::Counter valid_status_updates;
     process::metrics::Counter invalid_status_updates;
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/f63d9447/src/tests/slave_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_tests.cpp b/src/tests/slave_tests.cpp
index 3a7fee6..69be28f 100644
--- a/src/tests/slave_tests.cpp
+++ b/src/tests/slave_tests.cpp
@@ -697,6 +697,11 @@ TEST_F(SlaveTest, MetricsInStatsEndpoint)
   EXPECT_EQ(1u, stats.values.count("slave/tasks_killed"));
   EXPECT_EQ(1u, stats.values.count("slave/tasks_lost"));
 
+  EXPECT_EQ(1u, stats.values.count("slave/executors_registering"));
+  EXPECT_EQ(1u, stats.values.count("slave/executors_running"));
+  EXPECT_EQ(1u, stats.values.count("slave/executors_terminating"));
+  EXPECT_EQ(1u, stats.values.count("slave/executors_terminated"));
+
   EXPECT_EQ(1u, stats.values.count("slave/valid_status_updates"));
   EXPECT_EQ(1u, stats.values.count("slave/invalid_status_updates"));
 


Mime
View raw message