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 19:56:36 UTC

svn commit: r1205536 - in /incubator/mesos/trunk/src: master/constants.hpp master/http.cpp master/master.cpp master/master.hpp webui/master/framework.tpl webui/master/index.tpl

Author: andrew
Date: Wed Nov 23 18:56:35 2011
New Revision: 1205536

URL: http://svn.apache.org/viewvc?rev=1205536&view=rev
Log:
Fixes MESOS-8. Thanks Thomas Marshall for this patch!

Modified:
    incubator/mesos/trunk/src/master/constants.hpp
    incubator/mesos/trunk/src/master/http.cpp
    incubator/mesos/trunk/src/master/master.cpp
    incubator/mesos/trunk/src/master/master.hpp
    incubator/mesos/trunk/src/webui/master/framework.tpl
    incubator/mesos/trunk/src/webui/master/index.tpl

Modified: incubator/mesos/trunk/src/master/constants.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master/constants.hpp?rev=1205536&r1=1205535&r2=1205536&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master/constants.hpp (original)
+++ incubator/mesos/trunk/src/master/constants.hpp Wed Nov 23 18:56:35 2011
@@ -35,6 +35,14 @@ const int MAX_SLAVE_TIMEOUTS = 5;
 // Time to wait for a framework to failover (TODO(benh): Make configurable)).
 const double FRAMEWORK_FAILOVER_TIMEOUT = 60 * 60 * 24;
 
+// Maximum number of completed frameworks to store in the cache.
+// TODO(thomasm): make configurable
+const int MAX_COMPLETED_FRAMEWORKS = 100;
+
+// Maximum number of completed tasks per framework to store in the cache.
+// TODO(thomasm): make configurable
+const int MAX_COMPLETED_TASKS_PER_FRAMEWORK = 500;
+
 } // namespace mesos {
 } // namespace internal {
 } // namespace master {

