Browse Source

AMBARI-15956. Add quick links to the hs2 interactive UI on Ambari. (Jaimin)

Jaimin Jetly 9 years ago
parent
commit
ef9106762d

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.5/services/HIVE/configuration/hive-interactive-site.xml

@@ -262,7 +262,7 @@ limitations under the License.
   </property>
 
   <property>
-    <name>hive.server2.webui.port </name>
+    <name>hive.server2.webui.port</name>
     <value>10502</value>
     <description>Web UI port address</description>
   </property>

+ 6 - 0
ambari-server/src/main/resources/stacks/HDP/2.5/services/HIVE/metainfo.xml

@@ -113,6 +113,12 @@
           <default>true</default>
         </theme>
       </themes>
+      <quickLinksConfigurations>
+        <quickLinksConfiguration>
+          <fileName>quicklinks.json</fileName>
+          <default>true</default>
+        </quickLinksConfiguration>
+      </quickLinksConfigurations>
 
       <requiredServices>
         <service>ZOOKEEPER</service>

+ 26 - 0
ambari-server/src/main/resources/stacks/HDP/2.5/services/HIVE/quicklinks/quicklinks.json

@@ -0,0 +1,26 @@
+{
+  "name": "default",
+  "description": "default quick links configuration",
+  "configuration": {
+    "protocol": {
+      "type":"HTTP_ONLY"
+    },
+
+    "links": [
+      {
+        "name": "hiveserver2_ui",
+        "label": "HiveServer2 Interactive UI",
+        "requires_user_name": "false",
+        "url": "%@://%@:%@/llap/llap0",
+        "port":{
+          "http_property": "hive.server2.webui.port",
+          "http_default_port": "10502",
+          "https_property": "hive.server2.webui.port",
+          "https_default_port": "10502",
+          "regex": "\\w*:(\\d+)",
+          "site": "hive-interactive-site"
+        }
+      }
+    ]
+  }
+}

+ 18 - 0
ambari-web/app/models/quicklinks/quick_links_config.js

@@ -33,3 +33,21 @@ App.QuickLinksConfig = DS.Model.extend({
 });
 
 App.QuickLinksConfig.FIXTURES = [];
+
+/**
+ *  key = service name and value = master component name
+ * @type {{OOZIE: string, HDFS: string, HBASE: string, YARN: string, HIVE: string, STORM: string, ACCUMULO: string, ATLAS: string, MAPREDUCE2: string, AMBARI_METRICS: string, LOGSEARCH: string}}
+ */
+App.QuickLinksConfig.ServiceComponentMap = {
+  'OOZIE': 'OOZIE_SERVER',
+  'HDFS': 'NAMENODE',
+  'HBASE':'HBASE_MASTER',
+  'YARN' : 'RESOURCEMANAGER',
+  'HIVE' : 'HIVE_SERVER_INTERACTIVE',
+  'STORM': 'STORM_UI_SERVER',
+  'ACCUMULO': 'ACCUMULO_MONITOR',
+  'ATLAS': 'ATLAS_SERVER',
+  'MAPREDUCE2': 'HISTORYSERVER',
+  'AMBARI_METRICS': 'METRICS_GRAFANA',
+  'LOGSEARCH': 'LOGSEARCH_SERVER'
+};

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

@@ -73,14 +73,14 @@
                           <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>
