Exemple #1
0
def restart():
    hookenv.status_set('maintenance', 'Rolling restart')
    kafka = Kafka()
    if not kafka.is_running():
        kafka.start()
    else:
        kafka.restart()
    hookenv.open_port(hookenv.config()['port'])
    # set app version string for juju status output
    kafka_version = kafka.version()
    hookenv.application_version_set(kafka_version)
    hookenv.status_set('active', 'ready')
    set_state('kafka.started')
def configure_kafka(zk):
    hookenv.status_set('maintenance', 'setting up kafka')
    log_dir = unitdata.kv().get('kafka.storage.log_dir')
    data_changed('kafka.storage.log_dir', log_dir)
    kafka = Kafka()
    zks = zk.zookeepers()
    if log_dir:
        kafka.install(zk_units=zks, log_dir=log_dir)
    else:
        hookenv.status_set('blocked', 'unable to get storage dir')
    kafka.open_ports()
    set_state('kafka.started')
    hookenv.status_set('active', 'ready')
    # set app version string for juju status output
    kafka_version = kafka.version()
    hookenv.application_version_set(kafka_version)