You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sw...@apache.org on 2018/04/12 22:45:01 UTC
[ambari] branch trunk updated: AMBARI-23529 : Utility function to
get namenode logical hostname and namespace for a given hostname. (#954)
This is an automated email from the ASF dual-hosted git repository.
swagle pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new 70c42f5 AMBARI-23529 : Utility function to get namenode logical hostname and namespace for a given hostname. (#954)
70c42f5 is described below
commit 70c42f560032bf9f7f03c3ee74194c4b1f99a5c5
Author: vishalsuvagia <vi...@users.noreply.github.com>
AuthorDate: Fri Apr 13 04:14:58 2018 +0530
AMBARI-23529 : Utility function to get namenode logical hostname and namespace for a given hostname. (#954)
---
.../libraries/functions/namenode_ha_utils.py | 28 ++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/namenode_ha_utils.py b/ambari-common/src/main/python/resource_management/libraries/functions/namenode_ha_utils.py
index 0d2cd3f..c68d713 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/namenode_ha_utils.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/namenode_ha_utils.py
@@ -383,3 +383,31 @@ def get_name_service_by_hostname(hdfs_site, host_name):
nn_rpc = nn_rpc_port.split(':')[0]
if nn_rpc == host_name:
return ns
+
+def get_namespace_mapping_for_hostname(hostname, hdfs_site, security_enabled, run_user):
+ namenode_address_map_list = get_namenode_states(hdfs_site, security_enabled, run_user)
+ namenode_logical_name = None
+ for each_namenode_address_map in namenode_address_map_list:
+ if len(each_namenode_address_map) != 0:
+ for namenode_hostname_logical_map_tuple in each_namenode_address_map:
+ namenode_hostname = namenode_hostname_logical_map_tuple[1].split(":")[0]
+ if hostname == namenode_hostname:
+ namenode_logical_name = namenode_hostname_logical_map_tuple[0]
+ break
+ if namenode_logical_name is not None:
+ break
+
+
+ namenode_nameservices = get_nameservices(hdfs_site)
+ namespace_nameservice = None
+ if namenode_nameservices and len(namenode_nameservices) > 0:
+ for name_service in namenode_nameservices:
+ namenode_logical_names_list = hdfs_site.get('dfs.ha.namenodes.' + str(name_service), None)
+ if namenode_logical_names_list and ',' in namenode_logical_names_list:
+ for each_namenode_logical_name in namenode_logical_names_list.split(','):
+ if namenode_logical_name == each_namenode_logical_name:
+ namespace_nameservice = name_service
+ break
+ if namespace_nameservice is not None:
+ break
+ return namespace_nameservice,namenode_logical_name
--
To stop receiving notification emails like this one, please contact
swagle@apache.org.