AMBARI-20427. Ambari should allow empty string for hive.metastore.uris when 
running in embedded mode  (alejandro)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/19e7c65b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/19e7c65b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/19e7c65b

Branch: refs/heads/branch-feature-AMBARI-12556
Commit: 19e7c65ba2dcf09010aeeb3e3c39c78b410c7a84
Parents: 8b2565a
Author: Alejandro Fernandez <[email protected]>
Authored: Wed Mar 8 18:38:55 2017 -0800
Committer: Alejandro Fernandez <[email protected]>
Committed: Wed Mar 15 10:43:54 2017 -0700

----------------------------------------------------------------------
 .../test/python/resource_management/TestLibraryFunctions.py    | 2 ++
 .../libraries/functions/get_port_from_url.py                   | 6 +++---
 .../HIVE/0.12.0.2.0/configuration/hive-site.xml                | 4 ++++
 .../common-services/SPARK2/2.0.0/package/scripts/params.py     | 2 +-
 .../ZEPPELIN/0.6.0.2.5/package/scripts/params.py               | 4 ++--
 .../stacks/HDP/2.2/services/HIVE/configuration/hive-site.xml   | 4 ++++
 6 files changed, 16 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/19e7c65b/ambari-agent/src/test/python/resource_management/TestLibraryFunctions.py
----------------------------------------------------------------------
diff --git 
a/ambari-agent/src/test/python/resource_management/TestLibraryFunctions.py 
b/ambari-agent/src/test/python/resource_management/TestLibraryFunctions.py
index 4e6b6c3..48e0aa0 100644
--- a/ambari-agent/src/test/python/resource_management/TestLibraryFunctions.py
+++ b/ambari-agent/src/test/python/resource_management/TestLibraryFunctions.py
@@ -22,6 +22,8 @@ from resource_management.core.exceptions import Fail
 class TestLibraryFunctions(TestCase):
 
   def test_get_port_from_url(self):
+    self.assertEqual("", get_port_from_url(None))
+    self.assertEqual("", get_port_from_url(""))
     self.assertEqual("8080",get_port_from_url("protocol://host:8080"))
     self.assertEqual("8080",get_port_from_url("protocol://host:8080/"))
     self.assertEqual("8080",get_port_from_url("host:8080"))

http://git-wip-us.apache.org/repos/asf/ambari/blob/19e7c65b/ambari-common/src/main/python/resource_management/libraries/functions/get_port_from_url.py
----------------------------------------------------------------------
diff --git 
a/ambari-common/src/main/python/resource_management/libraries/functions/get_port_from_url.py
 
