Browse Source

AMBARI-15189: Set dfs.allow.truncate = True on HDFS during HAWQ install or add service (lavjain via jaoki)

Jun Aoki 9 years ago
parent
commit
a323c387f3

+ 5 - 0
ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py

@@ -363,6 +363,11 @@ class HDP23StackAdvisor(HDP22StackAdvisor):
     putHdfsSiteProperty = self.putProperty(configurations, "hdfs-site", services)
     putHdfsSiteProperty = self.putProperty(configurations, "hdfs-site", services)
     putHdfsSitePropertyAttribute = self.putPropertyAttribute(configurations, "hdfs-site")
     putHdfsSitePropertyAttribute = self.putPropertyAttribute(configurations, "hdfs-site")
 
 
+    servicesList = [service["StackServices"]["service_name"] for service in services["services"]]
+    if "HAWQ" in servicesList:
+      # Set dfs.allow.truncate to true
+      putHdfsSiteProperty('dfs.allow.truncate', 'true')
+
     if ('ranger-hdfs-plugin-properties' in services['configurations']) and ('ranger-hdfs-plugin-enabled' in services['configurations']['ranger-hdfs-plugin-properties']['properties']):
     if ('ranger-hdfs-plugin-properties' in services['configurations']) and ('ranger-hdfs-plugin-enabled' in services['configurations']['ranger-hdfs-plugin-properties']['properties']):
       rangerPluginEnabled = ''
       rangerPluginEnabled = ''
       if 'ranger-hdfs-plugin-properties' in configurations and 'ranger-hdfs-plugin-enabled' in  configurations['ranger-hdfs-plugin-properties']['properties']:
       if 'ranger-hdfs-plugin-properties' in configurations and 'ranger-hdfs-plugin-enabled' in  configurations['ranger-hdfs-plugin-properties']['properties']:

+ 20 - 0
ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py

@@ -595,6 +595,26 @@ class TestHDP23StackAdvisor(TestCase):
     self.stackAdvisor.recommendHDFSConfigurations(configurations, clusterData, services, hosts)
     self.stackAdvisor.recommendHDFSConfigurations(configurations, clusterData, services, hosts)
     self.assertEquals(configurations['hdfs-site']['properties']['dfs.namenode.inode.attributes.provider.class'], 'org.apache.ranger.authorization.hadoop.RangerHdfsAuthorizer', "Test with Ranger HDFS plugin is enabled")
     self.assertEquals(configurations['hdfs-site']['properties']['dfs.namenode.inode.attributes.provider.class'], 'org.apache.ranger.authorization.hadoop.RangerHdfsAuthorizer', "Test with Ranger HDFS plugin is enabled")
 
 
+    # Test 1 for dfs.allow.truncate with no HAWQ and dfs.allow.truncate not set
+    self.stackAdvisor.recommendHDFSConfigurations(configurations, clusterData, services, hosts)
+    self.assertTrue('dfs.allow.truncate' not in configurations['hdfs-site']['properties'])
+
+    # Test 2 for dfs.allow.truncate with HAWQ and dfs.allow.truncate not set
+    services["services"].append({"StackServices" : {"service_name" : "HAWQ"}, "components":[]})
+    self.stackAdvisor.recommendHDFSConfigurations(configurations, clusterData, services, hosts)
+    self.assertEquals(configurations['hdfs-site']['properties']['dfs.allow.truncate'], 'true')
+
+    # Test 3 for dfs.allow.truncate with no HAWQ and dfs.allow.truncate set to false
+    services["services"].remove({"StackServices" : {"service_name" : "HAWQ"}, "components":[]})
+    configurations['hdfs-site']['properties']['dfs.allow.truncate'] = 'false'
+    self.stackAdvisor.recommendHDFSConfigurations(configurations, clusterData, services, hosts)
+    self.assertEquals(configurations['hdfs-site']['properties']['dfs.allow.truncate'], 'false')
+
+    # Test 4 for dfs.allow.truncate with HAWQ and dfs.allow.truncate set to false
+    services["services"].append({"StackServices" : {"service_name" : "HAWQ"}, "components":[]})
+    self.stackAdvisor.recommendHDFSConfigurations(configurations, clusterData, services, hosts)
+    self.assertEquals(configurations['hdfs-site']['properties']['dfs.allow.truncate'], 'true')
+
   def test_recommendYARNConfigurations(self):
   def test_recommendYARNConfigurations(self):
     configurations = {}
     configurations = {}
     servicesList = ["YARN"]
     servicesList = ["YARN"]