You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2015/04/25 01:37:01 UTC
[3/4] mesos git commit: Made the launcher recover interface to return
a set of orphan containers.
Made the launcher recover interface to return a set of orphan
containers.
Review: https://reviews.apache.org/r/33412
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/24c78a15
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/24c78a15
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/24c78a15
Branch: refs/heads/master
Commit: 24c78a156f68f09de2c7b6729e077547edf768db
Parents: edaaccf
Author: Jie Yu <yu...@gmail.com>
Authored: Mon Apr 20 12:17:51 2015 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Apr 24 16:36:30 2015 -0700
----------------------------------------------------------------------
src/slave/containerizer/launcher.cpp | 13 ++++++-------
src/slave/containerizer/launcher.hpp | 12 ++++++++++--
src/slave/containerizer/linux_launcher.cpp | 7 ++++---
src/slave/containerizer/linux_launcher.hpp | 3 +--
src/tests/launcher.hpp | 2 +-
5 files changed, 22 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/24c78a15/src/slave/containerizer/launcher.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/launcher.cpp b/src/slave/containerizer/launcher.cpp
index eb798fa..24df1ca 100644
--- a/src/slave/containerizer/launcher.cpp
+++ b/src/slave/containerizer/launcher.cpp
@@ -36,12 +36,12 @@ using std::map;
using std::string;
using std::vector;
+using mesos::slave::ExecutorRunState;
+
namespace mesos {
namespace internal {
namespace slave {
-using mesos::slave::ExecutorRunState;
-
Try<Launcher*> PosixLauncher::create(const Flags& flags)
{
@@ -49,7 +49,8 @@ Try<Launcher*> PosixLauncher::create(const Flags& flags)
}
-Future<Nothing> PosixLauncher::recover(const list<ExecutorRunState>& states)
+Future<hashset<ContainerID>> PosixLauncher::recover(
+ const list<ExecutorRunState>& states)
{
foreach (const ExecutorRunState& state, states) {
const ContainerID& containerId = state.id;
@@ -70,7 +71,7 @@ Future<Nothing> PosixLauncher::recover(const list<ExecutorRunState>& states)
pids.put(containerId, pid);
}
- return Nothing();
+ return hashset<ContainerID>();
}
@@ -150,8 +151,7 @@ Future<Nothing> PosixLauncher::destroy(const ContainerID& containerId)
pid_t pid = pids.get(containerId).get();
// Kill all processes in the session and process group.
- Try<list<os::ProcessTree>> trees =
- os::killtree(pid, SIGKILL, true, true);
+ Try<list<os::ProcessTree>> trees = os::killtree(pid, SIGKILL, true, true);
pids.erase(containerId);
@@ -172,7 +172,6 @@ Future<Nothing> _destroy(const Future<Option<int>>& future)
}
}
-
} // namespace slave {
} // namespace internal {
} // namespace mesos {
http://git-wip-us.apache.org/repos/asf/mesos/blob/24c78a15/src/slave/containerizer/launcher.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/launcher.hpp b/src/slave/containerizer/launcher.hpp
index 95a7f76..a19b859 100644
--- a/src/slave/containerizer/launcher.hpp
+++ b/src/slave/containerizer/launcher.hpp
@@ -19,16 +19,22 @@
#ifndef __LAUNCHER_HPP__
#define __LAUNCHER_HPP__
+#include <sys/types.h>
+
#include <list>
#include <map>
#include <string>
+#include <mesos/mesos.hpp>
+
#include <mesos/slave/isolator.hpp>
#include <process/future.hpp>
#include <process/subprocess.hpp>
#include <stout/flags.hpp>
+#include <stout/hashmap.hpp>
+#include <stout/hashset.hpp>
#include <stout/lambda.hpp>
#include <stout/option.hpp>
#include <stout/try.hpp>
@@ -45,7 +51,9 @@ public:
virtual ~Launcher() {}
// Recover the necessary state for each container listed in state.
- virtual process::Future<Nothing> recover(
+ // Return the set of containers that are known to the launcher but
+ // not known to the slave (a.k.a. orphans).
+ virtual process::Future<hashset<ContainerID>> recover(
const std::list<mesos::slave::ExecutorRunState>& states) = 0;
// Fork a new process in the containerized context. The child will
@@ -82,7 +90,7 @@ public:
virtual ~PosixLauncher() {}
- virtual process::Future<Nothing> recover(
+ virtual process::Future<hashset<ContainerID>> recover(
const std::list<mesos::slave::ExecutorRunState>& states);
virtual Try<pid_t> fork(
http://git-wip-us.apache.org/repos/asf/mesos/blob/24c78a15/src/slave/containerizer/linux_launcher.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/linux_launcher.cpp b/src/slave/containerizer/linux_launcher.cpp
index b176ac1..9d2e813 100644
--- a/src/slave/containerizer/linux_launcher.cpp
+++ b/src/slave/containerizer/linux_launcher.cpp
@@ -119,13 +119,14 @@ Try<Launcher*> LinuxLauncher::create(const Flags& flags)
}
-Future<Nothing> _recover(const Future<list<Nothing>>& futures)
+static Future<hashset<ContainerID>> _recover(
+ const Future<list<Nothing>>& futures)
{
- return Nothing();
+ return hashset<ContainerID>();
}
-Future<Nothing> LinuxLauncher::recover(
+Future<hashset<ContainerID>> LinuxLauncher::recover(
const std::list<ExecutorRunState>& states)
{
hashset<string> cgroups;
http://git-wip-us.apache.org/repos/asf/mesos/blob/24c78a15/src/slave/containerizer/linux_launcher.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/linux_launcher.hpp b/src/slave/containerizer/linux_launcher.hpp
index 60082c7..2b95571 100644
--- a/src/slave/containerizer/linux_launcher.hpp
+++ b/src/slave/containerizer/linux_launcher.hpp
@@ -34,7 +34,7 @@ public:
virtual ~LinuxLauncher() {}
- virtual process::Future<Nothing> recover(
+ virtual process::Future<hashset<ContainerID>> recover(
const std::list<mesos::slave::ExecutorRunState>& states);
virtual Try<pid_t> fork(
@@ -68,7 +68,6 @@ private:
hashmap<ContainerID, pid_t> pids;
};
-
} // namespace slave {
} // namespace internal {
} // namespace mesos {
http://git-wip-us.apache.org/repos/asf/mesos/blob/24c78a15/src/tests/launcher.hpp
----------------------------------------------------------------------
diff --git a/src/tests/launcher.hpp b/src/tests/launcher.hpp
index 81ae95c..78216e0 100644
--- a/src/tests/launcher.hpp
+++ b/src/tests/launcher.hpp
@@ -91,7 +91,7 @@ public:
MOCK_METHOD1(
recover,
- process::Future<Nothing>(
+ process::Future<hashset<ContainerID>>(
const std::list<mesos::slave::ExecutorRunState>& states));
MOCK_METHOD9(