diff options
author | Dina Belova <dbelova@mirantis.com> | 2014-08-26 12:18:49 +0400 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2014-09-05 11:13:03 -0700 |
commit | faaeb41721c714f0d990a7b2a36a47f777e6cf48 (patch) | |
tree | 8523e0c1b7691777be88d62a7ed8fdba830a2939 | |
parent | 54dd71907989fa194f5cf71c25e5208c76df1f4d (diff) | |
download | tooz-faaeb41721c714f0d990a7b2a36a47f777e6cf48.tar.gz |
Move Zake driver code to separated Python module
That is needed to prevent Zake driver load in real-life Zookeeper
usage - currently we had the situation when even if you want to use
just KaZoo, you needed to install partially test-requierements
(zake package).
Change-Id: I9664fda2d6e76a6e48776b4a6d92af4c4baf1425
-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): |