Explorar el Código

AMBARI-5652. Quick Links does not work if both NameNodes are in Standby. (xiwang via yusaku)

Yusaku Sako hace 11 años
padre
commit
ce220f0812

+ 3 - 2
ambari-web/app/messages.js

@@ -2036,10 +2036,11 @@ Em.I18n.translations = {
 
   'common.combobox.placeholder': 'Filter...',
   'common.combobox.dropdown.1': 'Overridden properties',
-  //'common.combobox.dropdown.2': 'Modified properties',
-  //'common.combobox.dropdown.3': 'Properties needing restart',
 
   'quick.links.error.label': 'Hostname is undefined',
+  'quick.links.publicHostName': '{0} ({1})',
+  'quick.links.label.active': 'Active',
+  'quick.links.label.standby': 'Standby',
 
   'contact.administrator': 'Contact System Administrator for more information!',
 

+ 5 - 5
ambari-web/app/styles/application.less

@@ -2550,6 +2550,11 @@ width:100%;
       position: absolute;
     }
   }
+  .dropdown-submenu {
+    &> a:after {
+      border-left-color: #333;
+    }
+  }
   .nav li.dropdown.open {
     .dropdown-toggle{
       color: #005580;
@@ -2568,11 +2573,6 @@ width:100%;
       border-bottom-color: #005580;
     }
   }
