incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject svn commit: r1431584 - in /incubator/ambari/trunk: ./ ambari-web/app/ ambari-web/app/controllers/global/ ambari-web/app/mappers/ ambari-web/app/models/ ambari-web/app/styles/ ambari-web/app/templates/main/service/info/
Date Thu, 10 Jan 2013 19:55:33 GMT
Author: yusaku
Date: Thu Jan 10 19:55:32 2013
New Revision: 1431584

URL: http://svn.apache.org/viewvc?rev=1431584&view=rev
Log:
AMBARI-1071. Nagios alerts not updating in UI.  (Srimanth Gunturi via yusaku)

Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/ambari-web/app/app.js
    incubator/ambari/trunk/ambari-web/app/controllers/global/cluster_controller.js
    incubator/ambari/trunk/ambari-web/app/mappers/alerts_mapper.js
    incubator/ambari/trunk/ambari-web/app/models/alert.js
    incubator/ambari/trunk/ambari-web/app/styles/application.less
    incubator/ambari/trunk/ambari-web/app/templates/main/service/info/summary_alert.hbs

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1431584&r1=1431583&r2=1431584&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Thu Jan 10 19:55:32 2013
@@ -639,6 +639,8 @@ AMBARI-666 branch (unreleased changes)
 
   BUG FIXES
 
+  AMBARI-1071. Nagios alerts not updating in UI. (Srimanth Gunturi via yusaku)
+
   AMBARI-1063. Workflow Web Service potentially leaks DB connections upon
   exceptions. (yusaku)
 

