diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2014-09-11 18:45:08 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2014-09-15 16:38:11 -0700 |
commit | ac6f7d93dbf18db1e17f44c4b8727ca624e163b3 (patch) | |
tree | 9c9f516946c876d670286fc306800024ae55677d | |
parent | 3981a3a3003b1d7df380f39c9ac1451e716a0c18 (diff) | |
download | tooz-ac6f7d93dbf18db1e17f44c4b8727ca624e163b3.tar.gz |
Let zake act as a in-memory fully functional driver
The zake driver should theoretically function the same as the
non-local driver so all the same kazoo functions should work,
without the whole distributed part as they work with the regular
zookeeper backed kazoo driver.
Change-Id: I19df0da0e58c5624ca1b10f61c42510f1f104847
-rw-r--r-- | requirements.txt | 1 | ||||
-rw-r--r-- | test-requirements.txt | 1 | ||||
-rw-r--r-- | tooz/drivers/zake.py | 37 | ||||
-rw-r--r-- | tooz/drivers/zookeeper.py | 6 |
4 files changed, 10 insertions, 35 deletions
diff --git a/requirements.txt b/requirements.txt index df43765..c46fda1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,6 +6,7 @@ iso8601 kazoo>=1.3.1 oslo.config pymemcache>=1.2 +zake>=0.1.6 posix_ipc msgpack-python retrying diff --git a/test-requirements.txt b/test-requirements.txt index 149fa4e..07d9b74 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -7,5 +7,4 @@ python-subunit testrepository>=0.0.17 testtools>=0.9.32 testscenarios>=0.4 -zake>=0.1 coverage>=3.6 diff --git a/tooz/drivers/zake.py b/tooz/drivers/zake.py index 5ca244e..deb4430 100644 --- a/tooz/drivers/zake.py +++ b/tooz/drivers/zake.py @@ -17,11 +17,10 @@ from __future__ import absolute_import from zake import fake_client from zake import fake_storage -import tooz from tooz.drivers import zookeeper -class ZakeDriver(zookeeper.BaseZooKeeperDriver): +class ZakeDriver(zookeeper.KazooDriver): """The driver using the Zake client which mimic a fake Kazoo client without the need of real ZooKeeper servers. """ @@ -30,34 +29,6 @@ class ZakeDriver(zookeeper.BaseZooKeeperDriver): fake_storage = fake_storage.FakeStorage( fake_client.k_threading.SequentialThreadingHandler()) - def __init__(self, member_id, parsed_url, options): - super(ZakeDriver, self).__init__(member_id, parsed_url, options) - self._coord = fake_client.FakeClient(storage=self.fake_storage) - - @staticmethod - def watch_join_group(group_id, callback): - raise tooz.NotImplemented - - @staticmethod - def unwatch_join_group(group_id, callback): - raise tooz.NotImplemented - - @staticmethod - def watch_leave_group(group_id, callback): - raise tooz.NotImplemented - - @staticmethod - def unwatch_leave_group(group_id, callback): - raise tooz.NotImplemented - - @staticmethod - def watch_elected_as_leader(group_id, callback): - raise tooz.NotImplemented - - @staticmethod - def unwatch_elected_as_leader(group_id, callback): - raise tooz.NotImplemented - - @staticmethod - def run_watchers(): - raise tooz.NotImplemented + @classmethod + def _make_client(cls, parsed_url, options): + return fake_client.FakeClient(storage=cls.fake_storage) diff --git a/tooz/drivers/zookeeper.py b/tooz/drivers/zookeeper.py index 7ea8e58..9b110e1 100644 --- a/tooz/drivers/zookeeper.py +++ b/tooz/drivers/zookeeper.py @@ -207,9 +207,13 @@ class KazooDriver(BaseZooKeeperDriver): def __init__(self, member_id, parsed_url, options): super(KazooDriver, self).__init__(member_id, parsed_url, options) - self._coord = client.KazooClient(hosts=parsed_url.netloc) + self._coord = self._make_client(parsed_url, options) self._member_id = member_id + @classmethod + def _make_client(cls, parsed_url, options): + return client.KazooClient(hosts=parsed_url.netloc) + def _watch_group(self, group_id): get_members_req = self.get_members(group_id) |