ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xiw...@apache.org
Subject [1/2] git commit: AMBARI-5009. 'Disk_total' for one host returns 0 and the UI displays -Infinity%.(xiwang)
Date Wed, 12 Mar 2014 00:25:37 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 9069cb2fe -> e1d621ce6


AMBARI-5009. 'Disk_total' for one host returns 0 and the UI displays -Infinity%.(xiwang)


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

Branch: refs/heads/trunk
Commit: e1d621ce67a9115614144462ff0bbb96b4abfe11
Parents: 2efb779
Author: Xi Wang <xiwang@apache.org>
Authored: Mon Mar 10 17:37:40 2014 -0700
Committer: Xi Wang <xiwang@apache.org>
Committed: Tue Mar 11 17:24:51 2014 -0700

----------------------------------------------------------------------
 .../heatmap_metric_diskspaceused.js                | 17 ++++++++++++++---
 ambari-web/app/messages.js                         |  1 +
 ambari-web/app/models/host.js                      |  2 +-
 3 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e1d621ce/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_diskspaceused.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_diskspaceused.js
b/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_diskspaceused.js
index d103fc3..403e034 100644
--- a/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_diskspaceused.js
+++ b/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_diskspaceused.js
@@ -28,6 +28,7 @@ App.MainChartHeatmapDiskSpaceUsedMetric = App.MainChartHeatmapMetric.extend({
   slotDefinitionLabelSuffix: '%',
   metricMapper: function (json) {
     var hostToValueMap = {};
+    var self = this;
     var metricName = this.get('defaultMetric');
     if (json.items) {
       var props = metricName.split('.');
@@ -41,14 +42,24 @@ App.MainChartHeatmapDiskSpaceUsedMetric = App.MainChartHeatmapMetric.extend({
           }
         });
         if (value != null) {
-          var total = value.disk_total;
-          var free = value.disk_free;
-          value = (((total - free) * 100) / total).toFixed(1);
+          value = self.diskUsageFormatted(value.disk_total - value.disk_free, value.disk_total);
           var hostName = item.Hosts.host_name;
           hostToValueMap[hostName] = value;
         }
       });
     }
     return hostToValueMap;
+  },
+
+  /**
+   * Format percent disk usage to float with 2 digits
+   */
+  diskUsageFormatted: function(diskUsed, diskTotal) {
+    var diskUsage = (diskUsed) / diskTotal * 100;
+    if (isNaN(diskUsage) || diskUsage < 0 || diskUsage > 100) {
+      return Em.I18n.t('charts.heatmap.unknown');
+    }
+    var s = Math.round(diskUsage * Math.pow(10, 2)) / Math.pow(10, 2);
+    return isNaN(s) ? 0 : s;
   }
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/e1d621ce/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 875fc29..fc60607 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1427,6 +1427,7 @@ Em.I18n.translations = {
 
   'hosts.host.serviceNotAvailable': 'Service not available on this host',
 
+  'hosts.host.metrics.dataUnavailable':'Data Unavailable',
   'hosts.host.metrics.cpu':'CPU Usage',
   'hosts.host.metrics.cpu.displayNames.cpu_wio':'CPU I/O Idle',
   'hosts.host.metrics.cpu.displayNames.cpu_idle':'CPU Idle',

http://git-wip-us.apache.org/repos/asf/ambari/blob/e1d621ce/ambari-web/app/models/host.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/host.js b/ambari-web/app/models/host.js
index 0924ba6..947bb89 100644
--- a/ambari-web/app/models/host.js
+++ b/ambari-web/app/models/host.js
@@ -147,7 +147,7 @@ App.Host = DS.Model.extend({
    */
   diskUsageFormatted: function() {
     if (isNaN(this.get('diskUsage')) || this.get('diskUsage') < 0) {
-      return 'Data Unavailable';
+      return Em.I18n.t('hosts.host.metrics.dataUnavailable');
     }
     var s = Math.round(this.get('diskUsage') * Math.pow(10, 2)) / Math.pow(10, 2);
     if (isNaN(s)) {


Mime
View raw message