예제 #1
0
파일: store.py 프로젝트: oldpatricka/epu
    def __init__(self, hosts, base_path, username=None, password=None,
                 timeout=None, use_gevent=False, proc_name=None):

        kwargs = zkutil.get_kazoo_kwargs(username=username, password=password,
                                         timeout=timeout, use_gevent=use_gevent)
        self.kazoo = KazooClient(hosts + base_path, **kwargs)

        self.retry = zkutil.get_kazoo_retry()

        if not proc_name:
            proc_name = ""
        zk_id = "%s:%s:%d" % (proc_name, socket.gethostname(), os.getpid())

        log.info("Election id %s participating on %s" % (zk_id, self.ELECTION_PATH))
        self.election = self.kazoo.Election(self.ELECTION_PATH, identifier=zk_id)
        self.party = Party(self.kazoo, self.PARTICIPANT_PATH)

        #  callback fired when the connection state changes
        self.kazoo.add_listener(self._connection_state_listener)

        self._shutdown = False

        self._election_enabled = False
        self._election_condition = threading.Condition()
        self._election_thread = None

        self._leader = None

        self._disabled = False
        self._disabled_condition = threading.Condition()
예제 #2
0
파일: store.py 프로젝트: lelou6666/epu
    def __init__(self, hosts, base_path, username=None, password=None, timeout=None, use_gevent=False):

        kwargs = zkutil.get_kazoo_kwargs(username=username, password=password,
            timeout=timeout, use_gevent=use_gevent)
        self.kazoo = KazooClient(hosts + base_path, **kwargs)
        self.retry = zkutil.get_kazoo_retry()