You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2015/09/07 13:07:46 UTC
ambari git commit: AMBARI-13022. Ambari NameNode UI Quick Links
resolve to wrong port when NN HA is enabled (alexantonenko)
Repository: ambari
Updated Branches:
refs/heads/branch-2.1 07f9f7125 -> a21d2bc21
AMBARI-13022. Ambari NameNode UI Quick Links resolve to wrong port when NN HA is enabled (alexantonenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/a21d2bc2
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a21d2bc2
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a21d2bc2
Branch: refs/heads/branch-2.1
Commit: a21d2bc211d2262d1aaadb7a05b8342021e001c1
Parents: 07f9f71
Author: Alex Antonenko <hi...@gmail.com>
Authored: Mon Sep 7 13:39:20 2015 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Mon Sep 7 14:07:42 2015 +0300
----------------------------------------------------------------------
.../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/a21d2bc2/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 522837e..500d6ec 100644
--- a/ambari-web/app/views/common/quick_view_link_view.js
+++ b/ambari-web/app/views/common/quick_view_link_view.js
@@ -164,7 +164,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 {
@@ -425,15 +449,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');
}
@@ -459,7 +484,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/a21d2bc2/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);
});