You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by an...@apache.org on 2011/11/23 09:26:18 UTC
svn commit: r1205324 - in /incubator/mesos/trunk/src:
configurator/configuration.hpp slave/slave.cpp
Author: andrew
Date: Wed Nov 23 08:26:17 2011
New Revision: 1205324
URL: http://svn.apache.org/viewvc?rev=1205324&view=rev
Log:
Fixes MESOS-35. Thanks to Ben for the in-person code review
and pair programming!
Modified:
incubator/mesos/trunk/src/configurator/configuration.hpp
incubator/mesos/trunk/src/slave/slave.cpp
Modified: incubator/mesos/trunk/src/configurator/configuration.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/configurator/configuration.hpp?rev=1205324&r1=1205323&r2=1205324&view=diff
==============================================================================
--- incubator/mesos/trunk/src/configurator/configuration.hpp (original)
+++ incubator/mesos/trunk/src/configurator/configuration.hpp Wed Nov 23 08:26:17 2011
@@ -27,6 +27,7 @@
#include <boost/lexical_cast.hpp>
#include "common/foreach.hpp"
+#include "common/option.hpp"
#include "common/strings.hpp"
@@ -96,6 +97,14 @@ public:
return params[key];
}
+ Option<std::string> get(const std::string& key) const
+ {
+ if (!contains(key)) {
+ return Option<std::string>::none();
+ }
+ return get(key, "");
+ }
+
const std::string& get(const std::string& key,
const std::string& defaultValue) const
{
Modified: incubator/mesos/trunk/src/slave/slave.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/slave.cpp?rev=1205324&r1=1205323&r2=1205324&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/slave.cpp (original)
+++ incubator/mesos/trunk/src/slave/slave.cpp Wed Nov 23 08:26:17 2011
@@ -24,6 +24,7 @@
#include <process/timer.hpp>
#include "common/build.hpp"
+#include "common/option.hpp"
#include "common/type_utils.hpp"
#include "common/utils.hpp"
@@ -1386,14 +1387,17 @@ string Slave::createUniqueWorkDirectory(
LOG(INFO) << "Generating a unique work directory for executor '"
<< executorId << "' of framework " << frameworkId;
- string workDir = ".";
- if (conf.contains("work_dir")) {
- workDir = conf.get("work_dir", workDir);
- } else if (conf.contains("home")) {
- workDir = conf.get("home", workDir);
+ string workDir = "work"; // No relevant conf options set.
+ Option<string> option = conf.get("work_dir");
+ if (!option.isSome()) {
+ option = conf.get("home");
+ if (option.isSome()) {
+ workDir = option.get() + "/work";
+ }
+ } else {
+ workDir = option.get();
}
- workDir = workDir + "/work";
std::ostringstream out(std::ios_base::app | std::ios_base::out);
out << workDir << "/slaves/" << id