in cloudera-on-centos/scripts/cmxDeployOnIbiza.py [0:0]
def setup_hbase():
"""
HBase
> Creating HBase root directory
Starting HBase Service
:return:
"""
api = ApiResource(server_host=cmx.cm_server, username=cmx.username, password=cmx.password)
cluster = api.get_cluster(cmx.cluster_name)
service_type = "HBASE"
if cdh.get_service_type(service_type) is None:
print "> %s" % service_type
service_name = "hbase"
print "Create %s service" % service_name
cluster.create_service(service_name, service_type)
service = cluster.get_service(service_name)
hosts = management.get_hosts()
# Service-Wide
service.update_config(cdh.dependencies_for(service))
master_host_id = [host for host in hosts if host.id == 0][0]
backup_master_host_id = [host for host in hosts if host.id == 1][0]
for rcg in [x for x in service.get_all_role_config_groups()]:
if rcg.roleType == "MASTER":
cdh.create_service_role(service, rcg.roleType, master_host_id)
cdh.create_service_role(service, rcg.roleType, backup_master_host_id)
if rcg.roleType == "REGIONSERVER":
for host in management.get_hosts(include_cm_host = False):
if host.hostId != master_host_id.hostId:
if host.hostId != backup_master_host_id.hostId:
cdh.create_service_role(service, rcg.roleType, host)
for role_type in ['HBASETHRIFTSERVER', 'HBASERESTSERVER']:
cdh.create_service_role(service, role_type, random.choice(hosts))
for role_type in ['GATEWAY']:
for host in management.get_hosts(include_cm_host=(role_type == 'GATEWAY')):
cdh.create_service_role(service, role_type, host)
check.status_for_command("Creating HBase root directory", service.create_hbase_root())
check.status_for_command("Starting HBase Service", service.start())