Explorar o código

AMBARI-14467 Handle schemaless value for ams-hbase-site/hbase.rootdir (dsen)

Dmytro Sen %!s(int64=9) %!d(string=hai) anos
pai
achega
6f8b840aa7

+ 6 - 0
ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/configuration/ams-hbase-site.xml

@@ -29,6 +29,12 @@
       HBase to either local filesystem path if using Ambari Metrics in embedded mode or
       HBase to either local filesystem path if using Ambari Metrics in embedded mode or
       to a HDFS dir, example: hdfs://namenode.example.org:8020/amshbase.
       to a HDFS dir, example: hdfs://namenode.example.org:8020/amshbase.
     </description>
     </description>
+    <depends-on>
+      <property>
+        <type>core-site</type>
+        <name>fs.defaultFS</name>
+      </property>
+    </depends-on>
   </property>
   </property>
   <property>
   <property>
     <name>hbase.tmp.dir</name>
     <name>hbase.tmp.dir</name>

+ 15 - 5
ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py

@@ -459,6 +459,11 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
 
 
     amsCollectorHosts = self.getComponentHostNames(services, "AMBARI_METRICS", "METRICS_COLLECTOR")
     amsCollectorHosts = self.getComponentHostNames(services, "AMBARI_METRICS", "METRICS_COLLECTOR")
 
 
+    defaultFs = 'file:///'
+    if "core-site" in services["configurations"] and \
+      "fs.defaultFS" in services["configurations"]["core-site"]["properties"]:
+      defaultFs = services["configurations"]["core-site"]["properties"]["fs.defaultFS"]
+
     rootDir = "file:///var/lib/ambari-metrics-collector/hbase"
     rootDir = "file:///var/lib/ambari-metrics-collector/hbase"
     tmpDir = "/var/lib/ambari-metrics-collector/hbase-tmp"
     tmpDir = "/var/lib/ambari-metrics-collector/hbase-tmp"
     hbaseClusterDistributed = False
     hbaseClusterDistributed = False
@@ -482,7 +487,7 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
         if host["Hosts"]["host_name"] == collectorHostName:
         if host["Hosts"]["host_name"] == collectorHostName:
           mountpoints = self.getPreferredMountPoints(host["Hosts"])
           mountpoints = self.getPreferredMountPoints(host["Hosts"])
           break
           break
-    isLocalRootDir = rootDir.startswith("file://")
+    isLocalRootDir = rootDir.startswith("file://") or (defaultFs.startswith("file://") and rootDir.startswith("/"))
     if isLocalRootDir:
     if isLocalRootDir:
       rootDir = re.sub("^file:///|/", "", rootDir, count=1)
       rootDir = re.sub("^file:///|/", "", rootDir, count=1)
       rootDir = "file://" + os.path.join(mountpoints[0], rootDir)
       rootDir = "file://" + os.path.join(mountpoints[0], rootDir)
@@ -542,7 +547,7 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
       putHbaseEnvProperty("hbase_master_xmn_size", round_to_n(0.15*(hbase_heapsize+hbase_rs_heapsize),64))
       putHbaseEnvProperty("hbase_master_xmn_size", round_to_n(0.15*(hbase_heapsize+hbase_rs_heapsize),64))
 
 
     # If no local DN in distributed mode
     # If no local DN in distributed mode
-    if rootDir.startswith("hdfs://"):
+    if rootDir.startswith("hdfs://") or (defaultFs.startswith("hdfs://") and rootDir.startswith("/")):
       dn_hosts = self.getComponentHostNames(services, "HDFS", "DATANODE")
       dn_hosts = self.getComponentHostNames(services, "HDFS", "DATANODE")
       if set(amsCollectorHosts).intersection(dn_hosts):
       if set(amsCollectorHosts).intersection(dn_hosts):
         collector_cohosted_with_dn = "true"
         collector_cohosted_with_dn = "true"
@@ -837,6 +842,7 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
 
 
     amsCollectorHosts = self.getComponentHostNames(services, "AMBARI_METRICS", "METRICS_COLLECTOR")
     amsCollectorHosts = self.getComponentHostNames(services, "AMBARI_METRICS", "METRICS_COLLECTOR")
     ams_site = getSiteProperties(configurations, "ams-site")
     ams_site = getSiteProperties(configurations, "ams-site")