Modified: incubator/ambari/trunk/ambari-web/app/app.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/app.js?rev=1431584&r1=1431583&r2=1431584&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/app.js (original)
+++ incubator/ambari/trunk/ambari-web/app/app.js Thu Jan 10 19:55:32 2013
@@ -63,7 +63,7 @@ DS.attr.transforms.date = {
   to: function (deserialized) {
     if (deserialized instanceof Date) {
       return deserialized.getTime();
-    } else if (date === undefined) {
+    } else if (deserialized === undefined) {
       return undefined;
     } else {
       return null;

Modified: incubator/ambari/trunk/ambari-web/app/controllers/global/cluster_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/global/cluster_controller.js?rev=1431584&r1=1431583&r2=1431584&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/global/cluster_controller.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/global/cluster_controller.js Thu Jan
10 19:55:32 2013
@@ -169,7 +169,7 @@ App.ClusterController = Em.Controller.ex
       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('time');
+        var leftTime = left.get('date');
         rightTime = rightTime ? rightTime.getTime() : 0;
         leftTime = leftTime ? leftTime.getTime() : 0;
         statusDiff = rightTime - leftTime;

Modified: incubator/ambari/trunk/ambari-web/app/mappers/alerts_mapper.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/mappers/alerts_mapper.js?rev=1431584&r1=1431583&r2=1431584&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/mappers/alerts_mapper.js (original)
+++ incubator/ambari/trunk/ambari-web/app/mappers/alerts_mapper.js Thu Jan 10 19:55:32 2013
@@ -31,7 +31,7 @@ App.alertsMapper = App.QuickDataMapper.c
     last_hard_state_change: "last_hard_state_change",
     last_hard_state: "last_hard_state",
     last_time_ok: "last_time_ok",
-    last_wime_warning: "last_time_warning",
+    last_time_warning: "last_time_warning",
     last_time_unknown: "last_time_unknown",
     last_time_critical: "last_time_critical",
     is_flapping: "is_flapping",
@@ -54,14 +54,38 @@ App.alertsMapper = App.QuickDataMapper.c
     }
   },
   update: function(json){
-    var alerts = App.Alert.find();
-    var result = [];
-    json.alerts.forEach(function (item) {
-      if (!alerts.filterProperty('title', item.service_description).length) {
-        result.push(this.parseIt(item, this.config));
+    var alertsList = App.Alert.find();
+    var titleToAlertMap = {};
+    alertsList.forEach(function(alert){
+      titleToAlertMap[alert.get('serviceType') + alert.get('title') + alert.get('message')]
= alert;
+    });
+    var newRecords = [];
+    json.alerts.forEach(function(item){
+      var existAlert = titleToAlertMap[item.service_type + item.service_description + item.plugin_output];
+      if (existAlert == null) {
+        newRecords.push(this.parseIt(item, this.config));
+      } else {
+        // update record
+        existAlert.set('serviceType', item.service_type);
+        existAlert.set('date', DS.attr.transforms.date.from(item.last_hard_state_change));
+        existAlert.set('status', item.current_state);
+        existAlert.set('message', item.plugin_output);
+        existAlert.set('lastHardStateChange', item.last_hard_state_change);
+        existAlert.set('lastHardState', item.last_hard_state);
+        existAlert.set('lastTimeOk', item.last_time_ok);
+        existAlert.set('lastTimeWarning', item.last_time_warning);
+        existAlert.set('lastTimeUnknown', item.last_time_unknown);
+        existAlert.set('lastTimeCritical', item.last_time_critical);
+        existAlert.set('lastCheck', item.last_check);
+        existAlert.set('isFlapping', item.is_flapping);
+        delete titleToAlertMap[item.service_type + item.service_description + item.plugin_output];
       }
     }, this);
-    App.store.loadMany(this.get('model'), result);
-
+    for ( var e in titleToAlertMap) {
+      titleToAlertMap[e].deleteRecord();
+    }
+    if (newRecords.length > 0) {
+      App.store.loadMany(this.get('model'), newRecords); // Add new records
+    }
   }
 });

Modified: incubator/ambari/trunk/ambari-web/app/models/alert.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/models/alert.js?rev=1431584&r1=1431583&r2=1431584&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/models/alert.js (original)
+++ incubator/ambari/trunk/ambari-web/app/models/alert.js Thu Jan 10 19:55:32 2013
@@ -45,6 +45,7 @@ App.Alert = DS.Model.extend({
   lastTimeCritical: DS.attr('number'),
   isFlapping: DS.attr('number'),
   lastCheck: DS.attr('number'),
+
   /**
    * Used to show correct icon in UI
    */
@@ -53,6 +54,13 @@ App.Alert = DS.Model.extend({
   }.property('status'),
 
   /**
+   * Used to show correct icon in UI
+   */
+  isWarning: function () {
+    return this.get('status') == "1";
+  }.property('status'),
+
+  /**
    * Provides how long ago this alert happened.
    * 
    * @type {String}

Modified: incubator/ambari/trunk/ambari-web/app/styles/application.less
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/styles/application.less?rev=1431584&r1=1431583&r2=1431584&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/styles/application.less (original)
+++ incubator/ambari/trunk/ambari-web/app/styles/application.less Thu Jan 10 19:55:32 2013
@@ -190,6 +190,10 @@ h1 {
   color: #5AB400;
 }
 
+.icon-warning-sign {
+  color: #FDB82F;
+}
+
 .icon-empty {
   height: 21px;
   display: inline-block;

Modified: incubator/ambari/trunk/ambari-web/app/templates/main/service/info/summary_alert.hbs
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/templates/main/service/info/summary_alert.hbs?rev=1431584&r1=1431583&r2=1431584&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/templates/main/service/info/summary_alert.hbs (original)
+++ incubator/ambari/trunk/ambari-web/app/templates/main/service/info/summary_alert.hbs Thu
Jan 10 19:55:32 2013
@@ -22,7 +22,11 @@
           {{#if isOk}}
               <i class="icon-ok icon-large"></i>
           {{else}}
-              <i class="icon-remove icon-large"></i>
+	          {{#if isWarning}}
+	              <i class="icon-warning-sign icon-large"></i>
+	          {{else}}
+	              <i class="icon-remove icon-large"></i>
+	          {{/if}}
           {{/if}}
         </div>
         <div class="span11">



Mime
View raw message