Пример #1
0
def install_kafka(*args):

    kafka = Kafka(DistConfig())
    if kafka.verify_resources():
        hookenv.status_set('maintenance', 'Installing Kafka')
        kafka.install()
        kafka.open_ports()
        set_state('kafka.installed')
Пример #2
0
def configure_kafka(zk):
    hookenv.status_set('maintenance', 'setting up kafka')
    if hookenv.config()['log_dir']:
        log_dir = hookenv.config()['log_dir']
    else:
        log_dir = unitdata.kv().get('kafka.storage.log_dir')
    kafka = Kafka()
    zks = zk.zookeepers()
    data_changed('kafka.storage.log_dir', log_dir)
    data_changed('zookeepers', zks),
    if log_dir:
        kafka.install(zk_units=zks, log_dir=log_dir)
    else:
        hookenv.status_set('blocked', 'unable to get storage dir')
    charms.coordinator.acquire('restart')
Пример #3
0
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)
Пример #4
0
def configure_kafka_zookeepers(zk):
    """Configure ready zookeepers and restart kafka if needed.
    As zks come and go, server.properties will be updated. When that file
    changes, restart Kafka and set appropriate status messages.
    """
    zks = zk.zookeepers()
    log_dir = unitdata.kv().get('kafka.storage.log_dir')
    if not (any(
        (data_changed('zookeepers',
                      zks), data_changed('kafka.storage.log_dir', log_dir)))):
        return

    hookenv.log('Checking Zookeeper configuration')
    hookenv.status_set('maintenance', 'updating zookeeper instances')
    kafka = Kafka()
    kafka.install(zk_units=zks, log_dir=log_dir)
    hookenv.status_set('active', 'ready')