You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ss...@apache.org on 2013/07/27 02:52:46 UTC

git commit: Compute framework stats in one iteration

Updated Branches:
  refs/heads/master e9cf343d8 -> 5b163e4a2


Compute framework stats in one iteration

Rather than iterate over 'frameworks' and 'completed_frameworks' once
to update the slave mappings and a second time to calculate stats for
the frameworks, move that work into a single loop.

This also removes a 'concat' call that was creating a temporary Array
used to calculate stats once and then thrown away.

Review: http://reviews.apache.org/r/12880


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/5b163e4a
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/5b163e4a
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/5b163e4a

Branch: refs/heads/master
Commit: 5b163e4a276c7ddd14fdbbccf998f3db813d994f
Parents: e9cf343
Author: Ross Allen <re...@gmail.com>
Authored: Tue Jul 23 13:47:06 2013 -0700
Committer: Ross Allen <re...@gmail.com>
Committed: Fri Jul 26 17:52:36 2013 -0700

----------------------------------------------------------------------
 src/webui/master/static/js/controllers.js | 34 ++++++++++++++------------
 1 file changed, 18 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/5b163e4a/src/webui/master/static/js/controllers.js
----------------------------------------------------------------------
diff --git a/src/webui/master/static/js/controllers.js b/src/webui/master/static/js/controllers.js
index a757f13..b9099e0 100644
--- a/src/webui/master/static/js/controllers.js
+++ b/src/webui/master/static/js/controllers.js
@@ -495,28 +495,30 @@
         $scope.slave.starting_tasks = 0;
         $scope.slave.running_tasks = 0;
 
-        // Update the framework map.
+        // Computes framework stats by setting new attributes on the 'framework'
+        // object.
+        function computeFrameworkStats(framework) {
+          framework.num_tasks = 0;
+          framework.cpus = 0;
+          framework.mem = 0;
+
+          _.each(framework.executors, function(executor) {
+            framework.num_tasks += _.size(executor.tasks);
+            framework.cpus += executor.resources.cpus;
+            framework.mem += executor.resources.mem;
+          });
+        }
+
+        // Compute framework stats and update slave's mappings of those
+        // frameworks.
         _.each($scope.state.frameworks, function(framework) {
           $scope.slave.frameworks[framework.id] = framework;
+          computeFrameworkStats(framework);
         });
 
-        // Update the completed framework map.
         _.each($scope.state.completed_frameworks, function(framework) {
           $scope.slave.completed_frameworks[framework.id] = framework;
-        });
-
-        // Compute the framework stats.
-        _.each(_.values($scope.state.frameworks).concat(_.values($scope.state.completed_frameworks)),
-            function(framework) {
-              framework.num_tasks = 0;
-              framework.cpus = 0;
-              framework.mem = 0;
-
-              _.each(framework.executors, function(executor) {
-                framework.num_tasks += _.size(executor.tasks);
-                framework.cpus += executor.resources.cpus;
-                framework.mem += executor.resources.mem;
-              });
+          computeFrameworkStats(framework);
         });
 
         $('#slave').show();