Browse Source

AMBARI-6793. Need ResourceManager UI Quicklinks for active / standby. (akovalenko)

Aleksandr Kovalenko 10 years ago
parent
commit
7826a3ff41

+ 2 - 2
ambari-web/app/mappers/service_metrics_mapper.js

@@ -170,7 +170,7 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({
     host_id: 'HostRoles.host_name',
     host_name: 'HostRoles.host_name',
     stale_configs: 'HostRoles.stale_configs',
-    ha_state: 'HostRoles.ha_state',
+    ha_status: 'HostRoles.ha_state',
     display_name_advanced: 'display_name_advanced',
     $service_id: 'none' /* will be set outside of parse function */
   },
@@ -352,7 +352,7 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({
             hostComponent.display_name_advanced = null;
           }
         } else if (hostComponent.component_name === 'RESOURCEMANAGER' && isRMHAEnabled && hostComponent.work_status === 'STARTED') {
-          switch (hostComponent.ha_state) {
+          switch (hostComponent.ha_status) {
             case 'ACTIVE':
               hostComponent.display_name_advanced = Em.I18n.t('dashboard.services.yarn.resourceManager.active');
               break;

+ 27 - 12
ambari-web/app/views/common/quick_view_link_view.js

@@ -111,7 +111,7 @@ App.QuickViewLinks = Em.View.extend({
 
   findComponentHost: function (components, componentName) {
     return App.singleNodeInstall ? App.singleNodeAlias : components.find(function (item) {
-      return item.host_components.mapProperty('HostRoles.component_name').contains(componentName);
+      return item.host_components.someProperty('HostRoles.component_name', componentName);
     }).Hosts.public_host_name
   },
 
@@ -127,17 +127,13 @@ App.QuickViewLinks = Em.View.extend({
     var quickLinks = [];
     switch (serviceName) {
       case "HDFS":
-        var otherHost;
         if (this.get('content.snameNode')) {
           // not HA
           hosts[0] = this.findComponentHost(response.items, 'NAMENODE');
         } else {
           // HA enabled, need both two namenodes hosts
-          var nameNodes = response.items.filter(function (item) {
-            return item.host_components.mapProperty('HostRoles.component_name').contains('NAMENODE');
-          });
-          nameNodes.forEach(function(item) {
-            hosts.push({'publicHostName': item.Hosts.public_host_name});
+          this.get('content.hostComponents').filterProperty('componentName', 'NAMENODE').forEach(function (component) {
+            hosts.push({'publicHostName': response.items.findProperty('Hosts.host_name', component.get('hostName')).Hosts.public_host_name});
           });
           // assign each namenode status label
           if (this.get('content.activeNameNode')) {
@@ -160,18 +156,18 @@ App.QuickViewLinks = Em.View.extend({
         break;
       case "HBASE":
         var masterComponents = response.items.filter(function (item) {
-            return item.host_components.mapProperty('HostRoles.component_name').contains('HBASE_MASTER');
+            return item.host_components.someProperty('HostRoles.component_name', 'HBASE_MASTER');
         });
         var activeMaster, standbyMasters, otherMasters;
         if (App.supports.multipleHBaseMasters) {
           activeMaster = masterComponents.filter(function (item) {
-            return item.host_components.mapProperty('metrics.hbase.master.IsActiveMaster').contains('true');
+            return item.host_components.someProperty('metrics.hbase.master.IsActiveMaster', 'true');
           });
           standbyMasters = masterComponents.filter(function (item) {
-            return item.host_components.mapProperty('metrics.hbase.master.IsActiveMaster').contains('false');
+            return item.host_components.someProperty('metrics.hbase.master.IsActiveMaster', 'false');
           });
           otherMasters = masterComponents.filter(function (item) {
-            return !(item.host_components.mapProperty('metrics.hbase.master.IsActiveMaster').contains('true') || item.host_components.mapProperty('metrics.hbase.master.IsActiveMaster').contains('false')) ;
+            return !(item.host_components.someProperty('metrics.hbase.master.IsActiveMaster', 'true') || item.host_components.someProperty('metrics.hbase.master.IsActiveMaster', 'false')) ;
           });
         }
         if (masterComponents) {
@@ -200,7 +196,26 @@ App.QuickViewLinks = Em.View.extend({
         }
         break;
       case "YARN":
-        hosts[0] = this.findComponentHost(response.items, 'RESOURCEMANAGER');
+        if (App.get('isRMHaEnabled')) {
+          this.get('content.hostComponents').filterProperty('componentName', 'RESOURCEMANAGER').forEach(function (component) {
+            var newHost = {'publicHostName': response.items.findProperty('Hosts.host_name', component.get('hostName')).Hosts.public_host_name};
+            var status = '';
+            switch (component.get('haStatus')) {
+              case 'ACTIVE':
+                status = Em.I18n.t('quick.links.label.active');
+                break;
+              case 'STANDBY':
+                status = Em.I18n.t('quick.links.label.standby');
+                break;
+            }
+            if (status) {
+              newHost.status = status;
+            }
+            hosts.push(newHost);
+          }, this);
+        } else {
+          hosts[0] = this.findComponentHost(response.items, 'RESOURCEMANAGER');
+        }
         break;
       case "MAPREDUCE2":
         hosts[0] = this.findComponentHost(response.items, 'HISTORYSERVER');