Repository: ambari
Updated Branches:
  refs/heads/trunk 26609656f -> c583afb58


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/c583afb5
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c583afb5
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c583afb5

Branch: refs/heads/trunk
Commit: c583afb58b8ed97b95741cf5398e5da7d3950f7e
Parents: 2660965
Author: Dmytro Sen <[email protected]>
Authored: Thu Jun 2 22:27:35 2016 +0300
Committer: Dmytro Sen <[email protected]>
Committed: Thu Jun 2 22:27:35 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/c583afb5/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 cba388b..6f138c0 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
@@ -123,6 +123,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:
@@ -145,7 +152,6 @@ if has_namenode:
 
 webhdfs_service_urls = ""
 
-
 def buildUrlElement(protocol, hdfs_host, port, servicePath) :
   openTag = "<url>"
   closeTag = "</url>"
@@ -156,11 +162,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)

Reply via email to