You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2013/08/13 21:49:55 UTC
[11/23] git commit: Fixed slave to create work directory during
initialization.
Fixed slave to create work directory during initialization.
Review: https://reviews.apache.org/r/12010
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/7c306d77
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/7c306d77
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/7c306d77
Branch: refs/heads/vinod/0.13.0
Commit: 7c306d77a24fcbaf201f20267a9019fc0fc9dd29
Parents: 09f4c11
Author: Vinod Kone <vi...@twitter.com>
Authored: Thu Jun 20 10:24:24 2013 -0700
Committer: Vinod Kone <vi...@twitter.com>
Committed: Mon Jul 1 12:17:50 2013 -0700
----------------------------------------------------------------------
src/slave/slave.cpp | 68 ++++++++++++++++++++----------------------------
src/slave/slave.hpp | 5 ----
2 files changed, 28 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/7c306d77/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index fd96de9..c5380b8 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -76,15 +76,14 @@ namespace slave {
using namespace state;
-Slave::Slave(const Resources& _resources,
+Slave::Slave(const slave::Flags& _flags,
bool _local,
Isolator* _isolator,
Files* _files)
: ProcessBase(ID::generate("slave")),
state(RECOVERING),
- flags(),
+ flags(_flags),
local(_local),
- resources(_resources),
completedFrameworks(MAX_COMPLETED_FRAMEWORKS),
isolator(_isolator),
files(_files),
@@ -93,23 +92,32 @@ Slave::Slave(const Resources& _resources,
metaDir(paths::getMetaRootDir(flags.work_dir)) {}
-Slave::Slave(const slave::Flags& _flags,
- bool _local,
- Isolator* _isolator,
- Files* _files)
- : ProcessBase(ID::generate("slave")),
- state(RECOVERING),
- flags(_flags),
- local(_local),
- completedFrameworks(MAX_COMPLETED_FRAMEWORKS),
- isolator(_isolator),
- files(_files),
- monitor(_isolator),
- statusUpdateManager(new StatusUpdateManager()),
- metaDir(paths::getMetaRootDir(flags.work_dir))
+Slave::~Slave()
{
- // TODO(benh): Move this computation into Flags as the "default".
+ // TODO(benh): Shut down frameworks?
+
+ // TODO(benh): Shut down executors? The executor should get an "exited"
+ // event and initiate a shut down itself.
+ foreachvalue (Framework* framework, frameworks) {
+ delete framework;
+ }
+
+ delete statusUpdateManager;
+}
+
+
+void Slave::initialize()
+{
+ LOG(INFO) << "Slave started on " << string(self()).substr(6);
+
+ // Ensure slave work directory exists.
+ CHECK_SOME(os::mkdir(flags.work_dir))
+ << "Failed to create slave work directory '" << flags.work_dir << "'";
+
+ // Properly set up resources.
+ // TODO(benh): Move this computation into Flags as the "default".
+ // TODO(vinod): Move some of this computation into Resources.
resources = Resources::parse(
flags.resources.isSome() ? flags.resources.get() : "");
@@ -190,31 +198,11 @@ Slave::Slave(const slave::Flags& _flags,
resources = Resources::parse(defaults.get());
+ LOG(INFO) << "Slave resources: " << resources;
+
if (flags.attributes.isSome()) {
attributes = Attributes::parse(flags.attributes.get());
}
-}
-
-
-Slave::~Slave()
-{
- // TODO(benh): Shut down frameworks?
-
- // TODO(benh): Shut down executors? The executor should get an "exited"
- // event and initiate a shut down itself.
-
- foreachvalue (Framework* framework, frameworks) {
- delete framework;
- }
-
- delete statusUpdateManager;
-}
-
-
-void Slave::initialize()
-{
- LOG(INFO) << "Slave started on " << string(self()).substr(6);
- LOG(INFO) << "Slave resources: " << resources;
// Determine our hostname.
Try<string> result = os::hostname();
http://git-wip-us.apache.org/repos/asf/mesos/blob/7c306d77/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index d1ba82e..3a147f0 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -74,11 +74,6 @@ struct Framework;
class Slave : public ProtobufProcess<Slave>
{
public:
- Slave(const Resources& resources,
- bool local,
- Isolator* isolator,
- Files* files);
-
Slave(const Flags& flags,
bool local,
Isolator *isolator,