-  .disabled-hdfs-quick-link {
-    pointer-events: none;
-    color: #808080;
-    cursor: default;
-  }
 }
 
 .service-content {

+ 19 - 5
ambari-web/app/templates/main/dashboard/widgets/hbase_links.hbs

@@ -59,11 +59,25 @@
                 {{t common.more}}
                 <span class="caret"></span>
               </a>
-              <ul class="dropdown-menu">
-                {{#each view.quickLinks}}
-                  <li><a {{bindAttr href="url"}} target="_blank">{{label}}</a></li>
-                {{/each}}
-              </ul>
+                <ul class="dropdown-menu">
+                  {{#if view.quickLinksArray}}
+                     <!--there are multiple masters eg, HBase multiple masters or HDFS HA enabled-->
+                    {{#each quickLinks in view.quickLinksArray}}
+                      <li class="dropdown-submenu">
+                        <a href="javascript:void(null)">{{quickLinks.publicHostNameLabel}} &nbsp;</a>
+                        <ul class="dropdown-menu">
+                          {{#each quickLinks}}
+                            <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li>
+                          {{/each}}
+                        </ul>
+                      </li>
+                    {{/each}}
+                  {{else}}
+                    {{#each view.quickLinks}}
+                        <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li>
+                    {{/each}}
+                  {{/if}}
+                </ul>
             </div>
           {{/view}}
         {{/if}}

+ 17 - 7
ambari-web/app/templates/main/dashboard/widgets/hdfs_links.hbs

@@ -85,15 +85,25 @@
               {{t common.more}}
               <span class="caret"></span>
             </a>
-            <ul class="dropdown-menu">
-              {{#each view.quickLinks}}
-                {{#if disabled}}
-                  <li><a class="disabled-hdfs-quick-link">{{label}}</a></li>
+              <ul class="dropdown-menu">
+                {{#if view.quickLinksArray}}
+                    <!--there are multiple masters eg, HBase multiple masters or HDFS HA enabled-->
+                  {{#each quickLinks in view.quickLinksArray}}
+                    <li class="dropdown-submenu">
+                      <a href="javascript:void(null)">{{quickLinks.publicHostNameLabel}} &nbsp;</a>
+                      <ul class="dropdown-menu">
+                        {{#each quickLinks}}
+                           <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li>
+                        {{/each}}
+                      </ul>
+                    </li>
+                  {{/each}}
                 {{else}}
-                  <li><a {{bindAttr href="url"}} target="_blank">{{label}}</a></li>
+                  {{#each view.quickLinks}}
+                      <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li>
+                  {{/each}}
                 {{/if}}
-              {{/each}}
-            </ul>
+              </ul>
           </div>
         {{/view}}
       {{/if}}

+ 18 - 8
ambari-web/app/templates/main/service/item.hbs

@@ -24,14 +24,24 @@
           <li class="dropdown">
             <a class="dropdown-toggle" data-toggle="dropdown" href="#">{{t common.quickLinks}}<b class="caret"></b></a>
             <ul class="dropdown-menu">
-              {{#each view.quickLinks}}
-                {{#if disabled}}
-                  <li><a class="disabled-hdfs-quick-link">{{label}}</a></li>
-                {{else}}
-                  <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li>
-                {{/if}}
-              {{/each}}
-            </ul>
+              {{#if view.quickLinksArray}}
+                <!--there are multiple masters eg, HBase multiple masters or HDFS HA enabled-->
+                {{#each quickLinks in view.quickLinksArray}}
+                   <li class="dropdown-submenu">
+                     <a href="javascript:void(null)">{{quickLinks.publicHostNameLabel}} &nbsp;</a>
+                     <ul class="dropdown-menu">
+                       {{#each quickLinks}}
+                         <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li>
+                       {{/each}}
+                     </ul>
+                   </li>
+                {{/each}}
+              {{else}}
+                {{#each view.quickLinks}}
+                   <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li>
+                {{/each}}
+              {{/if}}
+           </ul>
           </li>
         </ul>
       {{/view}}

+ 79 - 31
ambari-web/app/views/common/quick_view_link_view.js

@@ -82,20 +82,31 @@ App.QuickViewLinks = Em.View.extend({
     this.loadTags();
     var serviceName = this.get('content.serviceName');
     var components = this.get('content.hostComponents');
-    var host;
+    var hosts = [];
     var self = this;
     var version = App.get('currentStackVersionNumber');
     var quickLinks = [];
     switch (serviceName) {
       case "HDFS":
-        if (this.get('content.snameNode')) { // not HA
-          host = this.findComponentHost('NAMENODE');
+        var otherHost;
+        if (this.get('content.snameNode')) {
+          // not HA
+          hosts[0] = this.findComponentHost('NAMENODE');
         } else {
-          // HA
+          // HA enabled, need both two namenodes hosts
+          var nameNodes = components.filterProperty('componentName', 'NAMENODE');
+          nameNodes.forEach(function(item) {
+            hosts.push({'publicHostName': item.get('host.publicHostName')});
+          });
+          // assign each namenode status label
           if (this.get('content.activeNameNode')) {
-            host = this.get('content.activeNameNode.publicHostName');
-          } else {
-            host = 'noActiveNN';
+            hosts.findProperty('publicHostName', this.get('content.activeNameNode.publicHostName')).status = Em.I18n.t('quick.links.label.active');
+          }
+          if (this.get('content.standbyNameNode')) {
+            hosts.findProperty('publicHostName', this.get('content.standbyNameNode.publicHostName')).status = Em.I18n.t('quick.links.label.standby');
+          }
+          if (this.get('content.standbyNameNode2')) {
+            hosts.findProperty('publicHostName', this.get('content.standbyNameNode2.publicHostName')).status = Em.I18n.t('quick.links.label.standby');
           }
         }
         break;
@@ -104,61 +115,98 @@ App.QuickViewLinks = Em.View.extend({
       case "GANGLIA":
       case "NAGIOS":
       case "HUE":
-        host = App.singleNodeInstall ? App.singleNodeAlias : components.findProperty('isMaster', true).get("host").get("publicHostName");
+        hosts[0] = App.singleNodeInstall ? App.singleNodeAlias : components.findProperty('isMaster', true).get("host").get("publicHostName");
         break;
       case "HBASE":
-        var component;
+        var masterComponents = components.filterProperty('componentName', 'HBASE_MASTER');
+        var activeMaster, standbyMasters, otherMasters;
         if (App.supports.multipleHBaseMasters) {
-          component = components.filterProperty('componentName', 'HBASE_MASTER').findProperty('haStatus', 'true');
-        } else {
-          component = components.findProperty('componentName', 'HBASE_MASTER');
+          activeMaster = masterComponents.filterProperty('haStatus', 'true');
+          standbyMasters = masterComponents.filterProperty('haStatus', 'false');
+          otherMasters = masterComponents.filterProperty('haStatus', null);
         }
-        if (component) {
+        if (masterComponents) {
           if (App.singleNodeInstall) {
-            host = App.singleNodeAlias;
+            hosts[0] = App.singleNodeAlias;
+          } else if (masterComponents.length > 1) {
+            // need all hbase_masters hosts in quick links
+            if (activeMaster) {
+              activeMaster.forEach(function(item) {
+                hosts.push({'publicHostName': item.get('host.publicHostName'), 'status': Em.I18n.t('quick.links.label.active')});
+              });
+            }
+            if (standbyMasters) {
+              standbyMasters.forEach(function(item) {
+                hosts.push({'publicHostName': item.get('host.publicHostName'), 'status': Em.I18n.t('quick.links.label.standby')});
+              });
+            }
+            if (otherMasters) {
+              otherMasters.forEach(function(item) {
+                hosts.push({'publicHostName': item.get('host.publicHostName')});
+              });
+            }
           } else {
-            host = component.get('host.publicHostName');
+            hosts[0] = masterComponents[0].get('host.publicHostName');
           }
-        } else {
-          host = 'noActiveHbaseMaster';
         }
         break;
       case "YARN":
-        host = this.findComponentHost('RESOURCEMANAGER');
+        hosts[0] = this.findComponentHost('RESOURCEMANAGER');
         break;
       case "MAPREDUCE2":
-        host = this.findComponentHost('HISTORYSERVER');
+        hosts[0] = this.findComponentHost('HISTORYSERVER');
         break;
       case "FALCON":
-        host = this.findComponentHost('FALCON_SERVER');
+        hosts[0] = this.findComponentHost('FALCON_SERVER');
         break;
       case "STORM":
-        host = this.findComponentHost('NIMBUS');
+        hosts[0] = this.findComponentHost('NIMBUS');
         break;
     }
-    if (!host) {
+    if (!hosts) {
       quickLinks = [
         {
           label: this.t('quick.links.error.label'),
           url: 'javascript:alert("' + this.t('contact.administrator') + '");return false;'
         }
       ];
-    } else {
+      this.set('quickLinks', quickLinks);
+    } else if (hosts.length == 1) {
+
       quickLinks = this.get('content.quickLinks').map(function (item) {
-        if (host == 'noActiveNN' || host == 'noActiveHbaseMaster') {
-          item.set('disabled', true);
-        } else {
-          item.set('disabled', false);
+        var protocol = self.setProtocol(item.get('service_id'));
+        if (item.get('template')) {
+          var port = item.get('http_config') && self.setPort(item, protocol, version);
+          item.set('url', item.get('template').fmt(protocol, hosts[0], port));
+        }
+        return item;
+      });
+      this.set('quickLinks', quickLinks);
+    } else {
+      // multiple hbase masters or HDFS HA enabled
+      var quickLinksArray = [];
+      hosts.forEach(function(host){
+        var quickLinks = [];
+        self.get('content.quickLinks').forEach(function (item) {
+          var newItem = {};
           var protocol = self.setProtocol(item.get('service_id'));
           if (item.get('template')) {
             var port = item.get('http_config') && self.setPort(item, protocol, version);
-            item.set('url', item.get('template').fmt(protocol, host, port));
+            newItem.url = item.get('template').fmt(protocol, host.publicHostName, port);
+            newItem.label =  item.get('label');
           }
+          quickLinks.push(newItem);
+        });
+        if (host.status) {
+          quickLinks.set('publicHostNameLabel', Em.I18n.t('quick.links.publicHostName').format(host.publicHostName, host.status));
+        } else {
+          quickLinks.set('publicHostNameLabel', host.publicHostName);
         }
-        return item;
-      });
+        quickLinksArray.push(quickLinks);
+      }, this);
+
+      this.set('quickLinksArray', quickLinksArray);
     }
-    this.set('quickLinks', quickLinks);
   }.observes('App.currentStackVersionNumber', 'App.singleNodeInstall'),
 
   setProtocol: function (service_id) {