Repository: mesos
Updated Branches:
  refs/heads/master 9000e9190 -> 517e84669


Added support for recovering RunState for HTTP based executors.

This change adds support for recovering the `RunState` for `HTTP` based
executors. Upon agent recovery, it checks if the marker file for HTTP
exists and populates `RunState.http` based on that. This is later used
by the Agent for recovering `HTTP` based executors.

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


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

Branch: refs/heads/master
Commit: ebff7ce003f08f2d92af7e28e843f7844f065cab
Parents: 9000e91
Author: Anand Mazumdar <[email protected]>
Authored: Fri Dec 4 15:24:29 2015 -0800
Committer: Vinod Kone <[email protected]>
Committed: Fri Dec 4 15:24:30 2015 -0800

----------------------------------------------------------------------
 src/slave/state.cpp | 56 ++++++++++++++++++++++++++++--------------------
 src/slave/state.hpp |  4 ++++
 2 files changed, 37 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ebff7ce0/src/slave/state.cpp
----------------------------------------------------------------------
diff --git a/src/slave/state.cpp b/src/slave/state.cpp
index bc46cc6..9e470cb 100644
--- a/src/slave/state.cpp
+++ b/src/slave/state.cpp
@@ -500,37 +500,47 @@ Try<RunState> RunState::recover(
   path = paths::getLibprocessPidPath(
       rootDir, slaveId, frameworkId, executorId, containerId);
 
-  if (!os::exists(path)) {
-    // This could happen if the slave died before the executor
-    // registered with the slave.
-    LOG(WARNING)
-      << "Failed to find executor libprocess pid file '" << path << "'";
-    return state;
-  }
-
-  pid = os::read(path);
-
-  if (pid.isError()) {
-    message = "Failed to read executor libprocess pid from '" + path +
-              "': " + pid.error();
+  if (os::exists(path)) {
+    pid = os::read(path);
+
+    if (pid.isError()) {
+      message = "Failed to read executor libprocess pid from '" + path +
+                "': " + pid.error();
+
+      if (strict) {
+        return Error(message);
+      } else {
+        LOG(WARNING) << message;
+        state.errors++;
+        return state;
+      }
+    }
 
-    if (strict) {
-      return Error(message);
-    } else {
-      LOG(WARNING) << message;
-      state.errors++;
+    if (pid.get().empty()) {
+      // This could happen if the slave died after opening the file for
+      // writing but before it checkpointed anything.
+      LOG(WARNING) << "Found empty executor libprocess pid file '" << path
+                   << "'";
       return state;
     }
+
+    state.libprocessPid = process::UPID(pid.get());
+    state.http = false;
+
+    return state;
   }
 
-  if (pid.get().empty()) {
-    // This could happen if the slave died after opening the file for
-    // writing but before it checkpointed anything.
-    LOG(WARNING) << "Found empty executor libprocess pid file '" << path << 
"'";
+  path = paths::getExecutorHttpMarkerPath(
+      rootDir, slaveId, frameworkId, executorId, containerId);
+
+  if (!os::exists(path)) {
+    // This could happen if the slave died before the executor
+    // registered with the slave.
+    LOG(WARNING) << "Failed to find executor libprocess pid/http marker file";
     return state;
   }
 
-  state.libprocessPid = process::UPID(pid.get());
+  state.http = true;
 
   return state;
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/ebff7ce0/src/slave/state.hpp
----------------------------------------------------------------------
diff --git a/src/slave/state.hpp b/src/slave/state.hpp
index eb6b06c..d4235d5 100644
--- a/src/slave/state.hpp
+++ b/src/slave/state.hpp
@@ -207,6 +207,10 @@ struct RunState
   Option<pid_t> forkedPid;
   Option<process::UPID> libprocessPid;
 
+  // This represents if the executor is connected via HTTP. It can be None()
+  // when the connection type is unknown.
+  Option<bool> http;
+
   // Executor terminated and all its updates acknowledged.
   bool completed;
 

Reply via email to