diff options
author | Jenkins <jenkins@review.openstack.org> | 2014-09-10 09:24:02 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2014-09-10 09:24:02 +0000 |
commit | beb73ba6515de2bf891adba1112715c9f2155de7 (patch) | |
tree | d08c3eeb542fca1e44a4c0fac3f1ff33b1bc55f6 | |
parent | 603bac9b2218ba78a04d42bb5f77535f256bb559 (diff) | |
parent | faaeb41721c714f0d990a7b2a36a47f777e6cf48 (diff) | |
download | tooz-beb73ba6515de2bf891adba1112715c9f2155de7.tar.gz |
Merge "Move Zake driver code to separated Python module"
-rw-r--r-- | setup.cfg | 2 | ||||
-rw-r--r-- | tooz/drivers/zake.py | 62 | ||||
-rw-r--r-- | tooz/drivers/zookeeper.py | 43 |
3 files changed, 63 insertions, 44 deletions
@@ -25,7 +25,7 @@ packages = [entry_points] tooz.backends = kazoo = tooz.drivers.zookeeper:KazooDriver - zake = tooz.drivers.zookeeper:ZakeDriver + zake = tooz.drivers.zake:ZakeDriver memcached = tooz.drivers.memcached:MemcachedDriver ipc = tooz.drivers.ipc:IPCDriver diff --git a/tooz/drivers/zake.py b/tooz/drivers/zake.py new file mode 100644 index 0000000..4e43ae1 --- /dev/null +++ b/tooz/drivers/zake.py @@ -0,0 +1,62 @@ +# Copyright (c) 2013-2014 Mirantis Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from __future__ import absolute_import + +from zake import fake_client +from zake import fake_storage + +from tooz.drivers import zookeeper + + +class ZakeDriver(zookeeper.BaseZooKeeperDriver): + """The driver using the Zake client which mimic a fake Kazoo client + without the need of real ZooKeeper servers. + """ + + # here we need to pass *threading handler* as an argument + 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 NotImplementedError + + @staticmethod + def unwatch_join_group(group_id, callback): + raise NotImplementedError + + @staticmethod + def watch_leave_group(group_id, callback): + raise NotImplementedError + + @staticmethod + def unwatch_leave_group(group_id, callback): + raise NotImplementedError + + @staticmethod + def watch_elected_as_leader(group_id, callback): + raise NotImplementedError + + @staticmethod + def unwatch_elected_as_leader(group_id, callback): + raise NotImplementedError + + @staticmethod + def run_watchers(): + raise NotImplementedError diff --git a/tooz/drivers/zookeeper.py b/tooz/drivers/zookeeper.py index 1fdd8df..7ea8e58 100644 --- a/tooz/drivers/zookeeper.py +++ b/tooz/drivers/zookeeper.py @@ -21,8 +21,6 @@ from kazoo import client from kazoo import exceptions from kazoo.protocol import paths import six -import zake.fake_client -import zake.fake_storage from tooz import coordination from tooz import locking @@ -352,47 +350,6 @@ class KazooDriver(BaseZooKeeperDriver): return ret -class ZakeDriver(BaseZooKeeperDriver): - """The driver using the Zake client which mimic a fake Kazoo client - without the need of real ZooKeeper servers. - """ - - fake_storage = zake.fake_storage.FakeStorage( - zake.fake_client.k_threading.SequentialThreadingHandler()) - - def __init__(self, member_id, parsed_url, options): - super(ZakeDriver, self).__init__(member_id, parsed_url, options) - self._coord = zake.fake_client.FakeClient(storage=self.fake_storage) - - @staticmethod - def watch_join_group(group_id, callback): - raise NotImplementedError - - @staticmethod - def unwatch_join_group(group_id, callback): - raise NotImplementedError - - @staticmethod - def watch_leave_group(group_id, callback): - raise NotImplementedError - - @staticmethod - def unwatch_leave_group(group_id, callback): - raise NotImplementedError - - @staticmethod - def watch_elected_as_leader(group_id, callback): - raise NotImplementedError - - @staticmethod - def unwatch_elected_as_leader(group_id, callback): - raise NotImplementedError - - @staticmethod - def run_watchers(): - raise NotImplementedError - - class ZooAsyncResult(coordination.CoordAsyncResult): def __init__(self, kazooAsyncResult, handler, **kwargs): |