+                              <li><a {{bindAttr href="url"}} target="_blank">{{label}}</a></li>
                             {{/each}}
                           </ul>
                         </li>
                       {{/each}}
                     {{else}}
                       {{#each view.quickLinks}}
-                        <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li>
+                        <li><a {{bindAttr href="url"}} target="_blank">{{label}}</a></li>
                       {{/each}}
                     {{/if}}
                   {{else}}

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

@@ -94,14 +94,14 @@
                         <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>
+                            <li><a {{bindAttr href="url"}} target="_blank">{{label}}</a></li>
                           {{/each}}
                         </ul>
                       </li>
                     {{/each}}
                   {{else}}
                     {{#each view.quickLinks}}
-                      <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li>
+                      <li><a {{bindAttr href="url"}} target="_blank">{{label}}</a></li>
                     {{/each}}
                   {{/if}}
                 {{else}}

+ 2 - 2
ambari-web/app/templates/main/dashboard/widgets/yarn_links.hbs

@@ -61,14 +61,14 @@
                           <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>
+                              <li><a {{bindAttr href="url"}} target="_blank">{{label}}</a></li>
                             {{/each}}
                           </ul>
                         </li>
                       {{/each}}
                     {{else}}
                       {{#each view.quickLinks}}
-                        <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li>
+                        <li><a {{bindAttr href="url"}} target="_blank">{{label}}</a></li>
                       {{/each}}
                     {{/if}}
                   {{else}}

+ 41 - 0
ambari-web/app/templates/main/service/info/metrics/hive/hive_quick_links.hbs

@@ -0,0 +1,41 @@
+{{!
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+}}
+
+<div class="widget span2p4">
+  <div class="thumbnail quick-link-widget">
+
+  {{#if view.isLoaded}}
+    <div class="caption title span11"> {{view.title}}</div>
+
+    <div class="content">
+      <table>
+        <tr class="grafana-link">
+          <td>
+            <a href="#" {{action showDetails view.model.nameNode.host}}>{{t dashboard.service.hive.grafana}}</a>
+          </td>
+        </tr>
+        <tr class="hive-interactive-server-link">
+          <td>
+            <a href="#" {{action showDetails view.model.snameNode.host}}>{{t dashboard.service.hive.interactive.server}}</a>
+          </td>
+        </tr>
+      </table>
+    </div>
+  {{/if}}
+  </div>
+</div>

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

@@ -19,7 +19,7 @@
 {{view App.MainServiceInfoMenuView configTabBinding="view.hasConfigTab" heatmapTabBinding="view.hasHeatmapTab"}}
   <div class="span3 quick-links-wrapper">
     {{#view App.QuickViewLinks contentBinding="view.service"}}
-      {{#if view.hasQuickLinksConfiged}}
+      {{#if view.showQuickLinks}}
         <ul class="nav nav-pills move">
           <li class="dropdown quick-links-dropdown">
             <a class="dropdown-toggle" id="quick-links-dropdown-btn" data-toggle="dropdown" href="#">{{t common.quickLinks}}<b class="caret"></b></a>
@@ -32,7 +32,7 @@
                       <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>
+                          <li><a {{bindAttr href="url"}} target="_blank">{{label}}</a></li>
                         {{/each}}
                       </ul>
                     </li>
@@ -40,7 +40,7 @@
                 {{else}}
                   {{#if view.quickLinks}}
                     {{#each view.quickLinks}}
-                      <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li>
+                      <li><a {{bindAttr href="url"}} target="_blank">{{label}}</a></li>
                     {{/each}}
                   {{else}}
                     <div class="alert alert-danger"><small>{{t quick.links.error.quicklinks.unavailable.label}}</small></div>

+ 18 - 56
ambari-web/app/views/common/quick_view_link_view.js

@@ -23,30 +23,10 @@ App.QuickViewLinks = Em.View.extend({
 
   isLoaded: false,
 
-  hasQuickLinksConfiged: false,
+  showQuickLinks: false,
 
   quickLinksErrorMessage: '',
 
-  /**
-   * service which has blank target of link
-   * @type {Array}
-   */
-  servicesHasBlankTarget: [
-    'HDFS',
-    'YARN',
-    'MAPREDUCE2',
-    'HBASE',
-    'OOZIE',
-    'STORM',
-    'SPARK',
-    'FALCON',
-    'ACCUMULO',
-    'ATLAS',
-    'RANGER',
-    'AMBARI_METRICS',
-    'LOGSEARCH'
-  ],
-
   /**
    * Updated quick links. Here we put correct hostname to url
    * @type {Array}
@@ -61,17 +41,6 @@ App.QuickViewLinks = Em.View.extend({
    * list of files that contains properties for enabling/disabling ssl
    */
   requiredSiteNames: [],
-
-  /**
-   * @type {string}
-   */
-  linkTarget: function () {
-    if (this.get('servicesHasBlankTarget').contains(this.get('content.serviceName'))) {
-      return "_blank";
-    }
-    return "";
-  }.property('content.serviceName'),
-
   /**
    * @type {object}
    */
@@ -213,8 +182,17 @@ App.QuickViewLinks = Em.View.extend({
   setQuickLinksSuccessCallback: function (response) {
     var serviceName = this.get('content.serviceName');
     var hosts = this.getHosts(response, serviceName);
-    var hasQuickLinks = this.hasQuickLinksConfig(serviceName);
-    this.set('hasQuickLinksConfiged', hasQuickLinks); // no need to set quicklinks if current service does not have quick links configured...
+    var hasQuickLinks = this.hasQuickLinksConfig(serviceName, hosts);
+    var componentName = App.QuickLinksConfig.ServiceComponentMap[serviceName];
+    var masterComponent =  App.MasterComponent.find().findProperty('componentName', componentName);
+    var hasHosts = false;
+    if (masterComponent) {
+      hasHosts = !!masterComponent.get('totalCount');
+    }
+    // no need to set quicklinks if
+    // 1)current service does not have quick links configured
+    // 2)No host component present for the configured quicklink
+    this.set('showQuickLinks', hasQuickLinks && hasHosts);
 
     if (hosts.length === 0){
       this.setEmptyLinks();
@@ -253,9 +231,8 @@ App.QuickViewLinks = Em.View.extend({
   getQuickLinksConfiguration: function(){
     var serviceName =  this.get('content.serviceName');
     var self = this;
-    if(self.hasQuickLinksConfig(serviceName)){
-      var quickLinksConfiguration = App.QuickLinksConfig.find().findProperty("id", serviceName);
-      return quickLinksConfiguration;
+    if (self.hasQuickLinksConfig(serviceName)) {
+      return App.QuickLinksConfig.find().findProperty("id", serviceName);
     }
     return null;
   },
@@ -539,26 +516,11 @@ App.QuickViewLinks = Em.View.extend({
       case "YARN":
         hosts = this.processYarnHosts(this.findHosts('RESOURCEMANAGER', response));
         break;
-      case "STORM":
-        hosts = this.findHosts('STORM_UI_SERVER', response);
-        break;
-      case "ACCUMULO":
-        hosts = this.findHosts('ACCUMULO_MONITOR', response);
-        break;
-      case "ATLAS":
-        hosts = this.findHosts('ATLAS_SERVER', response);
-        break;
-      case "MAPREDUCE2":
-        hosts = this.findHosts('HISTORYSERVER', response);
-        break;
-      case "AMBARI_METRICS":
-        hosts = this.findHosts('METRICS_GRAFANA', response);
-        break;
-      case "LOGSEARCH":
-        hosts = this.findHosts('LOGSEARCH_SERVER', response);
-        break;
       default:
-        if (this.getWithDefault('content.hostComponents', []).someProperty('isMaster')) {
+        var componentName =  App.QuickLinksConfig.ServiceComponentMap[serviceName];
+        if (componentName) {
+          hosts = this.findHosts(componentName, response);
+        } else if (this.getWithDefault('content.hostComponents', []).someProperty('isMaster')) {
           hosts = this.findHosts(this.get('content.hostComponents').findProperty('isMaster').get('componentName'), response);
         }
         break;

+ 0 - 13
ambari-web/test/views/common/quick_link_view_test.js

@@ -26,19 +26,6 @@ describe('App.QuickViewLinks', function () {
     content: Em.Object.create()
   });
 
-  describe("#linkTarget", function () {
-    it("blank link", function () {
-      quickViewLinks.set('content.serviceName', 'HDFS');
-      quickViewLinks.propertyDidChange('linkTarget');
-      expect(quickViewLinks.get('linkTarget')).to.equal('_blank');
-    });
-    it("non-blank link", function () {
-      quickViewLinks.set('content.serviceName', 'S1');
-      quickViewLinks.propertyDidChange('linkTarget');
-      expect(quickViewLinks.get('linkTarget')).to.be.empty;
-    });
-  });
-
   describe("#ambariProperties", function () {
     beforeEach(function () {
       sinon.stub(App.router, 'get').returns({p: 1});