Modified: incubator/mesos/trunk/src/master/http.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master/http.cpp?rev=1205536&r1=1205535&r2=1205536&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master/http.cpp (original)
+++ incubator/mesos/trunk/src/master/http.cpp Wed Nov 23 18:56:35 2011
@@ -77,7 +77,10 @@ JSON::Object model(const Framework& fram
   object.values["name"] = framework.info.name();
   object.values["user"] = framework.info.user();
   object.values["executor_uri"] = framework.info.executor().uri();
-  object.values["connect_time"] = framework.registeredTime;
+  object.values["registered_time"] = framework.registeredTime;
+  object.values["unregistered_time"] = framework.unregisteredTime;
+  object.values["reregistered_time"] = framework.reregisteredTime;
+  object.values["active"] = framework.active;
   object.values["resources"] = model(framework.resources);
 
   // Model all of the tasks associated with a framework.
@@ -90,6 +93,15 @@ JSON::Object model(const Framework& fram
     object.values["tasks"] = array;
   }
 
+  {
+    JSON::Array array;
+    foreach (const Task& task, framework.completedTasks) {
+      array.values.push_back(model(task));
+    }
+
+    object.values["completed_tasks"] = array;
+  }
+
   // Model all of the offers associated with a framework.
   {
     JSON::Array array;
@@ -111,7 +123,7 @@ JSON::Object model(const Slave& slave)
   object.values["id"] = slave.id.value();
   object.values["hostname"] = slave.info.hostname();
   object.values["web_ui_url"] = slave.info.public_hostname();
-  object.values["connect_time"] = slave.registeredTime;
+  object.values["registered_time"] = slave.registeredTime;
   object.values["resources"] = model(slave.info.resources());
   return object;
 }
@@ -241,6 +253,17 @@ Promise<HttpResponse> state(
     object.values["frameworks"] = array;
   }
 
+  // Model all of the completed frameworks.
+  {
+    JSON::Array array;
+
+    foreach (const Framework& framework, master.completedFrameworks) {
+      array.values.push_back(model(framework));
+    }
+
+    object.values["completed_frameworks"] = array;
+  }
+
   std::ostringstream out;
 
   JSON::render(out, object);

Modified: incubator/mesos/trunk/src/master/master.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master/master.cpp?rev=1205536&r1=1205535&r2=1205536&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master/master.cpp (original)
+++ incubator/mesos/trunk/src/master/master.cpp Wed Nov 23 18:56:35 2011
@@ -1566,6 +1566,14 @@ void Master::removeFramework(Framework* 
 
   // TODO(benh): unlink(framework->pid);
 
+  framework->unregisteredTime = elapsedTime();
+
+  completedFrameworks.push_back(*framework);
+
+  if (completedFrameworks.size() > MAX_COMPLETED_FRAMEWORKS) {
+    completedFrameworks.pop_front();
+  }
+
   // Delete it.
   frameworks.erase(framework->id);
   allocator->frameworkRemoved(framework);

Modified: incubator/mesos/trunk/src/master/master.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master/master.hpp?rev=1205536&r1=1205535&r2=1205536&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master/master.hpp (original)
+++ incubator/mesos/trunk/src/master/master.hpp Wed Nov 23 18:56:35 2011
@@ -214,6 +214,8 @@ private:
   hashmap<SlaveID, Slave*> slaves;
   hashmap<OfferID, Offer*> offers;
 
+  std::list<Framework> completedFrameworks;
+
   int64_t nextFrameworkId; // Used to give each framework a unique ID.
   int64_t nextOfferId;     // Used to give each slot offer a unique ID.
   int64_t nextSlaveId;     // Used to give each slave a unique ID.
@@ -391,6 +393,13 @@ struct Framework
   void removeTask(Task* task)
   {
     CHECK(tasks.contains(task->task_id()));
+
+    completedTasks.push_back(*task);
+
+    if (completedTasks.size() > MAX_COMPLETED_TASKS_PER_FRAMEWORK) {
+      completedTasks.pop_front();
+    }
+
     tasks.erase(task->task_id());
     resources -= task->resources();
   }
@@ -463,8 +472,12 @@ struct Framework
   bool active; // Turns false when framework is being removed.
   double registeredTime;
   double reregisteredTime;
+  double unregisteredTime;
 
   hashmap<TaskID, Task*> tasks;
+
+  std::list<Task> completedTasks;
+
   hashset<Offer*> offers; // Active offers for framework.
 
   Resources resources; // Total resources (tasks + offers + executors).

Modified: incubator/mesos/trunk/src/webui/master/framework.tpl
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/webui/master/framework.tpl?rev=1205536&r1=1205535&r2=1205536&view=diff
==============================================================================
--- incubator/mesos/trunk/src/webui/master/framework.tpl (original)
+++ incubator/mesos/trunk/src/webui/master/framework.tpl Wed Nov 23 18:56:35 2011
@@ -25,6 +25,14 @@
 %   end
 % end
 
+% if framework == None:
+%   for i in range(len(state['completed_frameworks'])):
+%     if state['completed_frameworks'][i]['id'] == framework_id:
+%       framework = state['completed_frameworks'][i]
+%     end
+%   end
+% end
+
 % # Build a dict from slave ID to slave for quick lookups of slaves.
 % slaves = {}
 % for i in range(len(state['slaves'])):
@@ -36,14 +44,14 @@
 <p>
   Name: {{framework['name']}}<br />
   User: {{framework['user']}}<br />
-  Connected: {{format_time(framework['connect_time'])}}<br />
+  Connected: {{format_time(framework['registered_time'])}}<br />
   Executor: {{framework['executor_uri']}}<br />
   Running Tasks: {{len(framework['tasks'])}}<br />
   CPUs: {{framework['resources']['cpus']}}<br />
   MEM: {{format_mem(framework['resources']['mem'])}}<br />
 </p>
 
-<h2>Tasks</h2>
+<h2>Running Tasks</h2>
 
 % # TODO: Sort these by task ID.
 % if len(framework['tasks']) > 0:
@@ -52,7 +60,7 @@
     <th class="lists">ID</th>
     <th class="lists">Name</th>
     <th class="lists">State</th>
-    <th class="lists">Running On</th>
+    <th class="lists">Running On Slave</th>
   </tr>
   % for i in range(len(framework['tasks'])):
   %   task = framework['tasks'][i]
@@ -72,6 +80,35 @@
 % else:
 <p>No tasks are running.</p>
 % end
+
+<h2>Completed Tasks</h2>
+
+% if len(framework['completed_tasks']) > 0:
+<table class="lists">
+  <tr>
+    <th class="lists">ID</th>
+    <th class="lists">Name</th>
+    <th class="lists">State</th>
+    <th class="lists">Ran On Slave</th>
+  </tr>
+  % for i in range(len(framework['completed_tasks'])):
+  %   task = framework['completed_tasks'][i]
+  <tr>
+    <td class="lists">{{task['id']}}</td>
+    <td class="lists">{{task['name']}}</td>
+    <td class="lists">{{task['state']}}</td>
+    % if task['slave_id'] in slaves:
+    %   slave = slaves[task['slave_id']]
+    <td class="lists"><a href="http://{{slave['web_ui_url']}}:8081/">{{slave['hostname']}}</a></td>
+    % else:
+    <td class="lists">Slave {{task['slave_id']}} (disconnected)</td>
+    % end
+  </tr>
+  % end
+</table>
+% else:
+<p>No tasks are running.</p>
+% end
 % else:
 <p>No framework with ID {{framework_id}} is connected.</p>
 % end

Modified: incubator/mesos/trunk/src/webui/master/index.tpl
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/webui/master/index.tpl?rev=1205536&r1=1205535&r2=1205536&view=diff
==============================================================================
--- incubator/mesos/trunk/src/webui/master/index.tpl (original)
+++ incubator/mesos/trunk/src/webui/master/index.tpl Wed Nov 23 18:56:35 2011
@@ -146,7 +146,7 @@
   </tr>
 </table>
 
-<h2>Frameworks</h2>
+<h2>Active Frameworks</h2>
 
 % # TODO: Sort these by framework ID.
 % if len(state['frameworks']) > 0:
@@ -181,7 +181,7 @@
     <td class="lists">{{framework['resources']['cpus']}}</td>
     <td class="lists">{{format_mem(framework['resources']['mem'])}}</td>
     <td class="lists">{{'%.2f' % max_share}}</td>
-    <td class="lists">{{format_time(framework['connect_time'])}}</td>
+    <td class="lists">{{format_time(framework['registered_time'])}}</td>
   </tr>
   % end
 </table>
@@ -209,7 +209,7 @@
     </td>
     <td class="lists">{{slave['resources']['cpus']}}</td>
     <td class="lists">{{format_mem(slave['resources']['mem'])}}</td>
-    <td class="lists">{{format_time(slave['connect_time'])}}</td>
+    <td class="lists">{{format_time(slave['registered_time'])}}</td>
   </tr>
   % end
 </table>
@@ -245,5 +245,30 @@
 <p>No offers are active.</p>
 % end
 
+<h2>Framework History</h2>
+% if len(state['completed_frameworks']) > 0:
+<table class="lists">
+  <tr>
+    <th class="lists">ID</th>
+    <th class="lists">User</th>
+    <th class="lists">Name</th>
+    <th class="lists">Connected</th>
+    <th class="lists">Disconnected</th>
+  </tr>
+  % for framework in state['completed_frameworks']:
+  <tr>
+    <td class="lists">{{framework['id']}}</td>
+    <td class="lists">{{framework['user']}}</td>
+    <td class="lists">
+      <a href="/framework/{{framework['id']}}">{{framework['name']}}</a>
+    </td>
+    <td class="lists">{{format_time(framework['registered_time'])}}</td>
+    <td class="lists">{{format_time(framework['unregistered_time'])}}</td>
+  </tr>
+  % end
+</table>
+% else:
+<p>No frameworks have completed.</p>
+% end
 </body>
 </html>