You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2011/06/05 11:08:20 UTC

svn commit: r1132255 - in /incubator/mesos/trunk/src: slave/process_based_isolation_module.cpp slave/slave.cpp slave/slave.hpp webui/slave/webui.py

Author: benh
Date: Sun Jun  5 09:08:19 2011
New Revision: 1132255

URL: http://svn.apache.org/viewvc?rev=1132255&view=rev
Log:
Updates to get webui working with multiple executors. Note that this is just a temporary solution for the webui.

Modified:
    incubator/mesos/trunk/src/slave/process_based_isolation_module.cpp
    incubator/mesos/trunk/src/slave/slave.cpp
    incubator/mesos/trunk/src/slave/slave.hpp
    incubator/mesos/trunk/src/webui/slave/webui.py

Modified: incubator/mesos/trunk/src/slave/process_based_isolation_module.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/process_based_isolation_module.cpp?rev=1132255&r1=1132254&r2=1132255&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/process_based_isolation_module.cpp (original)
+++ incubator/mesos/trunk/src/slave/process_based_isolation_module.cpp Sun Jun  5 09:08:19 2011
@@ -128,7 +128,8 @@ ExecutorLauncher* ProcessBasedIsolationM
                          executor->info.executor_id(),
                          executor->info.uri(),
                          framework->info.user(),
-                         slave->getUniqueWorkDirectory(framework->frameworkId),
+                         slave->getUniqueWorkDirectory(framework->frameworkId,
+                                                       executor->info.executor_id()),
                          slave->self(),
                          slave->getConfiguration().get("frameworks_home", ""),
                          slave->getConfiguration().get("home", ""),

Modified: incubator/mesos/trunk/src/slave/slave.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/slave.cpp?rev=1132255&r1=1132254&r2=1132255&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/slave.cpp (original)
+++ incubator/mesos/trunk/src/slave/slave.cpp Sun Jun  5 09:08:19 2011
@@ -94,42 +94,51 @@ state::SlaveState *Slave::getState()
     new state::SlaveState(BUILD_DATE, BUILD_USER, slaveId.value(),
                           cpus.value(), mem.value(), self(), master);
 
-//   foreachpair (_, Framework *f, frameworks) {
+  foreachpair (_, Framework *f, frameworks) {
+    foreachpair (_, Executor* e, f->executors) {
+      Resources resources(e->resources);
+      Resource::Scalar cpus;
+      Resource::Scalar mem;
+      cpus.set_value(-1);
+      mem.set_value(-1);
+      cpus = resources.getScalar("cpus", cpus);
+      mem = resources.getScalar("mem", mem);
+
+      // TOOD(benh): For now, we will add a state::Framework object
+      // for each executor that the framework has. Therefore, we tweak
+      // the framework ID to also include the associated executor ID
+      // to differentiate them. This is so we don't have to make very
+      // many changes to the webui right now. Note that this ID
+      // construction must be identical to what we do for directory
+      // suffix returned from Slave::getUniqueWorkDirectory.
+
+      string id = f->frameworkId.value() + "-" + e->info.executor_id().value();
+
+      state::Framework *framework =
+        new state::Framework(id, f->info.name(),
+                             e->info.uri(), e->executorStatus,
+                             cpus.value(), mem.value());
+
+      state->frameworks.push_back(framework);
+
+      foreachpair (_, Task *t, e->tasks) {
+        Resources resources(t->resources());
+        Resource::Scalar cpus;
+        Resource::Scalar mem;
+        cpus.set_value(-1);
+        mem.set_value(-1);
+        cpus = resources.getScalar("cpus", cpus);
+        mem = resources.getScalar("mem", mem);
+
+        state::Task *task =
+          new state::Task(t->task_id().value(), t->name(),
+                          TaskState_descriptor()->FindValueByNumber(t->state())->name(),
+                          cpus.value(), mem.value());
 
-//     foreachpair (_, Executor* e, f->executors) {
-
-//       Resources resources(e->resources);
-//       Resource::Scalar cpus;
-//       Resource::Scalar mem;
-//       cpus.set_value(-1);
-//       mem.set_value(-1);
-//       cpus = resources.getScalar("cpus", cpus);
-//       mem = resources.getScalar("mem", mem);
-
-//     state::Framework *framework =
-//       new state::Framework(f->frameworkId.value(), f->info.name(),
-//                            f->info.executor().uri(), f->executorStatus,
-//                            cpus.value(), mem.value());
-
-//     state->frameworks.push_back(framework);
-
-//     foreachpair(_, Task *t, f->tasks) {
-//       Resources resources(t->resources());
-//       Resource::Scalar cpus;
-//       Resource::Scalar mem;
-//       cpus.set_value(-1);
-//       mem.set_value(-1);
-//       cpus = resources.getScalar("cpus", cpus);
-//       mem = resources.getScalar("mem", mem);
-
-//       state::Task *task =
-//         new state::Task(t->task_id().value(), t->name(),
-//                         TaskState_descriptor()->FindValueByNumber(t->state())->name(),
-//                         cpus.value(), mem.value());
-
-//       framework->tasks.push_back(task);
-//     }
-//   }
+        framework->tasks.push_back(task);
+      }
+    }
+  }
 
   return state;
 }