b/ambari-common/src/main/python/resource_management/libraries/functions/get_port_from_url.py
index ed4586c..7ff2a14 100644
--- 
a/ambari-common/src/main/python/resource_management/libraries/functions/get_port_from_url.py
+++ 
b/ambari-common/src/main/python/resource_management/libraries/functions/get_port_from_url.py
@@ -30,9 +30,9 @@ def get_port_from_url(address):
   If address is UnknownConfiguration, UnknownConfiguration will be returned. 
   If no port was found, Fail will be raised.
   """
-  if is_empty(address):
-    return address
-  
+  if address is None or address.strip() == "":
+    return ""
+  address = address.strip()
   if isinstance(address, (int, long)):
     return address  
   

http://git-wip-us.apache.org/repos/asf/ambari/blob/19e7c65b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/configuration/hive-site.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/configuration/hive-site.xml
 
b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/configuration/hive-site.xml
index 3d08867..e48d069 100644
--- 
a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/configuration/hive-site.xml
+++ 
b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/configuration/hive-site.xml
@@ -124,6 +124,10 @@ limitations under the License.
     <name>hive.metastore.uris</name>
     <value>thrift://localhost:9083</value>
     <description>URI for client to contact metastore server</description>
+    <!-- Allow empty value for embedded mode. -->
+    <value-attributes>
+      <empty-value-valid>true</empty-value-valid>
+    </value-attributes>
     <on-ambari-upgrade add="false"/>
   </property>
   <property>

http://git-wip-us.apache.org/repos/asf/ambari/blob/19e7c65b/ambari-server/src/main/resources/common-services/SPARK2/2.0.0/package/scripts/params.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/common-services/SPARK2/2.0.0/package/scripts/params.py
 
b/ambari-server/src/main/resources/common-services/SPARK2/2.0.0/package/scripts/params.py
index 45a8c07..4ed0718 100755
--- 
a/ambari-server/src/main/resources/common-services/SPARK2/2.0.0/package/scripts/params.py
+++ 
b/ambari-server/src/main/resources/common-services/SPARK2/2.0.0/package/scripts/params.py
@@ -139,7 +139,7 @@ has_spark_thriftserver = not len(spark_thriftserver_hosts) 
== 0
 
 # hive-site params
 spark_hive_properties = {
-  'hive.metastore.uris': 
config['configurations']['hive-site']['hive.metastore.uris']
+  'hive.metastore.uris': 
default('/configurations/hive-site/hive.metastore.uris', '')
 }
 
 # security settings

http://git-wip-us.apache.org/repos/asf/ambari/blob/19e7c65b/ambari-server/src/main/resources/common-services/ZEPPELIN/0.6.0.2.5/package/scripts/params.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/common-services/ZEPPELIN/0.6.0.2.5/package/scripts/params.py
 
b/ambari-server/src/main/resources/common-services/ZEPPELIN/0.6.0.2.5/package/scripts/params.py
index fdc96db..8f06a17 100644
--- 
a/ambari-server/src/main/resources/common-services/ZEPPELIN/0.6.0.2.5/package/scripts/params.py
+++ 
b/ambari-server/src/main/resources/common-services/ZEPPELIN/0.6.0.2.5/package/scripts/params.py
@@ -129,12 +129,12 @@ hive_interactive_zookeeper_namespace = None
 if 'hive_server_host' in master_configs and 
len(master_configs['hive_server_host']) != 0:
   is_hive_installed = True
   spark_hive_properties = {
-    'hive.metastore.uris': 
config['configurations']['hive-site']['hive.metastore.uris']
+    'hive.metastore.uris': 
default('/configurations/hive-site/hive.metastore.uris', '')
   }
   hive_server_host = str(master_configs['hive_server_host'][0])
   hive_metastore_host = str(master_configs['hive_metastore_host'][0])
   hive_metastore_port = str(
-    
get_port_from_url(config['configurations']['hive-site']['hive.metastore.uris']))
+    get_port_from_url(default('/configurations/hive-site/hive.metastore.uris', 
'')))
   hive_server_port = 
str(config['configurations']['hive-site']['hive.server2.thrift.http.port'])
   hive_zookeeper_quorum = 
config['configurations']['hive-site']['hive.zookeeper.quorum']
   hive_zookeeper_namespace = 
config['configurations']['hive-site']['hive.server2.zookeeper.namespace']

http://git-wip-us.apache.org/repos/asf/ambari/blob/19e7c65b/ambari-server/src/main/resources/stacks/HDP/2.2/services/HIVE/configuration/hive-site.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.2/services/HIVE/configuration/hive-site.xml
 
b/ambari-server/src/main/resources/stacks/HDP/2.2/services/HIVE/configuration/hive-site.xml
index 856941f..39ba887 100644
--- 
a/ambari-server/src/main/resources/stacks/HDP/2.2/services/HIVE/configuration/hive-site.xml
+++ 
b/ambari-server/src/main/resources/stacks/HDP/2.2/services/HIVE/configuration/hive-site.xml
@@ -349,6 +349,10 @@ limitations under the License.
     <name>hive.metastore.uris</name>
     <value>thrift://localhost:9083</value>
     <description>Thrift URI for the remote metastore. Used by metastore client 
to connect to remote metastore.</description>
+    <!-- Allow empty value for embedded mode. -->
+    <value-attributes>
+      <empty-value-valid>true</empty-value-valid>
+    </value-attributes>
     <on-ambari-upgrade add="false"/>
   </property>
   <property require-input="true">

Reply via email to