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 2014/11/20 21:50:48 UTC

[2/3] mesos git commit: Added a task reconciliation continuation for re-use in the Master.

Added a task reconciliation continuation for re-use in the Master.

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


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

Branch: refs/heads/master
Commit: b51e4ed2d25d69b7e21acfe58ca5ac367a6fc349
Parents: 74e1d9b
Author: Benjamin Mahler <bm...@twitter.com>
Authored: Wed Nov 19 16:07:25 2014 -0800
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Thu Nov 20 12:49:49 2014 -0800

----------------------------------------------------------------------
 src/master/master.cpp | 30 ++++++++++++++++++++----------
 src/master/master.hpp |  6 ++++++
 2 files changed, 26 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/b51e4ed2/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index de42f8e..2b01af4 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -3552,14 +3552,24 @@ void Master::reconcileTasks(
     return;
   }
 
+  _reconcileTasks(framework, statuses);
+}
+
+
+void Master::_reconcileTasks(
+    Framework* framework,
+    const vector<TaskStatus>& statuses)
+{
+  CHECK_NOTNULL(framework);
+
   if (statuses.empty()) {
     // Implicit reconciliation.
-    LOG(INFO) << "Performing implicit task state reconciliation for framework "
-              << *framework;
+    LOG(INFO) << "Performing implicit task state reconciliation"
+                 " for framework " << *framework;
 
     foreachvalue (const TaskInfo& task, framework->pendingTasks) {
       const StatusUpdate& update = protobuf::createStatusUpdate(
-          frameworkId,
+          framework->id,
           task.slave_id(),
           task.task_id(),
           TASK_STAGING,
@@ -3585,7 +3595,7 @@ void Master::reconcileTasks(
           : task->state();
 
       const StatusUpdate& update = protobuf::createStatusUpdate(
-          frameworkId,
+          framework->id,
           task->slave_id(),
           task->task_id(),
           state,
@@ -3638,7 +3648,7 @@ void Master::reconcileTasks(
       // (1) Task is known, but pending: TASK_STAGING.
       const TaskInfo& task_ = framework->pendingTasks[status.task_id()];
       update = protobuf::createStatusUpdate(
-          frameworkId,
+          framework->id,
           task_.slave_id(),
           task_.task_id(),
           TASK_STAGING,
@@ -3652,7 +3662,7 @@ void Master::reconcileTasks(
           : task->state();
 
       update = protobuf::createStatusUpdate(
-          frameworkId,
+          framework->id,
           task->slave_id(),
           task->task_id(),
           state,
@@ -3662,7 +3672,7 @@ void Master::reconcileTasks(
     } else if (slaveId.isSome() && slaves.registered.contains(slaveId.get())) {
       // (3) Task is unknown, slave is registered: TASK_LOST.
       update = protobuf::createStatusUpdate(
-          frameworkId,
+          framework->id,
           slaveId.get(),
           status.task_id(),
           TASK_LOST,
@@ -3671,13 +3681,13 @@ void Master::reconcileTasks(
           TaskStatus::REASON_RECONCILIATION);
     } else if (slaves.transitioning(slaveId)) {
       // (4) Task is unknown, slave is transitionary: no-op.
-      LOG(INFO) << "Ignoring reconciliation request of task "
-                << status.task_id() << " from framework " << *framework
+      LOG(INFO) << "Dropping reconciliation of task " << status.task_id()
+                << " for framework " << *framework
                 << " because there are transitional slaves";
     } else {
       // (5) Task is unknown, slave is unknown: TASK_LOST.
       update = protobuf::createStatusUpdate(
-          frameworkId,
+          framework->id,
           slaveId,
           status.task_id(),
           TASK_LOST,

http://git-wip-us.apache.org/repos/asf/mesos/blob/b51e4ed2/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index ece36c3..6eabb07 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -286,6 +286,12 @@ protected:
   // Invoked when the contender has entered the contest.
   void contended(const process::Future<process::Future<Nothing>>& candidacy);
 
+  // Task reconciliation, split from the message handler
+  // to allow re-use.
+  void _reconcileTasks(
+      Framework* framework,
+      const std::vector<TaskStatus>& statuses);
+
   // Handles a known re-registering slave by reconciling the master's
   // view of the slave's tasks and executors.
   void reconcile(