浏览代码

AMBARI-1081. HDFS disk capacity on dashboard is seen as negative number. (Srimanth Gunturi via yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1431624 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako 12 年之前
父节点
当前提交
709f87e0b8
共有 2 个文件被更改,包括 12 次插入2 次删除
  1. 3 0
      CHANGES.txt
  2. 9 2
      ambari-web/app/views/main/dashboard/service/hdfs.js

+ 3 - 0
CHANGES.txt

@@ -654,6 +654,9 @@ AMBARI-666 branch (unreleased changes)
 
   BUG FIXES
 
+  AMBARI-1081. HDFS disk capacity on dashboard is seen as negative number.
+  (Srimanth Gunturi via yusaku)
+
   AMBARI-1148. Fix incorrect labels for configuration parameters. (yusaku)
 
   AMBARI-1080. Host disk & memory graphs have incorrect values.

+ 9 - 2
ambari-web/app/views/main/dashboard/service/hdfs.js

@@ -66,11 +66,18 @@ App.MainDashboardServiceHdfsView = App.MainDashboardServiceView.extend({
   capacity: function () {
     var text = this.t("dashboard.services.hdfs.capacityUsed");
     var total = this.get('service.capacityTotal') + 0;
-    var used = total - (this.get('service.capacityRemaining') + 0);
+    var remaining = this.get('service.capacityRemaining') + 0;
+    var used = total - remaining;
     var percent = total > 0 ? ((used * 100) / total).toFixed(1) : 0;
-    if (percent == "NaN") {
+    if (percent == "NaN" || percent < 0) {
       percent = "n/a ";
     }
+    if (used < 0) {
+      used = 0;
+    }
+    if (total < 0) {
+      total = 0;
+    }
     return text.format(used.bytesToSize(1, 'parseFloat'), total.bytesToSize(1, 'parseFloat'), percent);
   }.property('service.capacityUsed', 'service.capacityTotal'),