Added helper function for the agent to send `ExitedExecutorMessage`.

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


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

Branch: refs/heads/master
Commit: 0321b85ce66f21e9cb6990a3032cb7f8f709c6e6
Parents: ce7f1f6
Author: Meng Zhu <m...@mesosphere.io>
Authored: Tue Feb 13 22:45:03 2018 -0800
Committer: Greg Mann <gregorywm...@gmail.com>
Committed: Wed Feb 14 02:31:11 2018 -0800

----------------------------------------------------------------------
 src/slave/slave.cpp | 25 ++++++++++++++++++-------
 src/slave/slave.hpp |  5 +++++
 2 files changed, 23 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/0321b85c/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 893a196..f96c97e 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -6071,13 +6071,7 @@ void Slave::executorTerminated(
       // are generated by the slave.
       // TODO(vinod): Reliably forward this message to the master.
       if (!executor->isGeneratedForCommandTask()) {
-        ExitedExecutorMessage message;
-        message.mutable_slave_id()->MergeFrom(info.id());
-        message.mutable_framework_id()->MergeFrom(frameworkId);
-        message.mutable_executor_id()->MergeFrom(executorId);
-        message.set_status(status);
-
-        if (master.isSome()) { send(master.get(), message); }
+        sendExitedExecutorMessage(frameworkId, executorId, status);
       }
 
       // Remove the executor if either the slave or framework is
@@ -8295,6 +8289,23 @@ void Slave::sendExecutorTerminatedStatusUpdate(
 }
 
 
+void Slave::sendExitedExecutorMessage(
+    const FrameworkID& frameworkId,
+    const ExecutorID& executorId,
+    const Option<int>& status)
+{
+  ExitedExecutorMessage message;
+  message.mutable_slave_id()->MergeFrom(info.id());
+  message.mutable_framework_id()->MergeFrom(frameworkId);
+  message.mutable_executor_id()->MergeFrom(executorId);
+  message.set_status(status.getOrElse(-1));
+
+  if (master.isSome()) {
+    send(master.get(), message);
+  }
+}
+
+
 // TODO(dhamon): Move these to their own metrics.hpp|cpp.
 double Slave::_tasks_staging()
 {

http://git-wip-us.apache.org/repos/asf/mesos/blob/0321b85c/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index b2c7880..7840ce8 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -615,6 +615,11 @@ private:
       const FrameworkID& frameworkId,
       const Executor* executor);
 
+  void sendExitedExecutorMessage(
+      const FrameworkID& frameworkId,
+      const ExecutorID& executorId,
+      const Option<int>& status = None());
+
   // Forwards the current total of oversubscribed resources.
   void forwardOversubscribed();
   void _forwardOversubscribed(

Reply via email to