You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2013/02/22 22:43:07 UTC

svn commit: r1449230 - in /incubator/ambari/trunk: CHANGES.txt ambari-web/app/mappers/service_mapper.js ambari-web/app/mappers/status_mapper.js

Author: yusaku
Date: Fri Feb 22 21:43:06 2013
New Revision: 1449230

URL: http://svn.apache.org/r1449230
Log:
AMBARI-1477. Improve performance for App.statusMapper. (yusaku)

Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/ambari-web/app/mappers/service_mapper.js
    incubator/ambari/trunk/ambari-web/app/mappers/status_mapper.js

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1449230&r1=1449229&r2=1449230&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Fri Feb 22 21:43:06 2013
@@ -58,6 +58,8 @@ Trunk (unreleased changes):
 
  IMPROVEMENTS
 
+ AMBARI-1477. Improve performance for App.statusMapper. (yusaku)
+
  AMBARI-1484. Reintroduce client-side paging for Hosts table. (yusaku)
 
  AMBARI-1473. Further optimization of querying host information from the

Modified: incubator/ambari/trunk/ambari-web/app/mappers/service_mapper.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/mappers/service_mapper.js?rev=1449230&r1=1449229&r2=1449230&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/mappers/service_mapper.js (original)
+++ incubator/ambari/trunk/ambari-web/app/mappers/service_mapper.js Fri Feb 22 21:43:06 2013
@@ -125,6 +125,9 @@ App.servicesMapper = App.QuickDataMapper
       return;
     }
 
+    var start = new Date().getTime();
+    console.log('in service mapper');
+
     if (json.items) {
       var result = [];
       json.items.forEach(function (item) {
@@ -180,6 +183,8 @@ App.servicesMapper = App.QuickDataMapper
 
       App.store.loadMany(this.get('model3'), result);
     }
+
+    console.log('out service mapper.  Took ' + (new Date().getTime() - start) + 'ms');
   },
 
   hdfsMapper: function (item) {

Modified: incubator/ambari/trunk/ambari-web/app/mappers/status_mapper.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/mappers/status_mapper.js?rev=1449230&r1=1449229&r2=1449230&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/mappers/status_mapper.js (original)
+++ incubator/ambari/trunk/ambari-web/app/mappers/status_mapper.js Fri Feb 22 21:43:06 2013
@@ -29,41 +29,45 @@ App.statusMapper = App.QuickDataMapper.c
   },
 
   map:function (json) {
+    var start = new Date().getTime();
+    console.log('in status mapper');
 
     if (json.items) {
-      var result = [];
+      var result = {};
       json.items.forEach(function (item) {
-        result.push(this.parseIt(item, this.config));
+        item = this.parseIt(item, this.config);
+        result[item.id] = item;
       }, this);
 
       var services = App.Service.find();
-      result.forEach(function(item){
-        var service = services.findProperty('id', item.id);
-        if(service){
+      services.forEach(function(service) {
+        var item = result[service.get('id')];
+        if (item) {
           service.set('workStatus', item.work_status);
         }
-      })
-
+      });
 
       //host_components
-      result = [];
+      result = {};
       json.items.forEach(function (item) {
         item.components.forEach(function (component) {
           component.host_components.forEach(function (host_component) {
             host_component.id = host_component.HostRoles.component_name + "_" + host_component.HostRoles.host_name;
-            result.push(this.parseIt(host_component, this.config3));
+            result[host_component.id] = this.parseIt(host_component, this.config3);
           }, this)
         }, this)
       }, this);
 
       var hostComponents = App.HostComponent.find();
-      result.forEach(function(item){
-        var hostComponent = hostComponents.findProperty('id', item.id);
-        if(hostComponent){
-          item = this.calculateState(item);
-          hostComponent.set('workStatus', item.work_status);
+
+      hostComponents.forEach(function(hostComponent) {
+        var item = result[hostComponent.get('id')];
+        if (item) {
+         hostComponent.set('workStatus', item.work_status);
         }
-      }, this)
+      });
+
+      console.log('out status mapper.  Took ' + (new Date().getTime() - start) + 'ms');
     }
   }
 });