@@ -704,7 +713,8 @@ void Slave::executorExited(const Framewo
 };
 
 
-string Slave::getUniqueWorkDirectory(const FrameworkID& frameworkId)
+string Slave::getUniqueWorkDirectory(const FrameworkID& frameworkId,
+                                     const ExecutorID& executorId)
 {
   string workDir;
   if (conf.contains("work_dir")) {
@@ -716,7 +726,8 @@ string Slave::getUniqueWorkDirectory(con
   }
 
   ostringstream os(std::ios_base::app | std::ios_base::out);
-  os << workDir << "/slave-" << slaveId << "/fw-" << frameworkId;
+  os << workDir << "/slave-" << slaveId
+     << "/fw-" << frameworkId << "-" << executorId;
 
   // Find a unique directory based on the path given by the slave
   // (this is because we might launch multiple executors from the same

Modified: incubator/mesos/trunk/src/slave/slave.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/slave.hpp?rev=1132255&r1=1132254&r2=1132255&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/slave.hpp (original)
+++ incubator/mesos/trunk/src/slave/slave.hpp Sun Jun  5 09:08:19 2011
@@ -228,7 +228,7 @@ public:
 
   static void registerOptions(Configurator* conf);
 
-  state::SlaveState *getState();
+  state::SlaveState* getState();
 
   // Callback used by isolation module to tell us when an executor exits.
   void executorExited(const FrameworkID& frameworkId, const ExecutorID& executorId, int status);
@@ -236,7 +236,7 @@ public:
   // Kill a framework (possibly killing its executor).
   void killFramework(Framework *framework, bool killExecutors = true);
 
-  std::string getUniqueWorkDirectory(const FrameworkID& frameworkId);
+  std::string getUniqueWorkDirectory(const FrameworkID& frameworkId, const ExecutorID& executorId);
 
   const Configuration& getConfiguration();
 

Modified: incubator/mesos/trunk/src/webui/slave/webui.py
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/webui/slave/webui.py?rev=1132255&r1=1132254&r2=1132255&view=diff
==============================================================================
--- incubator/mesos/trunk/src/webui/slave/webui.py (original)
+++ incubator/mesos/trunk/src/webui/slave/webui.py Sun Jun  5 09:08:19 2011
@@ -16,7 +16,7 @@ def index():
   return template("index", start_time = start_time)
 
 
-@route('/framework/:id#[0-9-]*#')
+@route('/framework/:id#.*#')
 def framework(id):
   bottle.TEMPLATES.clear() # For rapid development
   return template("framework", framework_id = id)
@@ -39,7 +39,7 @@ def log_tail(level, lines):
   return commands.getoutput('tail -%s %s/mesos-slave.%s' % (lines, log_dir, level))
 
 
-@route('/framework-logs/:fid#[0-9-]*#/:log_type#[a-z]*#')
+@route('/framework-logs/:fid#.*#/:log_type#[a-z]*#')
 def framework_log_full(fid, log_type):
   sid = get_slave().id
   if sid != -1:
@@ -52,7 +52,7 @@ def framework_log_full(fid, log_type):
     abort(403, 'Slave not yet registered with master')
 
 
-@route('/framework-logs/:fid#[0-9-]*#/:log_type#[a-z]*#/:lines#[0-9]*#')
+@route('/framework-logs/:fid#.*#/:log_type#[a-z]*#/:lines#[0-9]*#')
 def framework_log_tail(fid, log_type, lines):
   bottle.response.content_type = 'text/plain'
   sid = get_slave().id