You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2015/09/08 19:25:52 UTC
ambari git commit: AMBARI-13022. Ambari NameNode UI Quick Links
resolve to wrong port when NN HA is enabled (alexantonenko via yusaku)
Repository: ambari
Updated Branches:
refs/heads/branch-2.1.1 ab13984be -> 50b2ca590
AMBARI-13022. Ambari NameNode UI Quick Links resolve to wrong port when NN HA is enabled (alexantonenko via yusaku)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/50b2ca59
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/50b2ca59
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/50b2ca59
Branch: refs/heads/branch-2.1.1
Commit: 50b2ca590aa52977ecca87d689cf3aef919eda1f
Parents: ab13984
Author: Yusaku Sako <yu...@hortonworks.com>
Authored: Tue Sep 8 10:25:37 2015 -0700
Committer: Yusaku Sako <yu...@hortonworks.com>
Committed: Tue Sep 8 10:25:37 2015 -0700
----------------------------------------------------------------------
.../app/views/common/quick_view_link_view.js | 37 ++++++++++++++++----
.../test/views/common/quick_link_view_test.js | 25 ++++++++++++-
2 files changed, 55 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/50b2ca59/ambari-web/app/views/common/quick_view_link_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/quick_view_link_view.js b/ambari-web/app/views/common/quick_view_link_view.js
index 32def18..18be703 100644
--- a/ambari-web/app/views/common/quick_view_link_view.js
+++ b/ambari-web/app/views/common/quick_view_link_view.js
@@ -162,7 +162,31 @@ App.QuickViewLinks = Em.View.extend({
var newItem = {};
var protocol = self.setProtocol(item.get('service_id'), self.get('configProperties'), self.ambariProperties());
if (item.get('template')) {
- var port = item.get('http_config') && self.setPort(item, protocol);
+ var port;
+ var hostNameRegExp = new RegExp('([\\w\\W]*):\\d+');
+ if (item.get('service_id') === 'HDFS') {
+ var config;
+ var configPropertiesObject = self.get('configProperties').findProperty('type', item.get('site'));
+ if (configPropertiesObject && configPropertiesObject.properties) {
+ var properties = configPropertiesObject.properties;
+ var nameServiceId = properties['dfs.nameservices'];
+ var nnProperties = ['dfs.namenode.{0}-address.{1}.nn1', 'dfs.namenode.{0}-address.{1}.nn2'].map(function (c) {
+ return c.format(protocol, nameServiceId);
+ });
+ var nnPropertiesLength = nnProperties.length;
+ for (var i = nnPropertiesLength; i--;) {
+ var propertyName = nnProperties[i];
+ var hostNameMatch = properties[propertyName] && properties[propertyName].match(hostNameRegExp);
+ if (hostNameMatch && hostNameMatch[1] === host.publicHostName) {
+ config = propertyName;
+ break;
+ }
+ }
+ }
+ port = self.setPort(item, protocol, config);
+ } else {
+ port = item.get('http_config') && self.setPort(item, protocol);
+ }
if (item.get('service_id')==='OOZIE') {
newItem.url = item.get('template').fmt(protocol, host.publicHostName, port, App.router.get('loginName'));
} else {
@@ -407,15 +431,16 @@ App.QuickViewLinks = Em.View.extend({
* sets the port of quick link
* @param item
* @param protocol
+ * @param config
* @returns {*}
* @method setPort
*/
- setPort: function (item, protocol) {
+ setPort: function (item, protocol, config) {
var configProperties = this.get('configProperties');
- var config = item.get('http_config');
+ var config = config || item.get('http_config');
var defaultPort = item.get('default_http_port');
- if (protocol === 'https' && item.get('https_config')) {
- config = item.get('https_config');
+ if (protocol === 'https' && (config || item.get('https_config'))) {
+ config = config || item.get('https_config');
if (item.get('default_https_port')) {
defaultPort = item.get('default_https_port');
}
@@ -440,7 +465,7 @@ App.QuickViewLinks = Em.View.extend({
var re = new RegExp(item.get('regex'));
var portValue = propertyValue.match(re);
- return portValue[1];
+ return portValue[1];
},
linkTarget: function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/50b2ca59/ambari-web/test/views/common/quick_link_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/quick_link_view_test.js b/ambari-web/test/views/common/quick_link_view_test.js
index 13dce99..92075e7 100644
--- a/ambari-web/test/views/common/quick_link_view_test.js
+++ b/ambari-web/test/views/common/quick_link_view_test.js
@@ -100,6 +100,24 @@ describe('App.QuickViewLinks', function () {
'regex': '\\w*:(\\d+)'
}),
Em.Object.create({
+ 'service_id': 'YARN',
+ 'protocol': 'https',
+ 'https_config': 'https_config',
+ 'config': 'https_config_custom',
+ 'site': 'yarn-site',
+ 'result': '9091',
+ 'default_http_port': '8088',
+ 'default_https_port': '8090',
+ 'regex': '\\w*:(\\d+)',
+ 'configProperties': [{
+ 'type': 'yarn-site',
+ 'properties': {
+ 'https_config': 'h:9090',
+ 'https_config_custom': 'h:9091'
+ }
+ }]
+ }),
+ Em.Object.create({
'service_id': 'RANGER',
'protocol': 'http',
'http_config': 'http_config',
@@ -121,9 +139,14 @@ describe('App.QuickViewLinks', function () {
})
];
+ after(function () {
+ quickViewLinks.set('configProperties', []);
+ });
+
testData.forEach(function(item) {
it(item.service_id + ' ' + item.protocol, function () {
- expect(quickViewLinks.setPort(item, item.protocol, item.version)).to.equal(item.result);
+ quickViewLinks.set('configProperties', item.configProperties || []);
+ expect(quickViewLinks.setPort(item, item.protocol, item.config)).to.equal(item.result);
})
},this);
});