Browse Source

AMBARI-3277. HDFS shows red when NameNode HA is enabled. (xiwang via yusaku)

Yusaku Sako 11 years ago
parent
commit
074d8395ea
2 changed files with 17 additions and 6 deletions
  1. 10 6
      ambari-web/app/models/service.js
  2. 7 0
      ambari-web/app/models/service/hdfs.js

+ 10 - 6
ambari-web/app/models/service.js

@@ -71,8 +71,7 @@ App.Service = DS.Model.extend({
       serviceName = this.get('serviceName'),
       isRunning = true,
       runningHCs = [],
-      unknownHCs = [],
-      hdfsHealthStatus;
+      unknownHCs = [];
 
     //look through all components to find out common statuses
     this.get('hostComponents').forEach(function (_hostComponent) {
@@ -133,16 +132,21 @@ App.Service = DS.Model.extend({
       }
     }
 
+    /**
+     * Both App.HDFSService and its parent (App.Service) can hit this block.
+     * We need a property: App.HDFSService.hdfsHealthStatus to store the correct status.
+     * When App.HDFSService get in, we store the status in that property based on if activeNN existed.
+     * When App.Service get in, we get correct health status from that property.
+     */
     if (isGreen && serviceName === 'HDFS' && masterComponents.length == 5) { // enabled HA
       var activeNN = this.get('activeNameNode');
       var nameNode = this.get('nameNode');
-
       if (nameNode && !activeNN) { //hdfs model but no active NN
-        hdfsHealthStatus = 'red';
+        App.HDFSService.hdfsHealthStatus = 'red';
       } else if (nameNode && activeNN) {
-        hdfsHealthStatus = 'green';
+        App.HDFSService.hdfsHealthStatus = 'green';
       }
-      this.set('healthStatus', hdfsHealthStatus);
+      this.set('healthStatus', App.HDFSService.hdfsHealthStatus);
     }
 
     this.set('isStarted', everyStarted);

+ 7 - 0
ambari-web/app/models/service/hdfs.js

@@ -46,4 +46,11 @@ App.HDFSService = App.Service.extend({
   nameNodeRpc: DS.attr('number')
 });
 
+/**
+ * Use this property only in its parent class to store hdfs health status.
+ */
+App.HDFSService.reopenClass({
+  hdfsHealthStatus: ''
+});
+
 App.HDFSService.FIXTURES = [];