Repository: ambari Updated Branches: refs/heads/branch-2.4 a83311897 -> 0a78ef4ad
AMBARI-13820 Incorrect ports in WebHDFS HA config in Knox (Sumit Gupta via dsen) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0a78ef4a Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0a78ef4a Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0a78ef4a Branch: refs/heads/branch-2.4 Commit: 0a78ef4ad8d1790f1328121837636440a92b9965 Parents: a833118 Author: Dmytro Sen <[email protected]> Authored: Thu Jun 2 22:27:35 2016 +0300 Committer: Dmytro Sen <[email protected]> Committed: Thu Jun 2 22:29:42 2016 +0300 ---------------------------------------------------------------------- .../KNOX/0.5.0.2.2/package/scripts/params_linux.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/0a78ef4a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_linux.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_linux.py b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_linux.py index 5d454de..4d30f55 100644 --- a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_linux.py +++ b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_linux.py @@ -124,6 +124,13 @@ if dfs_ha_enabled: # With HA enabled namenode_address is recomputed namenode_address = format('hdfs://{dfs_ha_nameservices}') +namenode_port_map = {} +if dfs_ha_enabled: + for nn_id in dfs_ha_namemodes_ids_list: + nn_host = config['configurations']['hdfs-site'][format('dfs.namenode.http-address.{dfs_ha_nameservices}.{nn_id}')] + nn_host_parts = nn_host.split(':') + namenode_port_map[nn_host_parts[0]] = nn_host_parts[1] + namenode_hosts = default("/clusterHostInfo/namenode_host", None) if type(namenode_hosts) is list: @@ -146,7 +153,6 @@ if has_namenode: webhdfs_service_urls = "" - def buildUrlElement(protocol, hdfs_host, port, servicePath) : openTag = "<url>" closeTag = "</url>" @@ -157,11 +163,12 @@ def buildUrlElement(protocol, hdfs_host, port, servicePath) : else: return openTag + proto + hdfs_host + ":" + port + servicePath + closeTag + newLine -if type(namenode_hosts) is list: - for host in namenode_hosts: - webhdfs_service_urls += buildUrlElement("http", host, namenode_http_port, "/webhdfs") +namenode_host_keys = namenode_port_map.keys(); +if len(namenode_host_keys) > 0: + for host in namenode_host_keys: + webhdfs_service_urls += buildUrlElement("http", host, namenode_port_map[host], "/webhdfs") else: - webhdfs_service_urls = buildUrlElement("http", namenode_hosts, namenode_http_port, "/webhdfs") + webhdfs_service_urls = buildUrlElement("http", namenode_host, namenode_http_port, "/webhdfs") rm_hosts = default("/clusterHostInfo/rm_host", None)
