예제 #1
0
def _push_zk_configs_to_nodes(cluster, zk_conf, to_delete_instances=None):
    instances = vu.get_zk_servers(cluster)
    if to_delete_instances:
        for instance in to_delete_instances:
            if instance in instances:
                instances.remove(instance)
    for index, instance in enumerate(instances):
        with instance.remote() as r:
            r.write_file_to('/opt/zookeeper/conf/zoo.cfg',
                            zk_conf,
                            run_as_root=True)
            r.execute_command(
                'sudo su - -c "echo %s > /var/zookeeper/myid" hadoop' % index)
예제 #2
0
def _form_zk_servers_to_quorum(cluster, to_delete_instances=None):
    quorum = []
    instances = map(vu.get_instance_hostname, vu.get_zk_servers(cluster))
    if to_delete_instances:
        delete_instances = map(vu.get_instance_hostname, to_delete_instances)
        reserve_instances = list(set(instances) - set(delete_instances))
        # keep the original order of instances
        reserve_instances.sort(key=instances.index)
    else:
        reserve_instances = instances
    for index, instance in enumerate(reserve_instances):
        quorum.append("server.%s=%s:2888:3888" % (index, instance))
    return '\n'.join(quorum)
def refresh_zk_servers(cluster, to_delete_instances=None):
    instances = vu.get_zk_servers(cluster)
    if to_delete_instances:
        for instance in to_delete_instances:
            if instance in instances:
                instances.remove(instance)

    utils.add_provisioning_step(cluster.id,
                                utils.start_process_event_message("ZooKeeper"),
                                len(instances))

    with context.PluginsThreadGroup() as tg:
        for instance in instances:
            with context.set_current_instance_id(instance.instance_id):
                tg.spawn('ZK-restart-processes-%s' % instance.instance_name,
                         _start_zk_processes, instance, 'restart')
예제 #4
0
def configure_zookeeper(cluster, instances=None):
    zk_servers = vu.get_zk_servers(cluster)
    if zk_servers:
        zk_conf = config_helper.generate_zk_basic_config(cluster)
        zk_conf += _form_zk_servers_to_quorum(cluster, instances)
        _push_zk_configs_to_nodes(cluster, zk_conf, instances)
예제 #5
0
def start_zookeeper(cluster):
    zk_servers = vu.get_zk_servers(cluster)
    if zk_servers:
        run.start_zk_server(zk_servers)