AMBARI-14620. HAWQ master components start should show ERROR or WARNING if 
dfs.allow.truncate is set to false(mithmatt via odiachenko).


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 019d6f4ccaa3f0fc94bfb7299fa1f98f46a5dade
Parents: a7af252
Author: Oleksandr Diachenko <[email protected]>
Authored: Tue Jan 12 14:38:51 2016 -0800
Committer: Nate Cole <[email protected]>
Committed: Thu Jan 14 11:43:26 2016 -0500

----------------------------------------------------------------------
 .../HAWQ/2.0.0/package/scripts/custom_params.py | 21 ++++++++++++++++
 .../HAWQ/2.0.0/package/scripts/master_helper.py | 26 ++++++++++++++++++++
 2 files changed, 47 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/019d6f4c/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/custom_params.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/custom_params.py
 
b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/custom_params.py
new file mode 100644
index 0000000..4a1cf82
--- /dev/null
+++ 
b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/custom_params.py
@@ -0,0 +1,21 @@
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+# dfs.allow.truncate in hdfs-site.xml being true is important for hawq's 
performance but still operational with a degraded performance.
+# This flag is to decide whether starting hawq completely fails or still 
starts with the performance limitation when the truncate property is set to 
false.
+enforce_hdfs_truncate = True

http://git-wip-us.apache.org/repos/asf/ambari/blob/019d6f4c/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/master_helper.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/master_helper.py
 
b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/master_helper.py
index 95c4eba..d30715e 100644
--- 
a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/master_helper.py
+++ 
b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/master_helper.py
@@ -16,11 +16,13 @@ See the License for the specific language governing 
permissions and
 limitations under the License.
 """
 import os
+import sys
 from resource_management.core.resources.system import File, Execute
 from resource_management.core.source import Template
 from resource_management.core.exceptions import Fail
 from resource_management.core.logger import Logger
 from resource_management.libraries.functions.format import format
+from resource_management.libraries.functions.default import default
 
 import utils
 import common
@@ -177,6 +179,28 @@ def __is_standby_host():
   return params.hostname == 
common.get_local_hawq_site_property("hawq_standby_address_host")
 
 
+def __check_dfs_truncate_enforced():
+  """
+  If enforce_hdfs_truncate is set to True:
+    throw an ERROR, HAWQMASTER or HAWQSTANDBY start should fail
+  Else:
+    throw a WARNING,
+  """
+  import custom_params
+
+  DFS_ALLOW_TRUNCATE_EXCEPTION_MESSAGE = "dfs.allow.truncate property in 
hdfs-site.xml configuration file should be set to True. Please review HAWQ 
installation guide for more information."
+
+  # Check if dfs.allow.truncate exists in hdfs-site.xml and throw appropriate 
exception if not set to True
+  dfs_allow_truncate = default('/configurations/hdfs-site/dfs.allow.truncate', 
None)
+
+  if dfs_allow_truncate is None or str(dfs_allow_truncate).lower() != 'true':
+    if custom_params.enforce_hdfs_truncate:
+      Logger.error("**ERROR**: 
{0}".format(DFS_ALLOW_TRUNCATE_EXCEPTION_MESSAGE))
+      sys.exit(1)
+    else:
+      Logger.warning("**WARNING**: 
{0}".format(DFS_ALLOW_TRUNCATE_EXCEPTION_MESSAGE))
+
+
 def start_master():
   """
   Initializes HAWQ Master/Standby if not already done and starts them
@@ -186,6 +210,8 @@ def start_master():
   if not params.hostname in [params.hawqmaster_host, params.hawqstandby_host]:
     Fail("Host should be either active Hawq master or Hawq standby.")
 
+  __check_dfs_truncate_enforced()
+
   is_active_master = __is_active_master()
   # Exchange ssh keys from active hawq master before starting.
   if is_active_master:

Reply via email to