in bigtop-packages/src/charm/hbase/layer-hbase/reactive/hbase.py [0:0]
def install_hbase(hdfs, zk):
'''
Anytime our dependencies are available, check to see if we have a valid
reason to (re)install. These include:
- initial install
- config change
- Zookeeper unit has joined/departed
'''
zks = zk.zookeepers()
deployment_matrix = {
'zookeepers': zks,
}
# Handle nuances when installing versus re-installing
if not is_state('hbase.installed'):
prefix = "installing"
# On initial install, prime our kv with the current deployment matrix.
# Subsequent calls will use this to determine if a reinstall is needed.
data_changed('deployment_matrix', deployment_matrix)
else:
prefix = "configuring"
# We do not need to reinstall when peers come and go; that is covered
# by other handlers below.
if is_state('hbpeer.departed') or is_state('hbpeer.joined'):
return
# Return if neither config nor our matrix has changed
if not (is_state('config.changed') or
data_changed('deployment_matrix', deployment_matrix)):
return
hookenv.status_set('maintenance', '{} hbase'.format(prefix))
hookenv.log("{} hbase with: {}".format(prefix, deployment_matrix))
hbase = HBase()
hosts = {}
hosts['namenode'] = hdfs.namenodes()[0]
hbase.configure(hosts, zks)
# Ensure our IP is in the regionservers list; restart if the rs conf
# file has changed.
hbase.update_regionservers([hookenv.unit_private_ip()])
if any_file_changed(['/etc/hbase/conf/regionservers']):
hbase.restart()
# set app version string for juju status output
hbase_version = get_package_version('hbase-master') or 'unknown'
hookenv.application_version_set(hbase_version)
hbase.open_ports()
report_status()
set_state('hbase.installed')