summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Magyar <m.magyar3@gmail.com>2018-05-31 17:25:36 +0200
committerGitHub <noreply@github.com>2018-05-31 17:25:36 +0200
commitc345720106b2894276cd3dbc90500588cb989064 (patch)
tree6ec0dcb7617ccc1f5ef46e3389ee11d7d9cb1c44
parent17d5bd4e6f31370e38ed614a76a5c878fb20eb56 (diff)
AMBARI-23995. stack advisor error : UnboundLocalError: local variable 'host' referenced before assignment (amagyar) (#1426)
-rw-r--r--ambari-server/src/main/resources/stacks/HDP/2.6/services/stack_advisor.py75
1 files changed, 31 insertions, 44 deletions
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.6/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.6/services/stack_advisor.py
index b87a8a537c..f0c4bdc32a 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.6/services/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.6/services/stack_advisor.py
@@ -682,51 +682,38 @@ class HDP26StackAdvisor(HDP25StackAdvisor):
# druid is not in list of services to be installed
servicesList = [service["StackServices"]["service_name"] for service in services["services"]]
if 'DRUID' in servicesList:
- putHiveInteractiveSiteProperty = self.putProperty(configurations, "hive-interactive-site", services)
- if 'druid-coordinator' in services['configurations']:
- component_hosts = self.getHostsWithComponent("DRUID", 'DRUID_COORDINATOR', services, hosts)
- if component_hosts is not None and len(component_hosts) > 0:
- # pick the first
- host = component_hosts[0]
- druid_coordinator_host_port = str(host['Hosts']['host_name']) + ":" + str(
- services['configurations']['druid-coordinator']['properties']['druid.port'])
+ putHiveInteractiveSiteProperty = self.putProperty(configurations, "hive-interactive-site", services)
+
+ druid_coordinator_host_port = self.druid_host('DRUID_COORDINATOR', 'druid-coordinator', services, hosts, default_host='localhost:8081')
+ druid_broker_host_port = self.druid_host('DRUID_ROUTER', 'druid-router', services, hosts)
+ if druid_broker_host_port is None:
+ druid_broker_host_port = self.druid_host('DRUID_BROKER', 'druid-broker', services, hosts, default_host='localhost:8083')
+
+ druid_metadata_uri = ""
+ druid_metadata_user = ""
+ druid_metadata_type = ""
+ if 'druid-common' in services['configurations']:
+ druid_metadata_uri = services['configurations']['druid-common']['properties']['druid.metadata.storage.connector.connectURI']
+ druid_metadata_type = services['configurations']['druid-common']['properties']['druid.metadata.storage.type']
+ if 'druid.metadata.storage.connector.user' in services['configurations']['druid-common']['properties']:
+ druid_metadata_user = services['configurations']['druid-common']['properties']['druid.metadata.storage.connector.user']
else:
- druid_coordinator_host_port = "localhost:8081"
-
- if 'druid-router' in services['configurations']:
- component_hosts = self.getHostsWithComponent("DRUID", 'DRUID_ROUTER', services, hosts)
- if component_hosts is not None and len(component_hosts) > 0:
- # pick the first
- host = component_hosts[0]
- druid_broker_host_port = str(host['Hosts']['host_name']) + ":" + str(
- services['configurations']['druid-router']['properties']['druid.port'])
- elif 'druid-broker' in services['configurations']:
- component_hosts = self.getHostsWithComponent("DRUID", 'DRUID_BROKER', services, hosts)
- if component_hosts is not None and len(component_hosts) > 0:
- # pick the first
- host = component_hosts[0]
- druid_broker_host_port = str(host['Hosts']['host_name']) + ":" + str(
- services['configurations']['druid-broker']['properties']['druid.port'])
- else:
- druid_broker_host_port = "localhost:8083"
-
- druid_metadata_uri = ""
- druid_metadata_user = ""
- druid_metadata_type = ""
- if 'druid-common' in services['configurations']:
- druid_metadata_uri = services['configurations']['druid-common']['properties']['druid.metadata.storage.connector.connectURI']
- druid_metadata_type = services['configurations']['druid-common']['properties']['druid.metadata.storage.type']
- if 'druid.metadata.storage.connector.user' in services['configurations']['druid-common']['properties']:
- druid_metadata_user = services['configurations']['druid-common']['properties']['druid.metadata.storage.connector.user']
- else:
- druid_metadata_user = ""
-
- putHiveInteractiveSiteProperty('hive.druid.broker.address.default', druid_broker_host_port)
- putHiveInteractiveSiteProperty('hive.druid.coordinator.address.default', druid_coordinator_host_port)
- putHiveInteractiveSiteProperty('hive.druid.metadata.uri', druid_metadata_uri)
- putHiveInteractiveSiteProperty('hive.druid.metadata.username', druid_metadata_user)
- putHiveInteractiveSiteProperty('hive.druid.metadata.db.type', druid_metadata_type)
-
+ druid_metadata_user = ""
+
+ putHiveInteractiveSiteProperty('hive.druid.broker.address.default', druid_broker_host_port)
+ putHiveInteractiveSiteProperty('hive.druid.coordinator.address.default', druid_coordinator_host_port)
+ putHiveInteractiveSiteProperty('hive.druid.metadata.uri', druid_metadata_uri)
+ putHiveInteractiveSiteProperty('hive.druid.metadata.username', druid_metadata_user)
+ putHiveInteractiveSiteProperty('hive.druid.metadata.db.type', druid_metadata_type)
+
+ def druid_host(self, component_name, config_type, services, hosts, default_host=None):
+ hosts = self.getHostsWithComponent('DRUID', component_name, services, hosts)
+ if hosts and config_type in services['configurations']:
+ host = hosts[0]['Hosts']['host_name']
+ port = services['configurations'][config_type]['properties']['druid.port']
+ return "%s:%s" % (host, port)
+ else:
+ return default_host
def recommendHBASEConfigurations(self, configurations, clusterData, services, hosts):
super(HDP26StackAdvisor, self).recommendHBASEConfigurations(configurations, clusterData, services, hosts)