ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject git commit: AMBARI-4133 Perf issues on Hosts page - freezes for several seconds and then unfreezes repeatedly on a large cluster. (atkach)
Date Fri, 20 Dec 2013 12:33:38 GMT
Updated Branches:
  refs/heads/branch-1.4.3 cff284639 -> dde56119d


AMBARI-4133 Perf issues on Hosts page - freezes for several seconds and then unfreezes repeatedly
on a large cluster. (atkach)


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

Branch: refs/heads/branch-1.4.3
Commit: dde56119d31ec90b455703d9b5f9e99dea3ab982
Parents: cff2846
Author: atkach <atkach@hortonworks.com>
Authored: Fri Dec 20 14:33:34 2013 +0200
Committer: atkach <atkach@hortonworks.com>
Committed: Fri Dec 20 14:33:34 2013 +0200

----------------------------------------------------------------------
 .../controllers/global/cluster_controller.js    | 38 +++++++++++++-------
 ambari-web/app/controllers/main/host.js         |  2 +-
 .../controllers/main/service/info/summary.js    |  6 ++--
 ambari-web/app/mappers/alerts_mapper.js         | 16 +++++----
 ambari-web/app/models/alert.js                  | 14 ++++++++
 ambari-web/app/models/host.js                   |  2 +-
 ambari-web/app/views/main/dashboard.js          |  2 +-
 ambari-web/app/views/main/dashboard/service.js  |  3 +-
 8 files changed, 55 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/dde56119/ambari-web/app/controllers/global/cluster_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/cluster_controller.js b/ambari-web/app/controllers/global/cluster_controller.js
