Пример #1
0
 def setUp(self):
     super(ClientSessionTests, self).setUp()
     self.cluster.start()
     self.client = None
     self.client2 = None
     zookeeper.deterministic_conn_order(True)
     zookeeper.set_debug_level(0)
Пример #2
0
    def set_deterministic_order(self, boolean):
        """
        The zookeeper client will by default randomize the server hosts
        it will connect to unless this is set to True.

        This is a global setting across connections.
        """
        zookeeper.deterministic_conn_order(bool(boolean))
Пример #3
0
    def setup_zookeeper(self):
        """Create a ZK cluster and chrooted :class:`KazooClient`

        The cluster will only be created on the first invocation and won't be
        fully torn down until exit.
        """
        zookeeper.deterministic_conn_order(True)
        if not self.cluster[0].running:
            self.cluster.start()
        namespace = "/kazootests" + uuid.uuid4().hex
        self.hosts = self.servers + namespace

        self.client = self._get_client()
        self.client.connect()
        self.client.ensure_path("/")
Пример #4
0
import os
import uuid
import sys
from collections import namedtuple
import threading
import unittest

import zookeeper
from kazoo.client import Callback
from kazoo.client import KazooClient
from kazoo.client import KazooState
from kazoo.testing.common import ZookeeperCluster

log = logging.getLogger(__name__)

zookeeper.deterministic_conn_order(True)

CLUSTER = None


def get_global_cluster():
    global CLUSTER
    if CLUSTER is None:
        ZK_HOME = os.environ.get("ZOOKEEPER_PATH")
        assert ZK_HOME, (
            "ZOOKEEPER_PATH environment variable must be defined.\n "
            "For deb package installations this is /usr/share/java")

        CLUSTER = ZookeeperCluster(ZK_HOME)
        atexit.register(lambda cluster: cluster.terminate(), CLUSTER)
    return CLUSTER