瀏覽代碼

AMBARI-3446 When SSL is enabled on Hadoop JMX endpoints ResourceManager quick links become unavailable. (ababiichuk)

aBabiichuk 11 年之前
父節點
當前提交
62dfae5f4c

+ 1 - 0
ambari-web/app/assets/test/tests.js

@@ -70,6 +70,7 @@ require('test/utils/config_test');
 require('test/utils/string_utils_test');
 require('test/views/common/chart/linear_time_test');
 require('test/views/common/filter_view_test');
+require('test/views/common/quick_link_view_test');
 require('test/views/main/dashboard_test');
 require('test/views/main/dashboard/widget_test');
 require('test/views/main/dashboard/widgets/text_widget_test');

+ 8 - 8
ambari-web/app/models/quick_links.js

@@ -184,30 +184,30 @@ App.QuickLinks.FIXTURES = [
   {
     id:23,
     label:'ResourceManager UI',
-    url:'%@://%@:8088',
+    url:'%@://%@:%@',
     service_id: 'YARN',
-    template:'%@://%@:8088'
+    template:'%@://%@:%@'
   },
   {
     id:24,
     label:'ResourceManager logs',
-    url:'%@://%@:8088/logs',
+    url:'%@://%@:%@/logs',
     service_id: 'YARN',
-    template:'%@://%@:8088/logs'
+    template:'%@://%@:%@/logs'
   },
   {
     id:25,
     label:'ResourceManager JMX',
-    url:'%@://%@:8088/jmx',
+    url:'%@://%@:%@/jmx',
     service_id: 'YARN',
-    template:'%@://%@:8088/jmx'
+    template:'%@://%@:%@/jmx'
   },
   {
     id:26,
     label:'Thread Stacks',
-    url:'%@://%@:8088/stacks',
+    url:'%@://%@:%@/stacks',
     service_id: 'YARN',
-    template:'%@://%@:8088/stacks'
+    template:'%@://%@:%@/stacks'
   },
   {
     id:27,

+ 16 - 1
ambari-web/app/views/common/quick_view_link_view.js

@@ -17,6 +17,7 @@
  */
 
 var App = require('app');
+var stringUtils = require('utils/string_utils');
 
 App.QuickViewLinks = Em.View.extend({
 
@@ -96,6 +97,7 @@ App.QuickViewLinks = Em.View.extend({
     var components = this.get('content.hostComponents');
     var host;
     var self = this;
+    var version = App.get('currentStackVersionNumber');
 
     switch (serviceName) {
       case "HDFS":
@@ -155,7 +157,12 @@ App.QuickViewLinks = Em.View.extend({
         item.set('disabled', false);
         var protocol = self.setProtocol(item.get('service_id'));
         if (item.get('template')) {
-          item.set('url', item.get('template').fmt(protocol,host));
+          if(item.get('service_id') === 'YARN'){
+            var port = self.setPort(item.get('service_id'),protocol, version);
+            item.set('url', item.get('template').fmt(protocol,host,port));
+          } else {
+            item.set('url', item.get('template').fmt(protocol,host));
+          }
         }
       }
       return item;
@@ -190,6 +197,14 @@ App.QuickViewLinks = Em.View.extend({
     }
   },
 
+  setPort: function(service_id, protocol, version) {
+    var port = '';
+    if (service_id === 'YARN') {
+      port = (protocol === 'https' && stringUtils.compareVersions(version,'2.0.5') === 1) ? '8090' : '8088'
+    }
+    return port;
+  },
+
   linkTarget: function () {
     switch (this.get('content.serviceName').toLowerCase()) {
       case "hdfs":

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

@@ -0,0 +1,60 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+require('views/common/quick_view_link_view');
+
+describe('App.QuickViewLinks', function () {
+
+  var quickViewLinks = App.QuickViewLinks.create({});
+
+  describe('#setPort', function () {
+    var testData = [
+      {
+        'service_id': 'HDFS',
+        'protocol': 'https',
+        'version': '2.0.6',
+        'result': ''
+      },
+      {
+        'service_id': 'YARN',
+        'protocol': 'http',
+        'version': '2.0.6',
+        'result': '8088'
+      },
+      {
+        'service_id': 'YARN',
+        'protocol': 'https',
+        'version': '2.0.5',
+        'result': '8088'
+      },
+      {
+        'service_id': 'YARN',
+        'protocol': 'https',
+        'version': '2.0.6',
+        'result': '8090'
+      },
+    ];
+
+    testData.forEach(function(item) {
+      it('should return empty string if service_id is not YARN, 8090 if protocol is https and stack version higher than 2.0.5, http otherwise', function () {
+        expect(quickViewLinks.setPort(item.service_id, item.protocol, item.version)).to.equal(item.result);
+      })
+    },this);
+  });
+});