index 3b74605..ed7789b 100644
--- a/ambari-web/app/controllers/global/cluster_controller.js
+++ b/ambari-web/app/controllers/global/cluster_controller.js
@@ -198,21 +198,33 @@ App.ClusterController = Em.Controller.extend({
    * Changes whenever alerts are loaded.
    */
   alerts:[],
+  alertsHostMap: {},
+  alertsServiceMap: {},
   updateAlerts: function(){
-    var alerts = App.Alert.find();
-    var alertsArray = alerts.toArray();
-    var sortedArray = alertsArray.sort(function (left, right) {
-      var statusDiff = right.get('status') - left.get('status');
-      if (statusDiff == 0) { // same error severity - sort by time
-        var rightTime = right.get('date');
-        var leftTime = left.get('date');
-        rightTime = rightTime ? rightTime.getTime() : 0;
-        leftTime = leftTime ? leftTime.getTime() : 0;
-        statusDiff = rightTime - leftTime;
+    var alerts = App.Alert.find().toArray();
+    var alertsHostMap = {};
+    var alertsServiceMap = {};
+    alerts.forEach(function (alert) {
+      if (!alert.get('isOk')) {
+        if (!alert.get('ignoredForHosts')) {
+          if (alertsHostMap[alert.get('hostName')]) {
+            alertsHostMap[alert.get('hostName')]++;
+          } else {
+            alertsHostMap[alert.get('hostName')] = 1;
+          }
+        }
+        if (!alert.get('ignoredForServices')) {
+          if (alertsServiceMap[alert.get('serviceType')]) {
+            alertsServiceMap[alert.get('serviceType')]++;
+          } else {
+            alertsServiceMap[alert.get('serviceType')] = 1;
+          }
+        }
       }
-      return statusDiff;
-    });
-    this.set('alerts', sortedArray);
+    }, this);
+    this.set('alertsHostMap', alertsHostMap);
+    this.set('alertsServiceMap', alertsServiceMap);
+    this.set('alerts', alerts);
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/dde56119/ambari-web/app/controllers/main/host.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host.js b/ambari-web/app/controllers/main/host.js
index d682fdf..c037e3b 100644
--- a/ambari-web/app/controllers/main/host.js
+++ b/ambari-web/app/controllers/main/host.js
@@ -87,7 +87,7 @@ App.MainHostController = Em.ArrayController.extend({
         hostAlerts: function () {
           var allAlerts = App.router.get('clusterController.alerts').filterProperty('ignoredForHosts',
false);
           if (host) {
-            return allAlerts.filterProperty('hostName', host.get('hostName'));
+            return App.Alert.sort(allAlerts.filterProperty('hostName', host.get('hostName')));
           }
           return 0;
         }.property('App.router.clusterController.alerts'),

http://git-wip-us.apache.org/repos/asf/ambari/blob/dde56119/ambari-web/app/controllers/main/service/info/summary.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/summary.js b/ambari-web/app/controllers/main/service/info/summary.js
index 99acdcd..51bfdc6 100644
--- a/ambari-web/app/controllers/main/service/info/summary.js
+++ b/ambari-web/app/controllers/main/service/info/summary.js
@@ -26,9 +26,9 @@ App.MainServiceInfoSummaryController = Em.Controller.extend({
   alerts: function () {
     var serviceId = this.get('content.serviceName');
     if (serviceId) {
-      return this.get('allAlerts').filter(function (item) {
+      return App.Alert.sort(this.get('allAlerts').filter(function (item) {
         return item.get('serviceType').toLowerCase() == serviceId.toLowerCase() &&
!item.get('ignoredForServices');
-      });
+      }));
     }
     return [];
   }.property('allAlerts', 'content.serviceName'),
@@ -44,4 +44,4 @@ App.MainServiceInfoSummaryController = Em.Controller.extend({
   isGangliaInstalled: function(){
     return App.router.get('clusterController.isGangliaInstalled');
   }.property('App.router.clusterController.isGangliaInstalled')
-});
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/dde56119/ambari-web/app/mappers/alerts_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/alerts_mapper.js b/ambari-web/app/mappers/alerts_mapper.js
index ef057f1..54466aa 100644
--- a/ambari-web/app/mappers/alerts_mapper.js
+++ b/ambari-web/app/mappers/alerts_mapper.js
@@ -69,16 +69,18 @@ App.alertsMapper = App.QuickDataMapper.create({
       }, this);
 
       this.get('model').find().forEach(function (alertRecord) {
-        var existAlert = alertsMap[alertRecord.get('id')];
-        if (existAlert) {
-          existAlert = this.getDiscrepancies(existAlert, previousAlertsResponse[alertRecord.get('id')],
mutableFields);
+        if (alertRecord) {
+          var existAlert = alertsMap[alertRecord.get('id')];
           if (existAlert) {
-            for (var i in existAlert) {
-              alertRecord.set(stringUtils.underScoreToCamelCase(i), existAlert[i]);
+            existAlert = this.getDiscrepancies(existAlert, previousAlertsResponse[alertRecord.get('id')],
mutableFields);
+            if (existAlert) {
+              for (var i in existAlert) {
+                alertRecord.set(stringUtils.underScoreToCamelCase(i), existAlert[i]);
+              }
             }
+          } else {
+            this.deleteRecord(alertRecord);
           }
-        } else {
-          this.deleteRecord(alertRecord);
         }
       }, this);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/dde56119/ambari-web/app/models/alert.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/alert.js b/ambari-web/app/models/alert.js
index 54aa821..a790f66 100644
--- a/ambari-web/app/models/alert.js
+++ b/ambari-web/app/models/alert.js
@@ -189,5 +189,19 @@ App.Alert = DS.Model.extend({
 
 });
 
+App.Alert.sort = function (array) {
+  return array.sort(function (left, right) {
+    var statusDiff = right.get('status') - left.get('status');
+    if (statusDiff == 0) { // same error severity - sort by time
+      var rightTime = right.get('date');
+      var leftTime = left.get('date');
+      rightTime = rightTime ? rightTime.getTime() : 0;
+      leftTime = leftTime ? leftTime.getTime() : 0;
+      statusDiff = rightTime - leftTime;
+    }
+    return statusDiff;
+  });
+};
+
 App.Alert.FIXTURES = [
 ];

http://git-wip-us.apache.org/repos/asf/ambari/blob/dde56119/ambari-web/app/models/host.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/host.js b/ambari-web/app/models/host.js
index 995f835..9a4992f 100644
--- a/ambari-web/app/models/host.js
+++ b/ambari-web/app/models/host.js
@@ -58,7 +58,7 @@ App.Host = DS.Model.extend({
   }.property('memTotal', 'memFree'),
 
   criticalAlertsCount: function () {
-    return App.router.get('clusterController.alerts').filterProperty('hostName', this.get('hostName')).filterProperty('isOk',
false).filterProperty('ignoredForHosts', false).length;
+    return App.router.get('clusterController.alertsHostMap')[this.get('hostName')];
   }.property('App.router.clusterController.alerts.length'),
 
   componentsWithStaleConfigsCount: function() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/dde56119/ambari-web/app/views/main/dashboard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard.js b/ambari-web/app/views/main/dashboard.js
index 9cc35f3..30be2f6 100644
--- a/ambari-web/app/views/main/dashboard.js
+++ b/ambari-web/app/views/main/dashboard.js
@@ -546,7 +546,7 @@ App.MainDashboardView = Em.View.extend({
           var allAlerts = App.router.get('clusterController.alerts');
           var serviceId = this.get('service.serviceName');
           if (serviceId) {
-            return allAlerts.filterProperty('serviceType', serviceId).filterProperty('isOk',
false).filterProperty('ignoredForServices', false);
+            return App.Alert.sort(allAlerts.filterProperty('serviceType', serviceId).filterProperty('isOk',
false).filterProperty('ignoredForServices', false));
           }
           return 0;
         }.property('App.router.clusterController.alerts'),

http://git-wip-us.apache.org/repos/asf/ambari/blob/dde56119/ambari-web/app/views/main/dashboard/service.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/service.js b/ambari-web/app/views/main/dashboard/service.js
index 9c5354c..4ae53a8 100644
--- a/ambari-web/app/views/main/dashboard/service.js
+++ b/ambari-web/app/views/main/dashboard/service.js
@@ -123,8 +123,7 @@ App.MainDashboardServiceView = Em.View.extend({
   },
 
   criticalAlertsCount: function () {
-    var alerts = App.router.get('clusterController.alerts');
-    return alerts.filterProperty('serviceType', this.get('service.id')).filterProperty('isOk',
false).filterProperty('ignoredForServices', false).length;
+    return App.router.get('clusterController.alertsServiceMap')[this.get('service.id')];
   }.property('App.router.clusterController.alerts'),
 
   isCollapsed: false,


Mime
View raw message