ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject ambari git commit: AMBARI-9866 Alerts display box not refreshing even after alert is Green. (ababiichuk)
Date Tue, 03 Mar 2015 07:09:42 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.0.0 f91beb047 -> d210c360c


AMBARI-9866 Alerts display box not refreshing even after alert is Green. (ababiichuk)


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

Branch: refs/heads/branch-2.0.0
Commit: d210c360cc61908112d51437a07b406210542504
Parents: f91beb0
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Mon Mar 2 20:02:10 2015 +0200
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Tue Mar 3 09:09:19 2015 +0200

----------------------------------------------------------------------
 .../app/controllers/global/update_controller.js |  9 ++-
 .../main/alerts/alert_instances_controller.js   |  2 +-
 .../app/mappers/alert_instances_mapper.js       | 58 +++++++++++++++-----
 .../test/mappers/alert_instances_mapper_test.js | 10 +++-
 4 files changed, 62 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d210c360/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 1c2c5ed..4958210 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -23,6 +23,9 @@ App.UpdateController = Em.Controller.extend({
   isUpdated: false,
   cluster: null,
   isWorking: false,
+  updateAlertInstances: function() {
+    return this.get('isWorking') && !App.get('router.mainAlertInstancesController.isUpdating');
+  }.property('isWorking', 'App.router.mainAlertInstancesController.isUpdating'),
   timeIntervalId: null,
   clusterName: function () {
     return App.router.get('clusterController.clusterName');
@@ -132,9 +135,11 @@ App.UpdateController = Em.Controller.extend({
       App.updater.run(this, 'updateAlertGroups', 'isWorking', App.alertGroupsUpdateInterval);
       App.updater.run(this, 'updateAlertDefinitions', 'isWorking', App.alertDefinitionsUpdateInterval);
       App.updater.run(this, 'updateAlertDefinitionSummary', 'isWorking', App.alertDefinitionsUpdateInterval);
-      App.updater.run(this, 'updateUnhealthyAlertInstances', 'isWorking', App.alertInstancesUpdateInterval);
+      if (!App.get('router.mainAlertInstancesController.isUpdating')) {
+        App.updater.run(this, 'updateUnhealthyAlertInstances', 'updateAlertInstances', App.alertInstancesUpdateInterval);
+      }
     }
-  }.observes('isWorking'),
+  }.observes('isWorking', 'App.router.mainAlertInstancesController.isUpdating'),
   /**
    * Update service metrics depending on which page is open
    * Make a call only on follow pages:

http://git-wip-us.apache.org/repos/asf/ambari/blob/d210c360/ambari-web/app/controllers/main/alerts/alert_instances_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/alerts/alert_instances_controller.js b/ambari-web/app/controllers/main/alerts/alert_instances_controller.js
index 9df59e2..a3bf7fe 100644
--- a/ambari-web/app/controllers/main/alerts/alert_instances_controller.js
+++ b/ambari-web/app/controllers/main/alerts/alert_instances_controller.js
@@ -158,7 +158,7 @@ App.MainAlertInstancesController = Em.Controller.extend({
    * @method getAlertInstancesSuccessCallback
    */
   getAlertInstancesSuccessCallback: function (json) {
-    App.alertInstanceMapper.map(json);
+    App.alertInstanceMapper.map(json, true);
     this.set('isLoaded', true);
     this.set('reload', !this.get('reload'));
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/d210c360/ambari-web/app/mappers/alert_instances_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/alert_instances_mapper.js b/ambari-web/app/mappers/alert_instances_mapper.js
index 9014892..852ce71 100644
--- a/ambari-web/app/mappers/alert_instances_mapper.js
+++ b/ambari-web/app/mappers/alert_instances_mapper.js
@@ -40,21 +40,53 @@ App.alertInstanceMapper = App.QuickDataMapper.create({
     text: 'Alert.text'
   },
 
-  map: function(json) {
+  map: function(json, skipDelete) {
     if (json.items) {
-      var self = this,
-        alertInstances = [],
-        model = this.get('model'),
-        alertsToDelete = model.find().mapProperty('id');
-
-      json.items.forEach(function (item) {
-        var alert = this.parseIt(item, this.get('config'));
-        alertInstances.push(alert);
-        alertsToDelete = alertsToDelete.without(alert.id);
-      }, this);
-
-      App.store.loadMany(model, alertInstances);
+      var alertInstances = (skipDelete) ? this.mapWithoutDelete(json) : this.mapAndDelete(json);
+
+      App.store.loadMany(this.get('model'), alertInstances);
     }
+  },
+
+  /**
+   * method that used when we not on alert definition state
+   * in this case we need to delete alerts that is not critical and not warning
+   * @param json
+   * @returns {Array}
+   */
+  mapAndDelete: function(json) {
+    var self = this,
+      alertInstances = [],
+      model = this.get('model'),
+      alertsToDelete = model.find().mapProperty('id');
+
+    json.items.forEach(function (item) {
+      var alert = this.parseIt(item, this.get('config'));
+      alertInstances.push(alert);
+      alertsToDelete = alertsToDelete.without(alert.id);
+    }, this);
+
+
+    alertsToDelete.forEach(function(alertId) {
+      var item = model.find(alertId);
+      self.deleteRecord(item);
+    });
+
+    return alertInstances;
+  },
+
+  /**
+   * this method is used on alert definition page
+   * @param json
+   * @returns {Array}
+   */
+  mapWithoutDelete: function(json) {
+    var alertInstances = [];
+    json.items.forEach(function (item) {
+      var alert = this.parseIt(item, this.get('config'));
+      alertInstances.push(alert);
+    }, this);
+    return alertInstances;
   }
 
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/d210c360/ambari-web/test/mappers/alert_instances_mapper_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mappers/alert_instances_mapper_test.js b/ambari-web/test/mappers/alert_instances_mapper_test.js
index 1d60869..1cdab7f 100644
--- a/ambari-web/test/mappers/alert_instances_mapper_test.js
+++ b/ambari-web/test/mappers/alert_instances_mapper_test.js
@@ -94,10 +94,18 @@ describe('App.alertInstanceMapper', function () {
 
   });
 
-  it('shouldn\'t delete not existing models', function () {
+  it('should delete models', function () {
 
     App.alertInstanceMapper.map(json);
 
+    expect(App.alertInstanceMapper.deleteRecord.called).to.be.true;
+
+  });
+
+  it('shouldn\'t delete not existing models', function () {
+
+    App.alertInstanceMapper.map(json, true);
+
     expect(App.alertInstanceMapper.deleteRecord.called).to.be.false;
 
   });


Mime
View raw message