You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2013/12/20 13:32:13 UTC
git commit: AMBARI-4133 Perf issues on Hosts page - freezes for
several seconds and then unfreezes repeatedly on a large cluster. (atkach)
Updated Branches:
refs/heads/trunk f963f667e -> 614d4f741
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/614d4f74
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/614d4f74
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/614d4f74
Branch: refs/heads/trunk
Commit: 614d4f741843ea76b505cbd207731ef3ccc3d702
Parents: f963f66
Author: atkach <at...@hortonworks.com>
Authored: Fri Dec 20 14:32:06 2013 +0200
Committer: atkach <at...@hortonworks.com>
Committed: Fri Dec 20 14:32:06 2013 +0200
----------------------------------------------------------------------
.../controllers/global/cluster_controller.js | 38 +++++++++++++-------
ambari-web/app/controllers/main/host.js | 2 +-
.../controllers/main/service/info/summary.js | 4 +--
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, 54 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/614d4f74/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/614d4f74/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/614d4f74/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..530a427 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'),
http://git-wip-us.apache.org/repos/asf/ambari/blob/614d4f74/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/614d4f74/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/614d4f74/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/614d4f74/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/614d4f74/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,