Sfoglia il codice sorgente

AMBARI-3372. HDFS health status hover and NameNode label changes when HA config'd. (xiwang via yusaku)

Yusaku Sako 12 anni fa
parent
commit
3b93763f2c

+ 40 - 2
ambari-web/app/mappers/status_mapper.js

@@ -102,7 +102,7 @@ App.statusMapper = App.QuickDataMapper.create({
     }
     if (hostComponent.get('isMaster')) {
       if (service.everyStartedOrMaintenance) {
-        service.everyStartedOrMaintenance = (!App.HostComponent.find().someProperty('componentName', 'SECONDARY_NAMENODE') && hostComponent.get('componentName') === 'NAMENODE' && App.HDFSService.find().filterProperty('activeNameNode.hostName').length > 0)
+        service.everyStartedOrMaintenance = (hostComponent.get('componentName') === 'NAMENODE' && !App.HostComponent.find().someProperty('componentName', 'SECONDARY_NAMENODE') && App.HDFSService.find().filterProperty('activeNameNode.hostName').length > 0)
           ? true : service.everyStartedOrMaintenance = ([App.HostComponentStatus.started, App.HostComponentStatus.maintenance].contains(hostComponent.get('workStatus')));
       } else {
         service.everyStartedOrMaintenance = false;
@@ -128,7 +128,45 @@ App.statusMapper = App.QuickDataMapper.create({
 
       service.masterComponents.push(hostComponent);
 
-      service.toolTipContent += hostComponent.get("displayName") + " " + hostComponent.get("componentTextStatus") + "<br/>";
+      // set advanced nameNode display name for HA, active or standby NameNode
+      // this is useful on three places: hdfs health status hover tooltip, hdfs service summary and NN component on host detail page
+      if (hostComponent.get('componentName') === 'NAMENODE' && !App.HostComponent.find().someProperty('componentName', 'SECONDARY_NAMENODE')) {
+        var hostName = hostComponent.get('host.hostName');
+        var services = App.Service.find();
+        var hdfs;
+        services.forEach(function (item) {
+          if (item.get("serviceName") == "HDFS") {
+            hdfs = App.HDFSService.find(item.get('id'));
+          }
+        }, this);
+        var activeNNText = Em.I18n.t('services.service.summary.nameNode.active');
+        var standbyNNText = Em.I18n.t('services.service.summary.nameNode.standby');
+        if (hdfs) {
+          if (hdfs.get('activeNameNode') && hdfs.get('activeNameNode').get('hostName')) {
+            var activeHostname = hdfs.get('activeNameNode').get('hostName');
+          }
+          if (hdfs.get('standbyNameNode') && hdfs.get('standbyNameNode').get('hostName')) {
+            var standbyHostname1 = hdfs.get('standbyNameNode').get('hostName');
+          }
+          if (hdfs.get('standbyNameNode2') && hdfs.get('standbyNameNode2').get('hostName')) {
+            var standbyHostname2 = hdfs.get('standbyNameNode2').get('hostName');
+          }
+          if ( hostName == activeHostname) {
+            hostComponent.set('displayNameAdvanced', activeNNText);
+          } else if ( hostName == standbyHostname1 || hostName == standbyHostname2) {
+            hostComponent.set('displayNameAdvanced', standbyNNText);
+          } else {
+            hostComponent.set('displayNameAdvanced', null);
+          }
+        }
+      }
+
+      if (hostComponent.get("displayNameAdvanced")) {
+        service.toolTipContent += hostComponent.get("displayNameAdvanced") + " " + hostComponent.get("componentTextStatus") + "<br/>";
+      } else {
+        service.toolTipContent += hostComponent.get("displayName") + " " + hostComponent.get("componentTextStatus") + "<br/>";
+      }
+
     }
 
     if (hostComponent.get('workStatus') !== App.HostComponentStatus.stopped &&

+ 1 - 45
ambari-web/app/views/main/dashboard/service/hdfs.js

@@ -43,52 +43,8 @@ App.MainDashboardServiceHdfsView = App.MainDashboardServiceView.extend({
       var masters = this.get('parentView.service.hostComponents').filter(function(comp){
         return comp.get('isMaster') && comp.get('componentName') !== 'JOURNALNODE';
       });
-      // enabled HA
-      if (!masters.findProperty('componentName', 'SECONDARY_NAMENODE') || masters.findProperty('componentName', 'SECONDARY_NAMENODE').get('workStatus') == 'MAINTENANCE') {
-        masters = this.setNNDisplayName();
-      }
-      return masters;
-    }.property('service'),
-    setNNDisplayName: function () {
-      var masters = this.get('parentView.service.hostComponents').filter(function(comp){
-        return comp.get('isMaster') && comp.get('componentName') !== 'JOURNALNODE';
-      });
-      var hostName0 = masters[0].get('host.hostName');
-      var activeNN = this.get('parentView.service.activeNameNode');
-      var standbyNN1 = this.get('parentView.service.standbyNameNode');
-      var standbyNN2 = this.get('parentView.service.standbyNameNode2');
-      if (activeNN) {
-        // 0 is always active
-        if (hostName0 == activeNN.get('hostName')) {
-          masters[0].set('displayNameAdvanced', Em.I18n.t('services.service.summary.nameNode.active'));
-        } else {
-          masters[1].set('displayNameAdvanced', Em.I18n.t('services.service.summary.nameNode.active'));
-          var temp = masters[0];
-          masters[0] = masters[1];
-          masters[1] = temp;
-        }
-        if (standbyNN1) {
-          masters[1].set('displayNameAdvanced', Em.I18n.t('services.service.summary.nameNode.standby'));
-        } else {
-          masters[1].set('displayNameAdvanced', null);
-        }
-      } else if (!activeNN && standbyNN2 && standbyNN1) {
-        masters[0].set('displayNameAdvanced', Em.I18n.t('services.service.summary.nameNode.standby'));
-        masters[1].set('displayNameAdvanced', Em.I18n.t('services.service.summary.nameNode.standby'));
-      } else if (!activeNN && standbyNN1 && !standbyNN2) {
-        if (hostName0 == standbyNN1.get('hostName')) {
-          masters[0].set('displayNameAdvanced', Em.I18n.t('services.service.summary.nameNode.standby'));
-          masters[1].set('displayNameAdvanced', null);
-        } else {
-          masters[1].set('displayNameAdvanced', Em.I18n.t('services.service.summary.nameNode.standby'));
-          masters[0].set('displayNameAdvanced', null);
-        }
-      } else if (!activeNN && !standbyNN1 && !standbyNN2) {
-        masters[0].set('displayNameAdvanced', null);
-        masters[1].set('displayNameAdvanced', null);
-      }
       return masters;
-    }.observes('parentView.service.activeNameNode', 'parentView.service.standbyNameNode','parentView.service.standbyNameNode2')
+    }.property('service')
   }),
 
   dataNodesLive: function(){