예제 #1
0
def configure_kafka(zk):
    hookenv.status_set('maintenance', 'Setting up Kafka')
    kafka = Kafka()
    zks = zk.zookeepers()
    kafka.configure_kafka(zks)
    set_state('kafka.started')
    hookenv.status_set('active', 'Ready')
예제 #2
0
파일: kafka.py 프로젝트: Guavus/bigtop
def stop_kafka_waiting_for_zookeeper_ready():
    hookenv.status_set('maintenance', 'zookeeper not ready, stopping kafka')
    kafka = Kafka()
    kafka.close_ports()
    kafka.stop()
    remove_state('kafka.started')
    hookenv.status_set('waiting', 'waiting for zookeeper to become ready')
예제 #3
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.

    This method also handles the restart if our network_interface
    config has changed.

    """
    zks = zk.zookeepers()
    network_interface = hookenv.config().get('network_interface')
    log_dir = unitdata.kv().get('kafka.storage.log_dir')
    if not(any((
            data_changed('zookeepers', zks),
            data_changed('kafka.network_interface', network_interface),
            data_changed('kafka.storage.log_dir', log_dir)))):
        return

    hookenv.log('Checking Zookeeper configuration')
    hookenv.status_set('maintenance', 'updating zookeeper instances')
    kafka = Kafka()
    kafka.configure_kafka(zks, network_interface=network_interface,
                          log_dir=log_dir)
    hookenv.status_set('active', 'ready')
예제 #4
0
파일: kafka.py 프로젝트: Guavus/bigtop
def configure_kafka(zk):
    hookenv.status_set('maintenance', 'setting up kafka')
    data_changed(  # Prime data changed for network interface
        'kafka.network_interface', hookenv.config().get('network_interface'))
    kafka = Kafka()
    zks = zk.zookeepers()
    kafka.configure_kafka(zks)
    kafka.open_ports()
    set_state('kafka.started')
    hookenv.status_set('active', 'ready')
    # set app version string for juju status output
    kafka_version = get_package_version('kafka') or 'unknown'
    hookenv.application_version_set(kafka_version)
예제 #5
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()
    if not data_changed('zookeepers', zks):
        return

    hookenv.log('Checking Zookeeper configuration')
    kafka = Kafka()
    kafka.configure_kafka(zks)
    hookenv.status_set('active', 'Ready')
예제 #6
0
파일: kafka.py 프로젝트: Guavus/bigtop
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.

    This method also handles the restart if our network_interface
    config has changed.

    """
    zks = zk.zookeepers()
    network_interface = hookenv.config().get('network_interface')
    if not data_changed('zookeepers', zks) and not data_changed(
            'kafka.network_interface', network_interface):
        return

    hookenv.log('Checking Zookeeper configuration')
    hookenv.status_set('maintenance', 'updating zookeeper instances')
    kafka = Kafka()
    kafka.configure_kafka(zks, network_interface)
    hookenv.status_set('active', 'ready')
예제 #7
0
def stop_kafka_waiting_for_zookeeper_ready():
    hookenv.status_set('maintenance', 'zookeeper not ready, stopping kafka')
    kafka = Kafka()
    kafka.close_ports()
    kafka.stop()
    remove_state('kafka.started')
    hookenv.status_set('waiting', 'waiting for zookeeper to become ready')
예제 #8
0
def storage_detaching():
    unitdata.kv().unset('kafka.storage.log_dir')
    kafka = Kafka()
    kafka.close_ports()
    kafka.stop()
    remove_state('kafka.started')
    hookenv.status_set('waiting', 'reconfiguring to use temporary storage')
    remove_state('kafka.storage.logs.attached')
예제 #9
0
def configure_kafka(zk):
    hookenv.status_set('maintenance', 'setting up kafka')
    data_changed(  # Prime data changed for network interface
        'kafka.network_interface',
        hookenv.config().get('network_interface'))
    kafka = Kafka()
    zks = zk.zookeepers()
    kafka.configure_kafka(zks)
    kafka.open_ports()
    set_state('kafka.started')
    hookenv.status_set('active', 'ready')
예제 #10
0
def configure_kafka(zk):
    hookenv.status_set('maintenance', 'setting up kafka')
    data_changed(  # Prime data changed for network interface
        'kafka.network_interface',
        hookenv.config().get('network_interface'))
    kafka = Kafka()
    zks = zk.zookeepers()
    kafka.configure_kafka(zks)
    kafka.open_ports()
    set_state('kafka.started')
    hookenv.status_set('active', 'ready')
    # set app version string for juju status output
    kafka_version = get_package_version('kafka') or 'unknown'
    hookenv.application_version_set(kafka_version)
예제 #11
0
def storage_attach():
    storageids = hookenv.storage_list('logs')
    if not storageids:
        hookenv.status_set('blocked', 'cannot locate attached storage')
        return
    storageid = storageids[0]

    mount = hookenv.storage_get('location', storageid)
    if not mount:
        hookenv.status_set('blocked', 'cannot locate attached storage mount')
        return

    log_dir = os.path.join(mount, "logs")
    unitdata.kv().set('kafka.storage.log_dir', log_dir)
    hookenv.log('Kafka logs storage attached at {}'.format(log_dir))
    # Stop Kafka; removing the kafka.started state will trigger a reconfigure if/when it's ready
    kafka = Kafka()
    kafka.close_ports()
    kafka.stop()
    remove_state('kafka.started')
    hookenv.status_set('waiting', 'reconfiguring to use attached storage')
    set_state('kafka.storage.logs.attached')