mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ji...@apache.org
Subject mesos git commit: Added CHECK's for various executor states in Command Executor to verify if messages are delivered in order.
Date Wed, 30 Dec 2015 20:50:43 GMT
Repository: mesos
Updated Branches:
  refs/heads/master 8cfd5f6f8 -> d35513930


Added CHECK's for various executor states in Command Executor to verify
if messages are delivered in order.

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


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

Branch: refs/heads/master
Commit: d3551393019d0ddbc2cf8ed1c73ded088b61871f
Parents: 8cfd5f6
Author: Anand Mazumdar <mazumdar.anand@gmail.com>
Authored: Wed Dec 30 12:50:28 2015 -0800
Committer: Jie Yu <yujie.jay@gmail.com>
Committed: Wed Dec 30 12:50:28 2015 -0800

----------------------------------------------------------------------
 src/launcher/executor.cpp | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/d3551393/src/launcher/executor.cpp
----------------------------------------------------------------------
diff --git a/src/launcher/executor.cpp b/src/launcher/executor.cpp
index 09e7de6..356d311 100644
--- a/src/launcher/executor.cpp
+++ b/src/launcher/executor.cpp
@@ -82,7 +82,8 @@ public:
       const string& _healthCheckDir,
       const Option<string>& _sandboxDirectory,
       const Option<string>& _user)
-    : launched(false),
+    : state(REGISTERING),
+      launched(false),
       killed(false),
       killedByHealthCheck(false),
       pid(-1),
@@ -102,21 +103,29 @@ public:
       const FrameworkInfo& frameworkInfo,
       const SlaveInfo& slaveInfo)
   {
+    CHECK_EQ(REGISTERING, state);
+
     cout << "Registered executor on " << slaveInfo.hostname() << endl;
     driver = _driver;
+    state = REGISTERED;
   }
 
   void reregistered(
       ExecutorDriver* driver,
       const SlaveInfo& slaveInfo)
   {
+    CHECK(state == REGISTERED || state == REGISTERING) << state;
+
     cout << "Re-registered executor on " << slaveInfo.hostname() << endl;
+    state = REGISTERED;
   }
 
   void disconnected(ExecutorDriver* driver) {}
 
   void launchTask(ExecutorDriver* driver, const TaskInfo& task)
   {
+    CHECK_EQ(REGISTERED, state);
+
     if (launched) {
       TaskStatus status;
       status.mutable_task_id()->MergeFrom(task.task_id());
@@ -482,31 +491,31 @@ private:
       pid_t pid,
       const Future<Option<int> >& status_)
   {
-    TaskState state;
+    TaskState taskState;
     string message;
 
     Clock::cancel(escalationTimer);
 
     if (!status_.isReady()) {
-      state = TASK_FAILED;
+      taskState = TASK_FAILED;
       message =
         "Failed to get exit status for Command: " +
         (status_.isFailed() ? status_.failure() : "future discarded");
     } else if (status_.get().isNone()) {
-      state = TASK_FAILED;
+      taskState = TASK_FAILED;
       message = "Failed to get exit status for Command";
     } else {
       int status = status_.get().get();
       CHECK(WIFEXITED(status) || WIFSIGNALED(status)) << status;
 
       if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
-        state = TASK_FINISHED;
+        taskState = TASK_FINISHED;
       } else if (killed) {
         // Send TASK_KILLED if the task was killed as a result of
         // killTask() or shutdown().
-        state = TASK_KILLED;
+        taskState = TASK_KILLED;
       } else {
-        state = TASK_FAILED;
+        taskState = TASK_FAILED;
       }
 
       message = "Command " + WSTRINGIFY(status);
@@ -516,7 +525,7 @@ private:
 
     TaskStatus taskStatus;
     taskStatus.mutable_task_id()->MergeFrom(taskId);
-    taskStatus.set_state(state);
+    taskStatus.set_state(taskState);
     taskStatus.set_message(message);
     if (killed && killedByHealthCheck) {
       taskStatus.set_healthy(false);
@@ -597,6 +606,12 @@ private:
     }
   }
 
+  enum State
+  {
+    REGISTERING, // Executor is launched but not (re-)registered yet.
+    REGISTERED,  // Executor has (re-)registered.
+  } state;
+
   bool launched;
   bool killed;
   bool killedByHealthCheck;


Mime
View raw message