+    core_site = getSiteProperties(configurations, "core-site")
 
 
     collector_heapsize, hbase_heapsize, total_sinks_count = self.getAmsMemoryRecommendation(services, hosts)
     collector_heapsize, hbase_heapsize, total_sinks_count = self.getAmsMemoryRecommendation(services, hosts)
     recommendedDiskSpace = 10485760
     recommendedDiskSpace = 10485760
@@ -855,10 +861,14 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
 
 
     rootdir_item = None
     rootdir_item = None
     op_mode = ams_site.get("timeline.metrics.service.operation.mode")
     op_mode = ams_site.get("timeline.metrics.service.operation.mode")
+    default_fs = core_site.get("fs.defaultFS") if core_site else "file:///"
     hbase_rootdir = properties.get("hbase.rootdir")
     hbase_rootdir = properties.get("hbase.rootdir")
     hbase_tmpdir = properties.get("hbase.tmp.dir")
     hbase_tmpdir = properties.get("hbase.tmp.dir")
-    if op_mode == "distributed" and hbase_rootdir.startswith("file://"):
+    is_local_root_dir = hbase_rootdir.startswith("file://") or (default_fs.startswith("file://") and hbase_rootdir.startswith("/"))
+    if op_mode == "distributed" and is_local_root_dir:
       rootdir_item = self.getWarnItem("In distributed mode hbase.rootdir should point to HDFS.")
       rootdir_item = self.getWarnItem("In distributed mode hbase.rootdir should point to HDFS.")
+    elif op_mode == "embedded" and hbase_rootdir.startswith('/'):
+      rootdir_item = self.getWarnItem("In embedded mode schemaless values are not supported for hbase.rootdir")
       pass
       pass
 
 
     distributed_item = None
     distributed_item = None
@@ -885,13 +895,13 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
     for collectorHostName in amsCollectorHosts:
     for collectorHostName in amsCollectorHosts:
       for host in hosts["items"]:
       for host in hosts["items"]:
         if host["Hosts"]["host_name"] == collectorHostName:
         if host["Hosts"]["host_name"] == collectorHostName:
-          if op_mode == 'embedded':
+          if op_mode == 'embedded' or is_local_root_dir:
             validationItems.extend([{"config-name": 'hbase.rootdir', "item": self.validatorEnoughDiskSpace(properties, 'hbase.rootdir', host["Hosts"], recommendedDiskSpace)}])
             validationItems.extend([{"config-name": 'hbase.rootdir', "item": self.validatorEnoughDiskSpace(properties, 'hbase.rootdir', host["Hosts"], recommendedDiskSpace)}])
             validationItems.extend([{"config-name": 'hbase.rootdir', "item": self.validatorNotRootFs(properties, recommendedDefaults, 'hbase.rootdir', host["Hosts"])}])
             validationItems.extend([{"config-name": 'hbase.rootdir', "item": self.validatorNotRootFs(properties, recommendedDefaults, 'hbase.rootdir', host["Hosts"])}])
             validationItems.extend([{"config-name": 'hbase.tmp.dir', "item": self.validatorNotRootFs(properties, recommendedDefaults, 'hbase.tmp.dir', host["Hosts"])}])
             validationItems.extend([{"config-name": 'hbase.tmp.dir', "item": self.validatorNotRootFs(properties, recommendedDefaults, 'hbase.tmp.dir', host["Hosts"])}])
 
 
           dn_hosts = self.getComponentHostNames(services, "HDFS", "DATANODE")
           dn_hosts = self.getComponentHostNames(services, "HDFS", "DATANODE")
-          if not hbase_rootdir.startswith("hdfs"):
+          if is_local_root_dir:
             mountPoints = []
             mountPoints = []
             for mountPoint in host["Hosts"]["disk_info"]:
             for mountPoint in host["Hosts"]["disk_info"]:
               mountPoints.append(mountPoint["mountpoint"])
               mountPoints.append(mountPoint["mountpoint"])

+ 5 - 0
ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py

@@ -1227,6 +1227,11 @@ class TestHDP206StackAdvisor(TestCase):
           'dfs.datanode.data.dir': "/hadoop/data"
           'dfs.datanode.data.dir': "/hadoop/data"
         }
         }
       },
       },
+      "core-site": {
+        "properties": {
+          "fs.defaultFS": "hdfs://c6401.ambari.apache.org:8020"
+        }
+      },
       "ams-site": {
       "ams-site": {
         "properties": {
         "properties": {
           "timeline.metrics.service.operation.mode": "embedded"
           "timeline.metrics.service.operation.mode": "embedded"