You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by xi...@apache.org on 2014/11/21 23:49:18 UTC
ambari git commit: AMBARI-8388. Remove legacy Nagios alerts code from
Ambari Web.(XIWANG)
Repository: ambari
Updated Branches:
refs/heads/trunk 870a5a579 -> 3dab802ce
AMBARI-8388. Remove legacy Nagios alerts code from Ambari Web.(XIWANG)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3dab802c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3dab802c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3dab802c
Branch: refs/heads/trunk
Commit: 3dab802cedd256b0952cce1f478b11f741335fd8
Parents: 870a5a5
Author: Xi Wang <xi...@apache.org>
Authored: Wed Nov 19 12:46:11 2014 -0800
Committer: Xi Wang <xi...@apache.org>
Committed: Fri Nov 21 14:37:20 2014 -0800
----------------------------------------------------------------------
ambari-web/app/assets/test/tests.js | 1 -
ambari-web/app/controllers.js | 1 -
.../app/controllers/global/update_controller.js | 4 +-
.../app/controllers/main/alerts_controller.js | 166 ------------
ambari-web/app/controllers/main/host.js | 23 --
ambari-web/app/messages.js | 1 -
ambari-web/app/routes/main.js | 6 -
.../main/dashboard/alert_notification_popup.hbs | 34 ---
.../app/templates/main/host/alerts_popup.hbs | 31 ---
.../app/templates/main/service/info/summary.hbs | 44 +---
ambari-web/app/utils/ajax/ajax.js | 10 +-
ambari-web/app/views/main/dashboard/widgets.js | 46 ----
.../app/views/main/service/info/summary.js | 120 +--------
.../controllers/main/alerts_controller_test.js | 260 -------------------
.../views/main/service/info/summary_test.js | 192 --------------
15 files changed, 11 insertions(+), 928 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/3dab802c/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index 0619981..89ad16b 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -92,7 +92,6 @@ var files = ['test/init_model_test',
'test/controllers/main/service/info/config_test',
'test/controllers/main/service_test',
'test/controllers/main/admin_test',
- 'test/controllers/main/alerts_controller_test',
'test/controllers/main/views_controller_test',
'test/controllers/installer_test',
'test/controllers/main_test',
http://git-wip-us.apache.org/repos/asf/ambari/blob/3dab802c/ambari-web/app/controllers.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers.js b/ambari-web/app/controllers.js
index 58e9c4e..374f39b 100644
--- a/ambari-web/app/controllers.js
+++ b/ambari-web/app/controllers.js
@@ -76,7 +76,6 @@ require('controllers/main/admin/security/add/step2');
require('controllers/main/admin/security/add/step3');
require('controllers/main/admin/security/add/step4');
require('controllers/main/admin/authentication');
-require('controllers/main/alerts_controller');
require('controllers/main/alert_definitions_controller');
require('controllers/main/alerts/alert_definitions_actions_controller');
require('controllers/main/alerts/definition_details_controller');
http://git-wip-us.apache.org/repos/asf/ambari/blob/3dab802c/ambari-web/app/controllers/global/update_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/update_controller.js b/ambari-web/app/controllers/global/update_controller.js
index bfb625c..9393f3b 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -157,7 +157,7 @@ App.UpdateController = Em.Controller.extend({
var realUrl = '/hosts?<parameters>fields=Hosts/host_name,Hosts/maintenance_state,Hosts/public_host_name,Hosts/cpu_count,Hosts/ph_cpu_count,' +
'Hosts/host_status,Hosts/last_heartbeat_time,Hosts/ip,host_components/HostRoles/state,host_components/HostRoles/maintenance_state,' +
'host_components/HostRoles/stale_configs,host_components/HostRoles/service_name,host_components/HostRoles/desired_admin_state,' +
- 'metrics/disk,metrics/load/load_one,Hosts/total_mem,legacy_alerts/summary<hostAuxiliaryInfo>&minimal_response=true';
+ 'metrics/disk,metrics/load/load_one,Hosts/total_mem&minimal_response=true';
var hostAuxiliaryInfo = ',Hosts/os_arch,Hosts/os_type,metrics/cpu/cpu_system,metrics/cpu/cpu_user,metrics/memory/mem_total,metrics/memory/mem_free';
if (App.router.get('currentState.name') == 'index' && App.router.get('currentState.parentState.name') == 'hosts') {
@@ -427,7 +427,7 @@ App.UpdateController = Em.Controller.extend({
},
updateServices: function (callback) {
var testUrl = '/data/services/HDP2/services.json';
- var componentConfigUrl = this.getUrl(testUrl, '/services?fields=legacy_alerts/summary,ServiceInfo/state,ServiceInfo/maintenance_state&minimal_response=true');
+ var componentConfigUrl = this.getUrl(testUrl, '/services?fields=ServiceInfo/state,ServiceInfo/maintenance_state&minimal_response=true');
App.HttpClient.get(componentConfigUrl, App.serviceMapper, {
complete: callback
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/3dab802c/ambari-web/app/controllers/main/alerts_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/alerts_controller.js b/ambari-web/app/controllers/main/alerts_controller.js
deleted file mode 100644
index b28f711..0000000
--- a/ambari-web/app/controllers/main/alerts_controller.js
+++ /dev/null
@@ -1,166 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-var App = require('app');
-
-App.MainAlertsController = Em.Controller.extend({
- name: 'mainAlertsController',
-
- alerts: [],
- isLoaded: false,
- isUpdating: false,
- // name of resource(hostName or ServiceName)
- resourceName: null,
- //"HOST" or "SERVICE"
- resourceType: null,
- updateTimer: null,
-
- /**
- * load alerts for service or host
- * @param name
- * @param type
- */
- loadAlerts: function (name, type) {
- this.set('isLoaded', false);
- this.set('resourceName', name);
- this.set('resourceType', type);
- this.getFromServer();
- },
- /**
- * update alerts
- */
- update: function () {
- var self = this;
- if (this.get('isUpdating')) {
- this.set('updateTimer', setTimeout(function () {
- self.getFromServer();
- self.update();
- }, App.componentsUpdateInterval));
- } else {
- clearTimeout(this.get('updateTimer'));
- }
- }.observes('isUpdating'),
-
- /**
- * ask alerts from server by type
- */
- getFromServer: function () {
- if (App.router.get('clusterController.isNagiosInstalled')) {
- if (this.get('resourceType') === "SERVICE") {
- this.getAlertsByService();
- } else if (this.get('resourceType') === "HOST") {
- this.getAlertsByHost();
- } else {
- console.warn("GET Alerts error: unknown resourceType");
- }
- } else {
- this.set('isLoaded', true);
- }
- },
- /**
- * request alerts from server, which belong to particular host
- * @return {Boolean}
- */
- getAlertsByHost: function () {
- if (this.get('resourceName')) {
- App.ajax.send({
- name: 'alerts.get_by_host',
- sender: this,
- data: {
- hostName: this.get('resourceName')
- },
- success: 'getAlertsSuccessCallback',
- error: 'getAlertsErrorCallback'
- });
- return true;
- } else {
- console.warn('GET Alerts error: hostName parameter is missing');
- return false;
- }
- },
-
- /**
- * Saved request for alerts
- * Should be aborted if user navigate away from current page (aborting done in router)
- * @type {$.ajax|null}
- */
- servicesRequest: null,
-
- /**
- * request alerts from server, which belong to particular service
- * @return {Boolean}
- */
- getAlertsByService: function () {
- if (this.get('resourceName')) {
- var request = App.ajax.send({
- name: 'alerts.get_by_service',
- sender: this,
- data: {
- serviceName: this.get('resourceName')
- },
- success: 'getAlertsSuccessCallback',
- error: 'getAlertsErrorCallback'
- });
- this.set('servicesRequest', request);
- return true;
- } else {
- console.warn('GET Alerts error: serviceName parameter is missing');
- return false;
- }
- },
-
- /**
- * map to associate old status format with and maintain sorting
- */
- statusNumberMap: {
- "OK": "0",
- "WARNING": "1",
- "CRITICAL": "2",
- "PASSIVE": "3"
- },
- /**
- * format json data and push into @alerts array
- * @param json
- */
- getAlertsSuccessCallback: function (json) {
- var alerts = [];
- if (json && json.legacy_alerts && json.legacy_alerts.detail) {
- json.legacy_alerts.detail.forEach(function (_alert) {
- alerts.pushObject(App.Alert.create({
- id: _alert.description + "_" + _alert.host_name + "_" + _alert.serviceType,
- title: _alert.description,
- serviceType: _alert.service_name,
- lastTime: _alert.last_status_time,
- status: this.get('statusNumberMap')[_alert.status] || "4",
- message: _alert.output,
- hostName: _alert.host_name,
- lastCheck: _alert.status_time,
- isLoaded: true
- }));
- }, this);
- }
- this.set('alerts', alerts.sortProperty('status', 'date').reverse());
- this.set('isLoaded', true);
- },
- /**
- * finish loading if call failed
- */
- getAlertsErrorCallback: function () {
- this.set('isLoaded', true);
- }
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/3dab802c/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 dc966db..63945ec 100644
--- a/ambari-web/app/controllers/main/host.js
+++ b/ambari-web/app/controllers/main/host.js
@@ -468,29 +468,6 @@ App.MainHostController = Em.ArrayController.extend(App.TableServerMixin, {
},
showAlertsPopup: function (event) {
- var host = event.context;
- App.router.get('mainAlertsController').loadAlerts(host.get('hostName'), "HOST");
- App.ModalPopup.show({
- header: this.t('services.alerts.headingOfList'),
- bodyClass: Ember.View.extend({
- templateName: require('templates/main/host/alerts_popup'),
- controllerBinding: 'App.router.mainAlertsController',
- alerts: function () {
- return this.get('controller.alerts');
- }.property('controller.alerts'),
-
- closePopup: function () {
- this.get('parentView').hide();
- }
- }),
- primary: Em.I18n.t('common.close'),
- secondary: null,
- didInsertElement: function () {
- this.$().find('.modal-footer').addClass('align-center');
- this.$().children('.modal').css({'margin-top': '-350px'});
- }
- });
- event.stopPropagation();
},
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/3dab802c/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 5c53cd6..8947b3b 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -365,7 +365,6 @@ Em.I18n.translations = {
'services.alerts.lastCheck': 'Last Checked {0}',
'services.alerts.brLastCheck': '<br>Last Checked {0}',
'services.alerts.occurredOn': 'Occurred on {0}, {1}',
- 'services.alerts.headingOfList': 'Alerts and Health Checks',
'services.alerts.goToService': 'Go to Service',
'services.alerts.goToNagios': 'Go to Nagios Web UI',
http://git-wip-us.apache.org/repos/asf/ambari/blob/3dab802c/ambari-web/app/routes/main.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/main.js b/ambari-web/app/routes/main.js
index 37c9fea..b5d353a 100644
--- a/ambari-web/app/routes/main.js
+++ b/ambari-web/app/routes/main.js
@@ -631,12 +631,6 @@ module.exports = Em.Route.extend({
} else {
router.transitionTo('services.index');
}
- },
- exit: function(router) {
- var request = router.get('mainAlertsController.servicesRequest');
- if (request) {
- request.abort();
- }
}
}),
metrics: Em.Route.extend({
http://git-wip-us.apache.org/repos/asf/ambari/blob/3dab802c/ambari-web/app/templates/main/dashboard/alert_notification_popup.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/dashboard/alert_notification_popup.hbs b/ambari-web/app/templates/main/dashboard/alert_notification_popup.hbs
deleted file mode 100644
index 8a37e23..0000000
--- a/ambari-web/app/templates/main/dashboard/alert_notification_popup.hbs
+++ /dev/null
@@ -1,34 +0,0 @@
-{{!
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-}}
-
-{{#if controller.isLoaded}}
- <p>{{view.warnAlertsMessage}}</p>
- {{#if view.warnAlertsCount}}
- <ul id='summary-alerts-list' class="alerts">
- {{#each view.warnAlerts}}
- {{view App.AlertItemView contentBinding="this"}}
- {{/each}}
- </ul>
- {{/if}}
- <p class="alertsPopupLinks">
- <a href="#" {{action selectService target="view"}}>{{t services.alerts.goToService}}</a>
- <a href="#" {{action "viewNagiosUrl" target="view" on="mouseUp"}}>{{t services.alerts.goToNagios}}</a>
- </p>
-{{else}}
- <div class="spinner"></div>
-{{/if}}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/3dab802c/ambari-web/app/templates/main/host/alerts_popup.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host/alerts_popup.hbs b/ambari-web/app/templates/main/host/alerts_popup.hbs
deleted file mode 100644
index 247753a..0000000
--- a/ambari-web/app/templates/main/host/alerts_popup.hbs
+++ /dev/null
@@ -1,31 +0,0 @@
-{{!
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-}}
-
-{{#if controller.isLoaded}}
- {{#if view.alerts.length}}
- <ul id='summary-alerts-list' class="alerts">
- {{#each view.alerts}}
- {{view App.AlertItemView contentBinding="this"}}
- {{/each}}
- </ul>
- {{else}}
- {{t hosts.host.alert.noAlerts.message}}
- {{/if}}
-{{else}}
- <div class="spinner"></div>
-{{/if}}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3dab802c/ambari-web/app/templates/main/service/info/summary.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/service/info/summary.hbs b/ambari-web/app/templates/main/service/info/summary.hbs
index 8ccc64e..bbf270f 100644
--- a/ambari-web/app/templates/main/service/info/summary.hbs
+++ b/ambari-web/app/templates/main/service/info/summary.hbs
@@ -61,46 +61,10 @@
</div>
</div>
</div>
- {{#unless view.isNoAlertsService}}
- <div class="span6">
- <div class="box">
- <div class="box-header">
- <h4>{{t services.alerts.headingOfList}}</h4>
- {{#if controller.isNagiosInstalled}}
- <div class="btn-group">
- {{#if App.router.clusterController.isNagiosUrlLoaded}}
- <a class="btn" target="_blank" rel="tooltip"
- title="Go to Nagios" {{bindAttr href="controller.nagiosUrl"}}><i class="icon-link"></i></a>
- {{else}}
- <div class="spinner"></div>
- {{/if}}
- </div>
- {{/if}}
- </div>
- <ul id='summary-alerts-list' class="alerts">
- {{#if view.alertsController.isLoaded}}
- {{#if view.alerts.length}}
- {{#each view.alerts}}
- {{view App.AlertItemView contentBinding="this"}}
- {{/each}}
- {{else}}
- {{#if controller.isNagiosInstalled}}
- <div class="alert alert-info">
- {{t services.service.info.summary.nagios.noAlerts}}
- </div>
- {{else}}
- <div class="alert">
- {{t services.service.info.summary.nagios.alerts}}
- </div>
- {{/if}}
- {{/if}}
- {{else}}
- <div class="spinner"></div>
- {{/if}}
- </ul>
- </div>
- </div>
- {{/unless}}
+
+ <div class="span6">
+ </div>
+
</div>
{{#if view.collapsedSections}}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3dab802c/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index 2454216..cbc8996 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -300,14 +300,6 @@ var urls = {
'type': 'DELETE'
},
- 'alerts.get_by_service': {
- 'real': '/clusters/{clusterName}/services/{serviceName}?fields=legacy_alerts',
- 'mock': '/data/alerts/HDP2/service_alerts.json'
- },
- 'alerts.get_by_host': {
- 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=legacy_alerts',
- 'mock': '/data/alerts/HDP2/host_alerts.json'
- },
'alerts.load_alert_notification': {
'real': '/alert_targets?fields=*',
'mock': 'data/alerts/alertNotifications.json'
@@ -1939,7 +1931,7 @@ var urls = {
}
},
'host.status.counters': {
- 'real': '/clusters/{clusterName}?fields=legacy_alerts,Clusters/health_report,Clusters/total_hosts&minimal_response=true',
+ 'real': '/clusters/{clusterName}?fields=Clusters/health_report,Clusters/total_hosts&minimal_response=true',
'mock': '/data/hosts/HDP2/host_status_counters.json'
},
'components.filter_by_status': {
http://git-wip-us.apache.org/repos/asf/ambari/blob/3dab802c/ambari-web/app/views/main/dashboard/widgets.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets.js b/ambari-web/app/views/main/dashboard/widgets.js
index 29b7063..107be63 100644
--- a/ambari-web/app/views/main/dashboard/widgets.js
+++ b/ambari-web/app/views/main/dashboard/widgets.js
@@ -587,52 +587,6 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, {
}.property('App.router.clusterController.gangliaUrl'),
showAlertsPopup: function (event) {
- var service = event.context;
- App.router.get('mainAlertsController').loadAlerts(service.get('serviceName'), "SERVICE");
- App.ModalPopup.show({
- header: this.t('services.alerts.headingOfList'),
- bodyClass: Ember.View.extend({
- templateName: require('templates/main/dashboard/alert_notification_popup'),
- service: service,
- controllerBinding: 'App.router.mainAlertsController',
- warnAlerts: function () {
- return this.get('controller.alerts').filterProperty('isOk', false).filterProperty('ignoredForServices', false);
- }.property('controller.alerts'),
-
- warnAlertsCount: function () {
- return this.get('warnAlerts').length;
- }.property('warnAlerts'),
-
- warnAlertsMessage: function() {
- return Em.I18n.t('services.alerts.head').format(this.get('warnAlertsCount'));
- }.property('warnAlertsCount'),
-
- nagiosUrl: function () {
- return App.router.get('clusterController.nagiosUrl');
- }.property('App.router.clusterController.nagiosUrl'),
-
- closePopup: function () {
- this.get('parentView').hide();
- },
-
- viewNagiosUrl: function () {
- window.open(this.get('nagiosUrl'), "_blank");
- this.closePopup();
- },
-
- selectService: function () {
- App.router.transitionTo('services.service.summary', service);
- this.closePopup();
- }
- }),
- primary: Em.I18n.t('common.close'),
- secondary : null,
- didInsertElement: function () {
- this.$().find('.modal-footer').addClass('align-center');
- this.$().children('.modal').css({'margin-top': '-350px'});
- }
- });
- event.stopPropagation();
}
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/3dab802c/ambari-web/app/views/main/service/info/summary.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/info/summary.js b/ambari-web/app/views/main/service/info/summary.js
index 99c049b..4e9e36c 100644
--- a/ambari-web/app/views/main/service/info/summary.js
+++ b/ambari-web/app/views/main/service/info/summary.js
@@ -37,14 +37,7 @@ App.AlertItemView = Em.View.extend({
App.MainServiceInfoSummaryView = Em.View.extend({
templateName: require('templates/main/service/info/summary'),
attributes:null,
- /**
- * alerts collection
- */
- alerts: [],
- /**
- * associative collection of alerts
- */
- alertsMap: {},
+
/**
* @property {String} templatePathPrefix - base path for custom templates
* if you want to add custom template, add <service_name>.hbs file to
@@ -89,64 +82,6 @@ App.MainServiceInfoSummaryView = Em.View.extend({
return App.get('services.hasClient');
}.property('App.services.hasClient'),
- alertsControllerBinding: 'App.router.mainAlertsController',
- /**
- * observes changes to alerts collection
- */
- observeAlerts: function (view, property) {
- //alerts should be inserted only in build-in DOM view
- if (view.state !== "inDOM") return;
- var newAlerts = this.get('alertsController.alerts'),
- currentAlerts = this.get('alerts'),
- alertsMap;
-
- if (currentAlerts.length === 0) {
- alertsMap = {};
- newAlerts.forEach(function (alert) {
- alertsMap[alert.id] = alert;
- currentAlerts.pushObject(alert);
- }, this);
- this.set('alertsMap', alertsMap);
- } else if (newAlerts.length > 0) {
- this.updateAlerts(newAlerts, currentAlerts);
- } else {
- currentAlerts.clear();
- this.set('alertsMap', {});
- }
- }.observes('alertsController.alerts'),
- /**
- * update existing alerts according to new data
- * @param newAlerts
- * @param currentAlerts
- */
- updateAlerts: function (newAlerts, currentAlerts) {
- var alertsMap = this.get('alertsMap');
- var mutableFields = ['status', 'message', 'lastCheck', 'lastTime'];
- // minimal time difference to apply changes to "lastTime" property
- var minTimeDiff = 60000;
- var curTime = App.dateTime();
- currentAlerts.setEach('isLoaded', false);
-
- newAlerts.forEach(function (alert) {
- var currentAlert = alertsMap[alert.get('id')];
- if (currentAlert) {
- mutableFields.forEach(function (field) {
- if (currentAlert.get(field) !== alert.get(field)) {
- currentAlert.set(field, alert.get(field));
- }
- });
- currentAlert.set('isLoaded', true);
- } else {
- alertsMap[alert.get('id')] = alert;
- currentAlerts.pushObject(alert);
- }
- });
- currentAlerts.filterProperty('isLoaded', false).slice(0).forEach(function (alert) {
- delete alertsMap[alert.get('id')];
- currentAlerts.removeObject(alert);
- }, this);
- },
-
noTemplateService: function () {
var serviceName = this.get("service.serviceName");
//services with only master components
@@ -443,14 +378,6 @@ App.MainServiceInfoSummaryView = Em.View.extend({
this.set('oldServiceName', serviceName);
}.observes('serviceName'),
- /**
- * Alerts panel not displayed when alerting service (ex:Nagios)is not in stack definition.
- * Alerts panel never displayed for PIG, SQOOP and TEZ Services
- */
- isNoAlertsService: function () {
- return !App.get('services.alerting').length ||
- (!!this.get('service.serviceName') && App.get('services.clientOnly').contains(this.get('service.serviceName')));
- }.property('service.serviceName', 'App.services.alerting'),
/**
* Service metrics panel not displayed when metrics service (ex:Ganglia) is not in stack definition.
@@ -482,15 +409,9 @@ App.MainServiceInfoSummaryView = Em.View.extend({
}.property('App.router.clusterController.gangliaUrl', 'service.serviceName'),
didInsertElement:function () {
- var alertsController = this.get('alertsController');
- alertsController.loadAlerts(this.get('service.serviceName'), "SERVICE");
- alertsController.set('isUpdating', true);
- //TODO delegate style calculation to css
- // We have to make the height of the Alerts section
- // match the height of the Summary section.
+ // adjust the summary table height
var summaryTable = document.getElementById('summary-info');
- var alertsList = document.getElementById('summary-alerts-list');
- if (summaryTable && alertsList) {
+ if (summaryTable) {
var rows = $(summaryTable).find('tr');
if (rows != null && rows.length > 0) {
var minimumHeightSum = 20;
@@ -499,40 +420,7 @@ App.MainServiceInfoSummaryView = Em.View.extend({
if (summaryActualHeight <= minimumHeightSum) {
$(summaryTable).attr('style', "height:" + minimumHeightSum + "px;");
}
- } else if (alertsList.clientHeight > 0) {
- $(summaryTable).append('<tr><td></td></tr>');
- $(summaryTable).attr('style', "height:" + alertsList.clientHeight + "px;");
}
}
- },
- willDestroyElement: function(){
- this.get('alertsController').set('isUpdating', false);
- this.get('alerts').clear();
- this.set('alertsMap', {});
- },
-
- setAlertsWindowSize: function() {
- // for alerts window
- var summaryTable = document.getElementById('summary-info');
- var alertsList = document.getElementById('summary-alerts-list');
- var alertsNum = this.get('alerts').length;
- if (summaryTable && alertsList && alertsNum != null) {
- var summaryActualHeight = summaryTable.clientHeight;
- var alertsActualHeight = alertsNum * 60;
- var alertsMinHeight = 58;
- if (alertsNum == 0) {
- $(alertsList).attr('style', "height:" + alertsMinHeight + "px;");
- } else if ( alertsNum <= 4) {
- // set window size to actual alerts height
- $(alertsList).attr('style', "height:" + alertsActualHeight + "px;");
- } else {
- // set window size : sum of first 4 alerts height
- $(alertsList).attr('style', "height:" + 240 + "px;");
- }
- var curSize = alertsList.clientHeight;
- if ( summaryActualHeight >= curSize) {
- $(alertsList).attr('style', "height:" + summaryActualHeight + "px;");
- }
- }
- }.observes('alertsController.isLoaded')
+ }
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/3dab802c/ambari-web/test/controllers/main/alerts_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/alerts_controller_test.js b/ambari-web/test/controllers/main/alerts_controller_test.js
deleted file mode 100644
index aee782a..0000000
--- a/ambari-web/test/controllers/main/alerts_controller_test.js
+++ /dev/null
@@ -1,260 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-var App = require('app');
-
-require('controllers/main/alerts_controller');
-require('models/alert');
-
-describe('MainAlertsController', function () {
-
- var controller = App.MainAlertsController.create();
-
- describe('#loadAlerts()', function () {
-
- before(function () {
- sinon.stub(controller, 'getFromServer', Em.K);
- });
- after(function () {
- controller.getFromServer.restore();
- });
-
- it('getFromServer should be called', function () {
- controller.set('resourceName', null);
- controller.set('isLoaded', true);
- controller.set('resourceType', null);
- controller.loadAlerts('name1', 'type1');
- expect(controller.get("isLoaded")).to.be.false;
- expect(controller.get("resourceName")).to.equal('name1');
- expect(controller.get("resourceType")).to.equal('type1');
- expect(controller.getFromServer.calledOnce).to.be.true;
- });
- });
-
- describe('#update()', function () {
-
- var clock;
-
- beforeEach(function () {
- clock = sinon.useFakeTimers();
- sinon.stub(controller, 'getFromServer', Em.K);
- sinon.spy(controller, 'update');
- });
- afterEach(function () {
- clock.restore();
- controller.getFromServer.restore();
- controller.update.restore();
- });
-
- it('isUpdating = true', function () {
- controller.set('isUpdating', true);
- expect(controller.get("updateTimer")).not.to.be.null;
- clock.tick(App.componentsUpdateInterval);
- expect(controller.getFromServer.calledOnce).to.be.true;
- expect(controller.update.calledTwice).to.be.true;
- });
- it('isUpdating = false', function () {
- controller.set('isUpdating', false);
- expect(controller.update.calledOnce).to.be.true;
- });
- });
-
- describe('#getFromServer()', function () {
- var obj = Em.Object.create({isNagiosInstalled: false});
-
- beforeEach(function () {
- sinon.stub(controller, 'getAlertsByService', Em.K);
- sinon.stub(controller, 'getAlertsByHost', Em.K);
- sinon.stub(App.router, 'get', function() {return obj.get('isNagiosInstalled')});
- });
- afterEach(function () {
- controller.getAlertsByService.restore();
- controller.getAlertsByHost.restore();
- App.router.get.restore();
- });
-
- it('Nagios is not installed', function () {
- obj.set('isNagiosInstalled', false);
- controller.set('isLoaded', false);
- controller.getFromServer();
- expect(controller.get('isLoaded')).to.be.true;
- controller.set('isLoaded', false);
- });
- it('Nagios installed, SERVICE resource type', function () {
- obj.set('isNagiosInstalled', true);
- controller.set('resourceType', 'SERVICE');
- controller.getFromServer();
- expect(controller.get('isLoaded')).to.be.false;
- expect(controller.getAlertsByService.calledOnce).to.be.true;
- });
- it('Nagios installed, HOST resource type', function () {
- obj.set('isNagiosInstalled', true);
- controller.set('resourceType', 'HOST');
- controller.getFromServer();
- expect(controller.get('isLoaded')).to.be.false;
- expect(controller.getAlertsByHost.calledOnce).to.be.true;
- });
- it('Nagios installed, unknown resource type', function () {
- obj.set('isNagiosInstalled', true);
- controller.set('resourceType', 'RS1');
- controller.getFromServer();
- expect(controller.get('isLoaded')).to.be.false;
- expect(controller.getAlertsByService.called).to.be.false;
- expect(controller.getAlertsByHost.called).to.be.false;
- });
- });
-
- describe('#getAlertsByHost()', function () {
-
- beforeEach(function () {
- sinon.stub(App.ajax, 'send', Em.K);
- });
- afterEach(function () {
- App.ajax.send.restore();
- });
-
- it('resourceName is null', function () {
- controller.set('resourceName', null);
- expect(controller.getAlertsByHost()).to.be.false;
- expect(App.ajax.send.called).to.be.false;
- });
- it('resourceName is correct', function () {
- controller.set('resourceName', 'host1');
- expect(controller.getAlertsByHost()).to.be.true;
- expect(App.ajax.send.calledOnce).to.be.true;
- });
- });
-
- describe('#getAlertsByService()', function () {
-
- beforeEach(function () {
- sinon.stub(App.ajax, 'send', Em.K);
- });
- afterEach(function () {
- App.ajax.send.restore();
- });
-
- it('resourceName is null', function () {
- controller.set('resourceName', null);
- expect(controller.getAlertsByService()).to.be.false;
- expect(App.ajax.send.called).to.be.false;
- });
- it('resourceName is correct', function () {
- controller.set('resourceName', 'service1');
- expect(controller.getAlertsByService()).to.be.true;
- expect(App.ajax.send.calledOnce).to.be.true;
- });
- });
-
- describe('#getAlertsSuccessCallback()', function () {
-
- var testCases = [
- {
- title: 'data is null',
- data: null,
- result: []
- },
- {
- title: 'data.legacy_alerts is null',
- data: {legacy_alerts: null},
- result: []
- },
- {
- title: 'data.legacy_alerts.detail is null',
- data: {legacy_alerts: {detail: null}},
- result: []
- },
- {
- title: 'data.legacy_alerts.detail is empty',
- data: {legacy_alerts: {detail: []}},
- result: []
- }
- ];
- testCases.forEach(function (test) {
- it(test.title, function () {
- controller.set('isLoaded', false);
- controller.getAlertsSuccessCallback(test.data);
- expect(controller.get('alerts')).to.eql(test.result);
- expect(controller.get('isLoaded')).to.be.true;
- });
- });
-
- var data = {legacy_alerts: {detail: [
- {
- description: 't1',
- service_name: "s1",
- status_time: 1,
- status: 'OK',
- output: 'o1',
- host_name: 'h1',
- last_status_time: 1
- }
- ]}};
- var testCasesOfStatus = [
- {
- title: 'data.legacy_alerts.detail is correct, OK status',
- status: 'OK',
- result: '0'
- },
- {
- title: 'data.legacy_alerts.detail is correct, WARNING status',
- status: 'WARNING',
- result: '1'
- },
- {
- title: 'data.legacy_alerts.detail is correct, CRITICAL status',
- status: 'CRITICAL',
- result: '2'
- },
- {
- title: 'data.legacy_alerts.detail is correct, PASSIVE status',
- status: 'PASSIVE',
- result: '3'
- },
- {
- title: 'data.legacy_alerts.detail is correct, unknown status',
- status: '',
- result: '4'
- }
- ];
- testCasesOfStatus.forEach(function (test) {
- it(test.title, function () {
- controller.set('isLoaded', false);
- data.legacy_alerts.detail[0].status = test.status;
- controller.getAlertsSuccessCallback(data);
- expect(controller.get('alerts.length')).to.equal(1);
- expect(controller.get('alerts').objectAt(0).get('status')).to.equal(test.result);
- expect(controller.get('isLoaded')).to.be.true;
- });
- });
- });
-
- describe('#getAlertsErrorCallback()', function () {
- it('isLoaded was false', function () {
- controller.set('isLoaded', false);
- controller.getAlertsErrorCallback();
- expect(controller.get('isLoaded')).to.be.true;
- });
- it('isLoaded was true', function () {
- controller.set('isLoaded', true);
- controller.getAlertsErrorCallback();
- expect(controller.get('isLoaded')).to.be.true;
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/3dab802c/ambari-web/test/views/main/service/info/summary_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/service/info/summary_test.js b/ambari-web/test/views/main/service/info/summary_test.js
index f64ee18..42909f4 100644
--- a/ambari-web/test/views/main/service/info/summary_test.js
+++ b/ambari-web/test/views/main/service/info/summary_test.js
@@ -125,196 +125,4 @@ describe('App.MainServiceInfoSummaryView', function() {
expect(view.constructGraphObjects([])).to.be.empty;
});
});
-
- describe("#observeAlerts()", function() {
- var mock = {state: 'inDOM'};
- it("No alerts loaded", function() {
- var alerts = [];
- view.set('alertsController.alerts', []);
- view.set('alerts', alerts);
- view.observeAlerts(mock);
-
- expect(alerts).to.be.empty;
- expect(view.get('alertsMap')).to.be.empty;
- });
- it("One alert loaded", function() {
- var alerts = [];
- view.set('alertsController.alerts', [{
- id: 1
- }]);
- view.set('alerts', alerts);
- view.observeAlerts(mock);
-
- expect(alerts[0]).to.be.eql({
- "id": 1
- });
- expect(alerts.length).to.be.equal(1);
- expect(view.get('alertsMap')).to.be.eql({"1": {
- "id": 1
- }});
- });
- it("No new alerts", function() {
- var alerts = [{id: 1}];
- view.set('alertsController.alerts', []);
- view.set('alerts', alerts);
- view.set('alertsMap', {'1': {id: '1'}});
- view.observeAlerts(mock);
-
- expect(alerts).to.be.empty;
- expect(view.get('alertsMap')).to.be.empty;
- });
- before(function () {
- sinon.stub(view, 'updateAlerts', Em.K);
- });
- after(function () {
- view.updateAlerts.restore();
- });
- it("Alerts already exist", function() {
- var alerts = [{id: 1}];
- view.set('alertsController.alerts', [{
- id: 1
- }]);
- view.set('alerts', alerts);
- view.set('alertsMap', {'1': {id: '1'}});
- view.observeAlerts(mock);
-
- expect(view.updateAlerts.calledWith(
- [{
- id: 1
- }],
- [{id: 1}]
- )).to.be.true;
- });
- });
-
- describe("#updateAlerts()", function() {
- var currentAlerts = [];
- var alertsMap = {};
- var newAlerts = [];
- it("Add new alert", function() {
- newAlerts.clear();
- currentAlerts.clear();
- alertsMap = {};
-
- newAlerts.pushObjects([
- Em.Object.create({
- id: '1',
- status: '1',
- isLoaded: true
- }),
- Em.Object.create({
- id: '2',
- status: '2',
- isLoaded: true
- })
- ]);
- var currentAlert = Em.Object.create({
- id: '1',
- status: '1',
- isLoaded: true
- });
- alertsMap['1'] = currentAlert;
- view.set('alertsMap', alertsMap);
- currentAlerts.pushObject(currentAlert);
-
- view.updateAlerts(newAlerts, currentAlerts);
- expect(currentAlerts.length).to.be.equal(2);
- expect(currentAlerts[1]).to.be.eql(Em.Object.create({
- id: '2',
- status: '2',
- isLoaded: true
- }));
- expect(alertsMap).to.be.eql({
- "1": Em.Object.create({
- id: '1',
- status: '1',
- isLoaded: true
- }),
- "2": Em.Object.create({
- id: '2',
- status: '2',
- isLoaded: true
- })
- });
- });
- it("Update properties of existing alert", function() {
- newAlerts.clear();
- currentAlerts.clear();
- alertsMap = {};
-
- newAlerts.pushObjects([
- Em.Object.create({
- id: '1',
- status: '2',
- isLoaded: true
- })
- ]);
- var currentAlert = Em.Object.create({
- id: '1',
- status: '1',
- isLoaded: true
- });
- alertsMap['1'] = currentAlert;
- view.set('alertsMap', alertsMap);
- currentAlerts.pushObject(currentAlert);
-
- view.updateAlerts(newAlerts, currentAlerts);
- expect(currentAlerts.length).to.be.equal(1);
- expect(currentAlerts[0]).to.be.eql(Em.Object.create({
- id: '1',
- status: '2',
- isLoaded: true
- }));
- expect(alertsMap).to.be.eql({
- "1": Em.Object.create({
- id: '1',
- status: '2',
- isLoaded: true
- })
- });
- });
- it("delete old alert", function() {
- newAlerts.clear();
- currentAlerts.clear();
- alertsMap = {};
-
- newAlerts.pushObjects([
- Em.Object.create({
- id: '1',
- status: '1',
- isLoaded: true
- })
- ]);
- var currentAlert1 = Em.Object.create({
- id: '1',
- status: '1',
- isLoaded: true
- });
- var currentAlert2 = Em.Object.create({
- id: '2',
- status: '2',
- isLoaded: true
- });
- alertsMap["1"] = currentAlert1;
- alertsMap["2"] = currentAlert2;
- view.set('alertsMap', alertsMap);
- currentAlerts.pushObjects([currentAlert1, currentAlert2]);
-
- view.updateAlerts(newAlerts, currentAlerts);
-
- expect(currentAlerts.length).to.be.equal(1);
- expect(currentAlerts[0]).to.be.eql(Em.Object.create({
- id: '1',
- status: '1',
- isLoaded: true
- }));
- expect(alertsMap).to.be.eql({
- "1": Em.Object.create({
- id: '1',
- status: '1',
- isLoaded: true
- })
- });
- });
- });
});
\ No newline at end of file