def configure_kafka(zkjoining, zkavailable): try: zk_units = zkavailable.get_zookeeper_units() hookenv.status_set('maintenance', 'Setting up Kafka') kafka = Kafka(DistConfig()) kafka.configure_kafka(zk_units) kafka.start() zkjoining.dismiss_joining() hookenv.status_set('active', 'Ready') set_state('kafka.started') except: hookenv.log("Relation with Zookeeper not established")
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')