tooz(1)
| TOOZ(1) | tooz | TOOZ(1) |
NAME
tooz - tooz 6.3.0
The Tooz project aims at centralizing the most common distributed primitives like group membership protocol, lock service and leader election by providing a coordination API helping developers to build distributed applications. [1]
CONTENTS
Installation
Python Versions
Tooz is tested under Python 2.7 and 3.4.
Basic Installation
Tooz should be installed into the same site-packages area where the application and extensions are installed (either a virtualenv or the global site-packages). You may need administrative privileges to do that. The easiest way to install it is using pip:
$ pip install tooz
or:
$ sudo pip install tooz
Download
Tooz releases are hosted on PyPI and can be downloaded from: http://pypi.python.org/pypi/tooz
Source Code
The source is hosted on the OpenStack infrastructure: https://opendev.org/openstack/tooz/
Reporting Bugs
Please report bugs through the launchpad project: https://launchpad.net/python-tooz
User Documentation
Using Tooz in Your Application
This tutorial is a step-by-step walk-through demonstrating how to use tooz in your application.
Creating A Coordinator
The principal object provided by tooz is the coordinator. It allows you to use various features, such as group membership, leader election or distributed locking.
The features provided by tooz coordinator are implemented using different drivers. When creating a coordinator, you need to specify which back-end driver you want it to use. Different drivers may provide different set of capabilities.
If a driver does not support a feature, it will raise a NotImplemented exception.
This example program loads a basic coordinator using the ZooKeeper based driver.
# Copyright (C) 2020 Red Hat, Inc.
#
# 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 tooz import coordination
coordinator = coordination.get_coordinator('zake://', b'host-1')
coordinator.start()
coordinator.stop()
The second argument passed to the coordinator must be a unique identifier identifying the running program.
After the coordinator is created, it can be used to use the various features provided.
In order to keep the connection to the coordination server active, the method heartbeat() method must be called regularly. This will ensure that the coordinator is not considered dead by other program participating in the coordination. Unless you want to call it manually, you can use tooz builtin heartbeat manager by passing the start_heart argument.
# Copyright (C) 2020 Red Hat, Inc.
#
# 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 tooz import coordination
coordinator = coordination.get_coordinator('zake://', b'host-1')
coordinator.start(start_heart=True)
coordinator.stop()
heartbeat at different moment or intervals.
Note that certain drivers, such as memcached are heavily based on timeout, so the interval used to run the heartbeat is important.
Group Membership
Basic operations
One of the feature provided by the coordinator is the ability to handle group membership. Once a group is created, any coordinator can join the group and become a member of it. Any coordinator can be notified when a members joins or leaves the group.
# Copyright (C) 2020 Red Hat, Inc.
#
# 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.
import uuid
from tooz import coordination
coordinator = coordination.get_coordinator('zake://', b'host-1')
coordinator.start()
# Create a group
group = bytes(str(uuid.uuid4()).encode('ascii'))
request = coordinator.create_group(group)
request.get()
# Join a group
request = coordinator.join_group(group)
request.get()
coordinator.stop()
Note that all the operation are asynchronous. That means you cannot be sure that your group has been created or joined before you call the tooz.coordination.CoordAsyncResult.get() method.
You can also leave a group using the tooz.coordination.CoordinationDriver.leave_group() method. The list of all available groups is retrievable via the tooz.coordination.CoordinationDriver.get_groups() method.
Watching Group Changes
It's possible to watch and get notified when the member list of a group changes. That's useful to run callback functions whenever something happens in that group.
# Copyright (C) 2020 Red Hat, Inc.
#
# 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.
import uuid
from tooz import coordination
coordinator = coordination.get_coordinator('zake://', b'host-1')
coordinator.start()
# Create a group
group = bytes(str(uuid.uuid4()).encode('ascii'))
request = coordinator.create_group(group)
request.get()
def group_joined(event):
# Event is an instance of tooz.coordination.MemberJoinedGroup
print(event.group_id, event.member_id)
coordinator.watch_join_group(group, group_joined)
coordinator.stop()
Using tooz.coordination.CoordinationDriver.watch_join_group() and tooz.coordination.CoordinationDriver.watch_leave_group() your application can be notified each time a member join or leave a group. To stop watching an event, the two methods tooz.coordination.CoordinationDriver.unwatch_join_group() and tooz.coordination.CoordinationDriver.unwatch_leave_group() allow to unregister a particular callback.
Leader Election
Each group can elect its own leader. There can be only one leader at a time in a group. Only members that are running for the election can be elected. As soon as one of leader steps down or dies, a new member that was running for the election will be elected.
# Copyright (C) 2020 Red Hat, Inc.
#
# 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.
import time
import uuid
from tooz import coordination
ALIVE_TIME = 1
coordinator = coordination.get_coordinator('zake://', b'host-1')
coordinator.start()
# Create a group
group = bytes(str(uuid.uuid4()).encode('ascii'))
request = coordinator.create_group(group)
request.get()
# Join a group
request = coordinator.join_group(group)
request.get()
def when_i_am_elected_leader(event):
# event is a LeaderElected event
print(event.group_id, event.member_id)
# Propose to be a leader for the group
coordinator.watch_elected_as_leader(group, when_i_am_elected_leader)
start = time.time()
while time.time() - start < ALIVE_TIME:
coordinator.heartbeat()
coordinator.run_watchers()
time.sleep(0.1)
coordinator.stop()
The method tooz.coordination.CoordinationDriver.watch_elected_as_leader() allows to register for a function to be called back when the member is elected as a leader. Using this function indicates that the run is therefore running for the election. The member can stop running by unregistering all its callbacks with tooz.coordination.CoordinationDriver.unwatch_elected_as_leader(). It can also temporarily try to step down as a leader with tooz.coordination.CoordinationDriver.stand_down_group_leader(). If another member is in the run for election, it may be elected instead.
To retrieve the leader of a group, even when not being part of the group, the method tooz.coordination.CoordinationDriver.get_leader() can be used.
Lock
Tooz provides distributed locks. A lock is identified by a name, and a lock can only be acquired by one coordinator at a time.
# Copyright (C) 2020 Red Hat, Inc.
#
# 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 tooz import coordination
coordinator = coordination.get_coordinator('zake://', b'host-1')
coordinator.start()
# Create a lock
lock = coordinator.get_lock("foobar")
with lock:
print("Do something that is distributed")
coordinator.stop()
The method tooz.coordination.CoordinationDriver.get_lock() allows to create a lock identified by a name. Once you retrieve this lock, you can use it as a context manager or use the tooz.locking.Lock.acquire() and tooz.locking.Lock.release() methods to acquire and release the lock.
Hash ring
Tooz provides a consistent hash ring implementation. It can be used to map objects (represented via binary keys) to one or several nodes. When the node list changes, the rebalancing of objects across the ring is kept minimal.
# Copyright (C) 2020 Red Hat, Inc.
#
# 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 tooz import hashring
hashring = hashring.HashRing({'node1', 'node2', 'node3'})
# Returns set(['node2'])
nodes_for_foo = hashring[b'foo']
# Returns set(['node2', 'node3'])
nodes_for_foo_with_replicas = hashring.get_nodes(b'foo',
replicas=2)
# Returns set(['node1', 'node3'])
nodes_for_foo_with_replicas = hashring.get_nodes(b'foo',
replicas=2,
ignore_nodes={'node2'})
Partitioner
Tooz provides a partitioner object based on its consistent hash ring implementation. It can be used to map Python objects to one or several nodes. The partitioner object automatically keeps track of nodes joining and leaving the group, so the rebalancing is managed.
# Copyright (C) 2020 Red Hat, Inc.
#
# 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 tooz import coordination
coordinator = coordination.get_coordinator('zake://', b'host-1')
coordinator.start()
partitioner = coordinator.join_partitioned_group("group1")
# Returns {'host-1'}
member = partitioner.members_for_object(object())
coordinator.leave_partitioned_group(partitioner)
coordinator.stop()
Drivers
Tooz is provided with several drivers implementing the provided coordination API. While all drivers provides the same set of features with respect to the API, some of them have different characteristics:
Zookeeper
Driver: tooz.drivers.zookeeper.KazooDriver
Characteristics:
tooz.drivers.zookeeper.KazooDriver.CHARACTERISTICS
Entrypoint name: zookeeper or kazoo
Summary:
The zookeeper is the reference implementation and provides the most solid features as it's possible to build a cluster of zookeeper servers that is resilient towards network partitions for example.
Test driver: tooz.drivers.zake.ZakeDriver
Characteristics:
tooz.drivers.zake.ZakeDriver.CHARACTERISTICS
Test driver entrypoint name: zake
Considerations
- •
- Primitives are based on sessions (and typically require careful selection of session heartbeat periodicity and server side configuration of session expiry).
Memcached
Driver: tooz.drivers.memcached.MemcachedDriver
Characteristics:
tooz.drivers.memcached.MemcachedDriver.CHARACTERISTICS
Entrypoint name: memcached
Summary:
The memcached driver is a basic implementation and provides little resiliency, though it's much simpler to setup. A lot of the features provided in tooz are based on timeout (heartbeats, locks, etc) so are less resilient than other backends.
Considerations
- Less resilient than other backends such as zookeeper and redis.
- Primitives are often based on TTL(s) that may expire before being renewed.
- Lacks certain primitives (compare and delete) so certain functionality is fragile and/or broken due to this.
Redis
Driver: tooz.drivers.redis.RedisDriver
Characteristics:
tooz.drivers.redis.RedisDriver.CHARACTERISTICS
Entrypoint name: redis
Summary:
The redis driver is a basic implementation and provides reasonable resiliency when used with redis-sentinel. A lot of the features provided in tooz are based on timeout (heartbeats, locks, etc) so are less resilient than other backends.
Considerations
- Less resilient than other backends such as zookeeper.
- Primitives are often based on TTL(s) that may expire before being renewed.
IPC
Driver: tooz.drivers.ipc.IPCDriver
Characteristics: tooz.drivers.ipc.IPCDriver.CHARACTERISTICS
Entrypoint name: ipc
Summary:
The IPC driver is based on Posix IPC API and implements a lock mechanism and some basic group primitives (with huge limitations).
Considerations
- •
- The lock can only be distributed locally to a computer processes.
File
Driver: tooz.drivers.file.FileDriver
Characteristics: tooz.drivers.file.FileDriver.CHARACTERISTICS
Entrypoint name: file
Summary:
The file driver is a simple driver based on files and directories. It implements a lock based on POSIX or Window file level locking mechanism and some basic group primitives (with huge limitations).
Considerations
- The lock can only be distributed locally to a computer processes.
- Certain concepts provided by it are not crash tolerant.
PostgreSQL
Driver: tooz.drivers.pgsql.PostgresDriver
Characteristics:
tooz.drivers.pgsql.PostgresDriver.CHARACTERISTICS
Entrypoint name: postgresql
Summary:
The postgresql driver is a driver providing only a distributed lock (for now) and is based on the PostgreSQL database server and its API(s) that provide for advisory locks to be created and used by applications. When a lock is acquired it will release either when explicitly released or automatically when the database session ends (for example if the program using the lock crashes).
Considerations
- •
- Lock that may be acquired restricted by max_locks_per_transaction * (max_connections + max_prepared_transactions) upper bound (PostgreSQL server configuration settings).
MySQL
Driver: tooz.drivers.mysql.MySQLDriver
Characteristics: tooz.drivers.mysql.MySQLDriver.CHARACTERISTICS
Entrypoint name: mysql
Summary:
The MySQL driver is a driver providing only distributed locks (for now) and is based on the MySQL database server supported get_lock primitives. When a lock is acquired it will release either when explicitly released or automatically when the database session ends (for example if the program using the lock crashes).
Considerations
- Does not work correctly on some MySQL versions.
- Does not work when MySQL replicates from one server to another (locks are local to the server that they were created from).
Etcd
Driver: tooz.drivers.etcd.EtcdDriver
Characteristics: tooz.drivers.etcd.EtcdDriver.CHARACTERISTICS
Entrypoint name: etcd
Summary:
The etcd driver is a driver providing only distributed locks (for now) and is based on the etcd server supported key/value storage and associated primitives.
Etcd3 Gateway
Driver: tooz.drivers.etcd3gw.Etcd3Driver
Characteristics: tooz.drivers.etcd3gw.Etcd3Driver.CHARACTERISTICS
Entrypoint name: etcd3+http
Summary:
The etcd3gw driver is a driver providing only distributed locks (for now) and is based on the etcd server supported key/value storage and associated primitives. It relies on the GRPC Gateway to provide HTTP access to etcd3.
Consul
Driver: tooz.drivers.consul.ConsulDriver
Characteristics:
tooz.drivers.consul.ConsulDriver.CHARACTERISTICS
Entrypoint name: consul
Summary:
The consul driver is a driver providing distributed locking and group membership and is based on the consul server key/value storage and/or primitives. When a lock is acquired it will release either when explicitly released or automatically when the consul session ends (for example if the program using the lock crashes).
Characteristics
- class tooz.coordination.Characteristics(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)
- Attempts to describe the characteristic that a driver supports.
- CAUSAL = 'CAUSAL'
- The driver has the following properties:
- •
- Does not have to enforce the order of every operation from a process, perhaps, only causally related operations must occur in order.
- DISTRIBUTED_ACROSS_HOSTS = 'DISTRIBUTED_ACROSS_HOSTS'
- Coordinator components when used by multiple hosts work the same as if those components were only used by a single thread.
- DISTRIBUTED_ACROSS_PROCESSES = 'DISTRIBUTED_ACROSS_PROCESSES'
- Coordinator components when used by multiple processes work the same as if those components were only used by a single thread.
- DISTRIBUTED_ACROSS_THREADS = 'DISTRIBUTED_ACROSS_THREADS'
- Coordinator components when used by multiple threads work the same as if those components were only used by a single thread.
- LINEARIZABLE = 'LINEARIZABLE'
- The driver has the following properties:
- Ensures each operation must take place before its completion time.
- Any operation invoked subsequently must take place after the invocation and by extension, after the original operation itself.
- NON_TIMEOUT_BASED = 'NON_TIMEOUT_BASED'
- The driver has the following property:
- •
- Its operations are not based on the timeout of other clients, but on some other more robust mechanisms.
- SAME_VIEW_ACROSS_CLIENTS = 'SAME_VIEW_ACROSS_CLIENTS'
- A client connected to one server will always have the same view every other client will have (no matter what server those other clients are connected to). Typically this is a sacrifice in write availability because before a write can be acknowledged it must be acknowledged by all servers in a cluster (so that all clients that are connected to those servers read the exact same thing).
- SAME_VIEW_UNDER_PARTITIONS = 'SAME_VIEW_UNDER_PARTITIONS'
- When a client is connected to a server and that server is partitioned from a group of other servers it will (somehow) have the same view of data as a client connected to a server on the other side of the partition (typically this is accomplished by write availability being lost and therefore nothing can change).
- SEQUENTIAL = 'SEQUENTIAL'
- The driver has the following properties:
- •
- Operations can take effect before or after completion - but all operations retain the constraint that operations from any given process must take place in that processes order.
- SERIALIZABLE = 'SERIALIZABLE'
- The driver has the following properties:
- •
- The history of all operations is equivalent to one that took place in some single atomic order but with unknown invocation and completion times - it places no bounds on time or order.
Compatibility
Grouping
APIs
- watch_join_group()
- unwatch_join_group()
- watch_leave_group()
- unwatch_leave_group()
- create_group()
- get_groups()
- join_group()
- leave_group()
- delete_group()
- get_members()
- get_member_capabilities()
- update_capabilities()
Driver support
| Driver | Supported |
| ConsulDriver | Yes |
| EtcdDriver | Yes |
| FileDriver | Yes |
| IPCDriver | No |
| MemcachedDriver | Yes |
| MySQLDriver | No |
| PostgresDriver | No |
| RedisDriver | Yes |
| ZakeDriver | Yes |
| KazooDriver | Yes |
Leaders
APIs
- watch_elected_as_leader()
- unwatch_elected_as_leader()
- stand_down_group_leader()
- get_leader()
Driver support
| Driver | Supported |
| ConsulDriver | No |
| EtcdDriver | No |
| FileDriver | No |
| IPCDriver | No |
| MemcachedDriver | Yes |
| MySQLDriver | No |
| PostgresDriver | No |
| RedisDriver | Yes |
| ZakeDriver | Yes |
| KazooDriver | Yes |
Locking
APIs
- •
- get_lock()
Driver support
| Driver | Supported |
| ConsulDriver | Yes |
| EtcdDriver | Yes |
| FileDriver | Yes |
| IPCDriver | Yes |
| MemcachedDriver | Yes |
| MySQLDriver | Yes |
| PostgresDriver | Yes |
| RedisDriver | Yes |
| ZakeDriver | Yes |
| KazooDriver | Yes |
CHANGES
6.3.0
- •
- Replace use of testtools.testcase.TestSkipped
6.2.0
- Loose lower bound of packaging library version
- fix: correctly pass ssl_ca_certs to sentinel when enabled
- Add requirements check job
- Remove old excludes
- Define characteristics of etcd/etcd3gw driver
- pre-commit: Bump version, add doc8
- Remove unnecessary dependencies
- Remove use of distutils
6.1.0
- Make authentication/SSL for redis sentinel optional
- reno: Update master for unmaintained/wallaby
- reno: Update master for unmaintained/victoria
6.0.1
- Fix sentinel tests not running
- Fix broken redis sentinel support
6.0.0
- redis: Fix wrong type used to parse socket_keepalive
- redis: support healthcheck interval
- Prevent potential ReDoS attack
- Show coverage report
- Redis: Fix missing ssl/auth options for sentinel
- redis: Fix parsing of sentinel fallbacks containing IPv6 address
- redis: Add username
- Move driver tests to drivers directory
- Bump hacking
- Update python classifier in setup.cfg
- Ignore .eggs directory
- Fix handling of timeout and blocking
5.0.0
- tox: Bump python runtime versions in the default envlist
- Deprecate zake driver because of unmaintained library
- etcd3gw: Discover API version automatically
- Redis: Allow customizing ssl ca certificates path
- Remove etcd3 drvier
- Fix bindep for Debian 12
4.3.0
- Add missing % in diagnostic_lines.append call
- Update the default etcd3gw endpoint to v3
- Replace en-dash with ASCII minus in a docstring
- Cleanup py27 support
4.2.0
- •
- Fix: Add timeout for mysql driver
4.1.0
- •
- Revert "Moves supported python runtimes from version 3.8 to 3.10"
4.0.0
- Fix mysql timeout
- Moves supported python runtimes from version 3.8 to 3.10
- redis: Make socket_connect_timeout configurable
- Accept float values for socket_timeout
- Change StrictRedis usage to Redis
- tox: set allowlist_externals
- Allow to pass ssl-related args for zookeeper
- Loosen protobuf version that's used for docs/renos
- Add grouping support in etcd to compatibility matrix
3.2.0
3.1.0
- Support etcd3gw api version
- remove unicode from code
3.0.0
- Cap protobuf < 4.x
- Fix inappropriate logic in memcachedlock.release()
- [etcd3gw] create new lease if expired
- Drop python3.6/3.7 support in testing runtime
- Enable watch functionality for Etcd3Driver
2.11.1
- •
- Fix getting group with prefix in etcd3gw driver
2.11.0
- Bump tenacity dependency to >= 5.0.0
- Support later tenacity versions
- Update CI to use unversioned jobs template
- Deprecate the etcd3 driver
2.10.1
- Fix docstring for get_members()
- Add TLS support for MySQL driver
2.10.0
- Enable retries in redis driver
- setup.cfg: Replace dashes with underscores
2.9.0
- setup.cfg: Replace dashes with underscores
- Fix formatting of release list
- Move flake8 as a pre-commit local target
- Retry on redis connection errors
- Update master for stable/wallaby
- Cap tenacity to unblock the gate
- Bump hacking and flake8 version to fix pep8 job
- Use py3 as the default runtime for tox
2.8.0
- Replace md5 with oslo version
- Adding pre-commit
- Blacklist etcd3gw 0.2.6
- Add Python3 wallaby unit tests
- Update master for stable/victoria
2.7.1
- •
- Use safe_decode for decoding in zookeeper driver
2.7.0
- Fix breakage with PyMySQL 0.10.0
- hashring: allow choosing hash function
- Remove six library
2.6.0
- •
- Implements Group API for the Consul driver
2.5.1
2.5.0
- Stop to use the __future__ module
- Switch to newer openstackdocstheme and reno versions
- Add python 3.8 to classifiers
2.4.0
- Use unittest.mock instead of third party mock
- Add support for Consul ACL token parameter
- Switch to Victoria tests
- Add nose as test-requirement
- Fix mysql driver comparison operator
- Add release notes links to doc index
- Update master for stable/ussuri
2.3.0
- Add TLS support in etcd3 and etcd3gw drivers
- Drop requirements-check job
- ignore reno generated artifacts
2.2.0
- •
- Adds heartbeating to the consul driver
2.1.0
2.0.0
- •
- [ussuri][goal] Drop python 2.7 support and testing
1.67.2
- •
- RedisLock release() should not check if the lock has been acquired
1.67.1
1.67.0
- Drop os-testr test-requirement and pretty_tox.sh
- Update master for stable/train
- Add shared arg in metaclass Lock
1.66.2
- •
- Fix membership lease issue on the etcd3gw driver
1.66.1
- •
- Fix wrong log level during heartbeat
1.66.0
- Add Python 3 Train unit tests
- Move grpcio from requirements.txt to extras
- Blacklist sphinx 2.1.0
1.65.0
- Move test deps to test-requirements.txt
- Remove unused requirements
- Update Sphinx requirement and uncap grpcio
- Avoid redis lock's expire_time exceeding timeout
- Referencing testenv deps now works
- Update master for stable/stein
- Replace git.openstack.org URLs with opendev.org URLs
- Remove py35, add py37 classifiers
- Unblock tooz gate
- OpenDev Migration Patch
- add python 3.7 unit test job
1.64.2
1.64.1
- •
- Fixed UnicodeEncodeError for Python2 unicode objects
1.64.0
- More explicitly document driver connection strings
- Unblock tooz gate
- Change openstack-dev to openstack-discuss
1.63.1
1.63.0
- coordination: do not retry the whole heartbeat on fail
- Use templates for cover
- Migrate to stestr
- Fix coverage tests
- Switch to autodoc_default_options
- Ensure consistent encoding of strings for ID
- add lib-forward-testing-python3 test job
- add python 3.6 unit test job
- import zuul job settings from project-config
- Update reno for stable/rocky
- Add release note link in README
- fix tox python3 overrides
1.62.0
- Trivial: Update pypi url to new url
- set default python to python3
- Implement group support for etcd3gw
1.61.0
- Zuul: Remove project name
- Zuul: Remove project name
- Update reno for stable/queens
- partitioner: do not use hash() to determine object identity
- msgpack-python has been renamed to msgpack
- Follow the new PTI for document build
- Remove tox_install.sh
- Use native Zuul v3 tox jobs
- Add doc/requirements.txt
- Remove setting of version/release from releasenotes
- Zuul: add file extension to playbook path
- Move legacy jobs to project
1.59.0
- Acquire fails with "ToozError: Not found"
- redis: always remove lock from acquired lock when release()ing
- redis: log an error on release failure
- Use the same default timeout for async result
- Update reno for stable/pike
1.58.0
- Update URLs in documents according to document migration
- doc: use list-table for driver support tables
- rearrange existing documentation to fit the new standard layout
1.57.4
- Switch from oslosphinx to openstackdocstheme
- Turn on warning-is-error in doc build
- Add etcd3 group support
1.57.3
- Make sure Lock.heartbeat() returns True/False
- etcd3: skip ProcessPool based test
- etcd3: replace custom lock code by more recent etcd3 lock code
- pgsql: fix self._conn.close() being called without connection
- test: leverage existing helper method in test_partitioner
- coordination: remove double serialization of capabilities
- tests: fix missing .get() on some group operations
- Mutualize executor code in a mixin class
- coordination: fix reversed fiels for __repr__ for events
- Fix docstring for group and member id
1.57.2
- {my,pg}sql: close connections when out of retry
- Disable test_get_lock_serial_locking_two_lock_process for etcd3
- Simplify env list and test running
- Factorize tox envlist for better readability
1.57.1
- •
- consul: remove unused executor
1.57.0
- Separate etcd3gw driver that uses the etcd3 grpc gateway
- etcd3: use discard() rather than remove()
- etcd: fix blocking argument
- etcd: fix acquire(blocking=True) on request exception
- etcd3: fix test run
- coordination: factorize common async result futures code
1.56.1
- •
- Fix psycopg2 connection argument
1.56.0
- doc: update heartbeat doc to use start_heart=True
- sql: close connection for lock if not used
- http->https for security
- etcd3: add etcd3 coordination driver
1.55.0
- Implement heartbeat for FileDriver
- simplify hashring node lookup
1.54.0
- redis: fix concurrent access on acquire()
- tests: tests fail if no URL is set + run partitioner tests on basic drivers
- tests: fix etcd and consul test run
- add weight tests for add_nodes
- get weight of existing members
- coordination: do not get member list if not needed
- Add shared filelock
1.53.0
- •
- Enhance heartbeat sleep timer
1.52.0
- FileDriver:Support multiple processes
- Switch tests to use latest etcd - 3.1.3
1.51.0
- pass on partitions
- hashring: allow to use bytes as node name
1.50.0
- postgresql: only pass username and password if they are set
- Rewrite heartbeat runner with event
- Adds authentication support for zookeeperDriver
1.49.0
- support unicode node name
- Update reno for stable/ocata
1.48.0
- •
- Fix test function name with two underscores to have only one
1.47.0
- Add partitioner implementation
- Stop making tooz.utils depending on tooz.coordination
- [doc] Note lack of constraints is a choice
- The 'moves.moved_class' function creates a new class
- Add weight support to the hashring
- coordination: allow to pass capabilities in join_group_create()
- coordination: fix moved_class usage for ToozError
- zookeeper: switch to standard group membership watching
- Add a hashring implementation
- Move ToozError to root module
- Fixup concurrent modification
- Replaces uuid.uuid4 with uuidutils.generate_uuid()
1.46.0
- Do not re-set the members cache for watchers by default
- coordination: add __repr__ for join/leave events
- coordination: renforce event based testing
- Factorize member_id in the base coordinator class
- Use the internal group of list rather than listing the groups
- Move the cached-based watcher implementation into its own class
1.45.0
- Factorize group quit on stop()
- coordination: make get_members() return a set
- Replace 'assertTrue(a (not)in b)' with 'assert(Not)In(a, b)'
- Changed author and author-email
- redis: make sure we don't release and heartbeat a lock at the same time
- coordinator: add join_group_create
- Replace retrying with tenacity
- Add CONTRIBUTING.rst
- Replace 'assertTrue(a in b)' with 'assertIn(a, b)' and 'assertFalse(a in b)' with 'assertNotIn(a, b)'
- Using assertIsNone() instead of assertEqual(None, ...)
- tox: use pretty tox output
- tox: install docs dependency in docs target and reno
- Bump hacking to 0.12
- Add reno for release notes management
1.44.0
- Changed the home-page link
- file: update .metadata atomically
- file: return converted voluptuous data
- file: move _load_and_validate to a method
- file: move _read_{group,member}_id to staticmethod-s
- etcd: run tests in clustering mode too
- Use method ensure_tree from oslo.utils
- Switch from Python 3.4 to Python 3.5
- Install only needed packages
- Fix a typo in file.py
- Update etcd version in tests
1.43.0
- •
- Makedirs only throws oserror, so only catch that
1.42.0
- etcd: don't run heartbeat() concurrently
- Raise tooz error when unexpected last entries found
- etcd: properly block when using 'wait'
- Share _get_random_uuid() among all tests
- Updated from global requirements
- Clean leave group hooks when unwatching
- Fix the test test_unwatch_elected_as_leader
- Updated from global requirements
1.41.0
- File driver: properly handle Windows paths
- Updated from global requirements
- Updated from global requirements
1.40.0
- Add docs for new consul driver
- Change dependency to use flavors
- Run doc8 only in pep8 target
- Move pep8 requirements in their own target
- zookeeper: do not hard depend on eventlet
- Remove unused iso8601 dependency
- tests: remove testscenario usage
- file: set no timeout by default
- tests: move bad_url from scenarios to static test
- Expose timeout capabilities and use them for tests
- Use pifpaf to setup daemons
1.39.0
- •
- Updated from global requirements
1.38.0
- Using LOG.warning instead of LOG.warn
- Updated from global requirements
- redis: do not force LuaLock
- Fix coordinator typo
- Updated from global requirements
- Ensure etcd is in developer and driver docs
1.37.0
- Remove unused consul future result
- Updated from global requirements
- Add a consul based driver
- file: make python2 payload readable from python3
1.36.0
- •
- Updated from global requirements
1.35.0
- Drop babel as requirement since its not used
- Updated from global requirements
- Updated from global requirements
- Updated from global requirements
- Updated from global requirements
- coordination: expose a heartbeat loop method
1.34.0
1.33.0
- Updated from global requirements
- Compute requires_beating
- Fix calling acquire(blocking=False) twice leads to a deadlock
1.32.0
- •
- Raises proper error when unwatching a group
1.31.0
- Updated from global requirements
- Updated from global requirements
- Add .tox, *.pyo and *.egg to .gitignore
- Enable OS_LOG_CAPTURE so that logs can be seen (on error)
1.30.0
- Updated from global requirements
- Add lock breaking
- pgsql: fix hostname parsing
- Updated from global requirements
- Updated from global requirements
- Update voluptuous requirement
- Updated from global requirements
- Updated from global requirements
- Have zookeeper heartbeat perform basic get
- Add desired characteristics strict subset validation
- Add base64 key encoder (and validations)
- Use voluptuous instead of jsonschema
- Add programatic introspection of drivers characteristic(s)
- Updated from global requirements
- pep8: fix remaining errors and enable all checks
- Use utils.convert_blocking to convert blocking argument
- Adjust some of the zookeeper exception message
- Fix etcd env setup
- tests: do not hardcode /tmp
- utils: replace exception_message by exception_to_unicode
- Add a default port and default host
- etcd: driver with lock support
- Use utils.to_binary instead of using redis module equivalent
- Remove tested under 2.6 from docs
1.29.0
- Updated from global requirements
- Add basic file content schema validation
- Spice up the driver summary/info page
- Make all locks operate the same when fetched from different coordinators
- Add noted driver weaknesses onto the drivers docs
- Updated from global requirements
- File: read member id from file with suffix ".raw"
- Reduce duplication of code in handling multi-type blocking argument
- Updated from global requirements
- Add comment in memcache explaining the current situation with lock release
1.28.0
- Add 'requires_beating' property to coordination driver
- {pg,my}sql: fix AttributeError on connection failure
- tests: allow ipc to bypass blocking=False test
- pgsql: remove unused left-over code
- Add 'is_still_owner' lock test function
1.27.0
- Updated from global requirements
- Updated from global requirements
- Remove python 2.6 and cleanup tox.ini
1.26.0
- Updated from global requirements
- Allow specifying a kazoo async handler 'kind'
- Updated from global requirements
1.25.0
- Updated from global requirements
- Add standard code coverage configuration file
- docs - Set pbr 'warnerrors' option for doc build
- Include changelog/history in docs
- Updated from global requirements
- Expose Znode Stats and Capabilities
- Allow more kazoo specific client options to be proxied through
1.24.0
- •
- Updated from global requirements
1.23.0
- Changes to add driver list to the documentation
- Updated from global requirements
1.22.0
- Updated from global requirements
- Accept blocking argument in lock's context manager
- Make RedisLock's init consistent with other locks
- Updated from global requirements
1.21.0
- Raise exception on failed lock's CM acquire fail
- Be more restrictive on the executors users can provide
1.20.0
- Updated from global requirements
- Updated from global requirements
- Use futurist to allow for executor providing and unifying
- Use a lua script(s) instead of transactions
1.19.0
- Updated from global requirements
- Change Lock.name to a property
- Update .gitignore
- Updated from global requirements
- Fixup dependencies
- Expose started state of coordinator to external
- Updated from global requirements
- Updated from global requirements
1.18.0
- Remove tooz/openstack as it is empty and not used
- Fix sp 'seonds' -> 'seconds'
- Ensure run_watchers called from mixin, not base class
- Updated from global requirements
- Update compatibility matrix due to file drivers new abilities
0.17.0
- No longer need kazoo lock custom retry code
- Ensure unwatch_elected_as_leader correctly clears hooks
0.16.0
- Updated from global requirements
- Updated from global requirements
- Ensure lock(s) acquire/release returns boolean values
- Expose 'run_elect_coordinator' and call it from 'run_watchers'
- Share most of the `run_watchers` code via a common mixin
- Remove 2.6 classifier
- Remove file-driver special no-async abilities
- Delay interpolating the LOG string
- Use `encodeutils.exception_to_unicode` for exception -> string function
- Use the `excutils.raise_with_cause` after doing our type check
- Updated from global requirements
- Use the 'driver_lock' around read operations
- Updated from global requirements
- Switch badges from 'pypip.in' to 'shields.io'
- Updated from global requirements
- Add watch file driver support
- Make the file driver more capable (with regard to groups)
- Ensure locks can not be created outside of the root file driver directory
- Updated from global requirements
- Use MySQL default port when not set explicitly
- Use fasteners library for interprocess locks
- Implement watch/unwatch elected_as_leader for redis driver
- Updated from global requirements
- Use lua locks instead of pipeline locks
- Move more string constants to class constants with docstrings
- Updated from global requirements
- Updated from global requirements
- Remove support for redis < 2.6.0
- Expose Zookeeper client class constants
- Expose redis client class constants
- Use a serialization/deserialization specific exception
- Expose memcache coord. class constants
- Explicitly start and execute most transactions
- Provide and use a options collapsing function
- Add zookeeper tag in setup.cfg
- Use pymemcache pooled client
- Use oslo.serialization msgpackutils
- Provide ability for namespace customization for Zookeeper and Zake drivers
- Typo in Locking doc
- Move optional driver requirements to test-requirements.txt
- Have run_watchers take a timeout and respect it
- Heartbeat on acquired locks copy
- Avoid using a thread local token storage
0.15.0
- Fix param name to be its right name
- Replace more instance(s) of exception chaining with helper
- Just use staticmethod functions to create _dumps/_loads
- Uncap library requirements for liberty
- Link AOF to redis persistence docs
- Add exception docs to developer docs
- Add + use helper to raise + chain exceptions
- Allow the acquired file to be closed manually
- Updated from global requirements
- Silence logs + errors when stopping and group membership lost
- Make and use a thread safe pymemcache client subclass
- Handle errors that come out of pymemcache better
- Use rst inline code structure + link to sentinel
0.14.0
- Beef up the docstrings on the various drivers
- fix lock concurrency issues with certain drivers
- Add pypi download + version badges
- Denote that 2.6 testing is still happening
- Updated from global requirements
- Use a sentinel connection pool to manage failover
- fix mysql driver url parsing
0.13.1
- Switch to non-namespaced module imports
- Add a driver feature compatibility matrix
- Remove support for 3.3
0.13.0
- Two locks acquired from one coord must works
- Updated from global requirements
- Releases locks in tests
- Allow coordinator non-string options and use them
- Since we use msgpack this can be more than a str
- Updated from global requirements
- Avoid re-using the same timeout for further watcher ops
0.12
- retry: fix decorator
- file: fix typo in errno.EACCES
0.11
- Add a file based driver
- Upgrade to hacking 0.10
- Update sentinel support to allow multiple sentinel hosts
- Allow to pass arguments to retry()
- IPC simplification
0.10
- Add support for an optional redis-sentinel
- README.rst tweaks
- A few more documentation tweaks
- Sync requirements to global requirements
- Add create/join/leave group support in IPC driver
- Add driver autogenerated docs
- Update links + python version supported
- zookeeper: add support for delete group
- redis: add support for group deletion
- tests: minor code simplification
- memcached: add support for group deletion
- memcached: add support for _destroy_group
- Switch to using oslosphinx
- Add doc on how transaction is itself retrying internally
- Fix .gitreview after rename/transfer
- tests: use scenarios attributes for timeout capability
- tests: check for leave group events on dead members cleanup
- memcached: delete stale/dead group members on get_members()
- tests: remove check_port
- tests: do not skip test on connection error
0.9
- doc: add missing new drivers
- doc: switch examples to Zake
- doc: add locking
- Fix tox envlist
- Drop Python 3.3 tests in tox
- Allow tox with py34 and MySQL
- Test connection error scenarios on more drivers
- Translate psycopg2 errors/exceptions into tooz exceptions
- Ensure 'leave_group' result gotten before further work
- watch_leave_group not triggering callback on expired members
- Add MySQL driver
- Discard 'self' from '_joined_groups' if we got booted out
- Implement non-blocking locks with PostgreSQL
- More retry code out of memcached
- Add a PostgreSQL driver
- Fix gate
- Handle when a group used to exist but no longer does
- tox: split redis/memcached env
- Fix memcached heartbeat on start()
- tox: splits test scenarios
- Add a minimum redis version check while starting
- Make requirement on redis 2.10.x explicit
- Try to use PSETEX when possible
- Use hdel with many keys where supported
- Avoid logging warnings when group deleted or member gone
- Ensure that we correctly expire (and cleanup) redis members
- Various fixes for locks and version compatibility
- Move sysv_ipc deps to test-requirements
0.8
- test: try to stop() first
- Convert the rest of memcached driver functions to futures
- Add a assertRaisesAny helper method
- Allow zake to be tested
- Add a redis driver
- Ensure groups leaving returns are gotten
- Raise the new OperationTimedOut when futures don't finish
- Start to add a catch and reraise of timed out exceptions
- Adjust the timeout to reflect the repeated retries
- ipc: do not delete the lock if we never acquired it
- Add home-page field
0.7
- Split up the requirements for py2.x and py3.x
- ipc: Fix acquire lock loop logic
0.6
- •
- Make lock blocking with no time out by default
0.5
- coordination: remove destroy() from the lock protocol
- IPC: fix a potential race condition at init
- Fix IPC driver on OS X
- Switch to oslo.utils
- Blacklist retrying 1.3.0
- Use futures to make parts of the memcached driver async
- Have examples run in the py27 environment and make them work
0.4
- Standardize the async result subclasses
- Fix the comment which was borrowed from the IPC driver
- Be more tolerant of unicode exceptions
- Standardize on the same lock acquire method definition
- Standardize on hiding the lock implementation
- On lock removal validate that they key was actually deleted
- Use a thread safe deque instead of a queue
- Change inline docs about class fake storage variable
- LOG a warning if the heartbeat can not be validated
- Add doc8 to the py27 test running
- Use the more reliable sysv_ipc instead of posix_ipc+lockutils
- Only start zookeeper/memcached when not already running
- Let zake act as a in-memory fully functional driver
- Switch to a custom NotImplemented error
- Ensure lock list isn't mutated while iterating
- Move Zake driver code to separated Python module
- Work toward Python 3.4 support and testing
- Unlock the kazoo version
- Bump up zake to be using the newer 0.1 or greater
- Fix zake driver with latest release
- memcached: switch leader election implementation to a lock
- Add the generation of the documentation in tox.ini
- Add coverage report
0.3
- Switch to URL for loading backends
- Import network_utils from Oslo
- coordination: add IPC driver
- coordination: raise NotImplementedError as default
- Add documentation
- Upgrade hacking requirement
- memcached: use retrying rather than sleeping
- Use retrying instead of our custom code
- Update requirements file matching global requ
0.2
- memcached: implement leader election
- Fix a race condition in one of the test
0.1
- memcached: add locking
- coordination: implement lock mechanism in ZK
- coordination, zookeeper: add get_leader()
- coordination, zookeeper: implement leader election
- coordination: remove wrong comment in tests
- memcached: add support for leave events
- memcached: implement {un,}watch_join_group()
- coordination: raise GroupNotCreated when watching uncreated group
- coordination, zookeeper: add {un,}watch_leave_group
- coordination, zookeeper: add watch_join_group
- tests: skip test if function is not implemented
- coordination: add hooks system
- Add memcached driver
- zookeeper: use bytes as input/output type
- tests: test client disconnection
- coordination: add heartbeat method
- Add pbr generated and testr files to gitignore
- coordination: enhance MemberAlreadyExist exception
- coordination: enhance GroupNotCreated exception
- coordination: enhance MemberNotJoined
- coordination: enhance GroupAlreadyExist exception
- tests: test capabilities on non existent group/member
- tests: add a test for group already existing
- tests: fix variable name
- Fix the default prototype for join_group
- Adds basic tests which deals with exceptions
- Fixes TypeError in _leave_group_handler
- Remove _wrap_call_kazoo
- Add asynchronous API
- Delete models.py and clean get_members()
- Add a fake ZooKeeper driver
- Allow passing in a handler
- First commit of Tooz
- Added .gitreview
Module Reference
Interfaces
- class tooz.coordination.CoordinationDriver(member_id, parsed_url, options)
- CHARACTERISTICS = ()
- Tuple of Characteristics introspectable enum member(s) that can be used to interogate how this driver works.
- __init__(member_id, parsed_url, options)
- __weakref__
- list of weak references to the object
- static create_group(group_id)
- Request the creation of a group asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group to create
- Returns
- None
- Return type
- CoordAsyncResult
- static delete_group(group_id)
- Delete a group asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group to leave
- Returns
- Result
- Return type
- CoordAsyncResult
- static get_groups()
- Return the list composed by all groups ids asynchronously.
- Returns
- the list of all created group ids
- Return type
- CoordAsyncResult
- static get_leader(group_id)
- Return the leader for a group.
- Parameters
- group_id -- the id of the group:
- Returns
- the leader
- Return type
- CoordAsyncResult
- static get_lock(name)
- Return a distributed lock.
This is a exclusive lock, a second call to acquire() will block or return False.
- Parameters
- name -- The lock name that is used to identify it across all nodes.
- static get_member_capabilities(group_id, member_id)
- Return the capabilities of a member asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group of the member
- member_id (ascii bytes) -- the id of the member
- Returns
- capabilities of a member
- Return type
- CoordAsyncResult
- static get_member_info(group_id, member_id)
- Return the statistics and capabilities of a member asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group of the member
- member_id (ascii bytes) -- the id of the member
- Returns
- capabilities and statistics of a member
- Return type
- CoordAsyncResult
- static get_members(group_id)
- Return the set of all member ids of a group asynchronously.
- Returns
- set of all member ids in the specified group
- Return type
- CoordAsyncResult
- static heartbeat()
- Update member status to indicate it is still alive.
Method to run once in a while to be sure that the member is not dead and is still an active member of a group.
- Returns
- The number of seconds to wait before sending a new heartbeat.
- static join_group(group_id, capabilities=b'')
- Join a group and establish group membership asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group to join
- capabilities (object) -- the capabilities of the joined member
- Returns
- None
- Return type
- CoordAsyncResult
- join_group_create(group_id, capabilities=b'')
- Join a group and create it if necessary.
If the group cannot be joined because it does not exist, it is created before being joined.
This function will keep retrying until it can create the group and join it. Since nothing is transactional, it may have to retry several times if another member is creating/deleting the group at the same time.
- Parameters
- group_id -- Identifier of the group to join and create
- capabilities -- the capabilities of the joined member
- join_partitioned_group(group_id, weight=1, partitions=32)
- Join a group and get a partitioner.
A partitioner allows to distribute a bunch of objects across several members using a consistent hash ring. Each object gets assigned (at least) one member responsible for it. It's then possible to check which object is owned by any member of the group.
This method also creates if necessary, and joins the group with the selected weight.
- Parameters
- group_id -- The group to create a partitioner for.
- weight -- The weight to use in the hashring for this node.
- partitions -- The number of partitions to create.
- Returns
- A Partitioner object.
- static leave_group(group_id)
- Leave a group asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group to leave
- Returns
- None
- Return type
- CoordAsyncResult
- leave_partitioned_group(partitioner)
- Leave a partitioned group.
This leaves the partitioned group and stop the partitioner. :param group_id: The group to create a partitioner for.
- requires_beating = False
- Usage requirement that if true requires that the heartbeat() be called periodically (at a given rate) to avoid locks, sessions and other from being automatically closed/discarded by the coordinators backing store.
- static run_elect_coordinator()
- Try to leader elect this coordinator & activate hooks on success.
- static run_watchers(timeout=None)
- Run the watchers callback.
This may also activate run_elect_coordinator() (depending on driver implementation).
- static stand_down_group_leader(group_id)
- Stand down as the group leader if we are.
- Parameters
- group_id -- The group where we don't want to be a leader anymore
- start(start_heart=False)
- Start the service engine.
If needed, the establishment of a connection to the servers is initiated.
- stop()
- Stop the service engine.
If needed, the connection to servers is closed and the client will disappear from all joined groups.
- unwatch_elected_as_leader(group_id, callback)
- Call a function when member gets elected as leader.
The callback functions will be executed when run_watchers is called.
- Parameters
- group_id -- The group id to watch
- callback -- The function to execute when a member leaves this group
- unwatch_join_group(group_id, callback)
- Stop executing a function when a group_id sees a new member joined.
- Parameters
- group_id -- The group id to unwatch
- callback -- The function that was executed when a member joined this group
- unwatch_leave_group(group_id, callback)
- Stop executing a function when a group_id sees a new member leaving.
- Parameters
- group_id -- The group id to unwatch
- callback -- The function that was executed when a member left this group
- static update_capabilities(group_id, capabilities)
- Update member capabilities in the specified group.
- Parameters
- group_id (ascii bytes) -- the id of the group of the current member
- capabilities (object) -- the capabilities of the updated member
- Returns
- None
- Return type
- CoordAsyncResult
- watch_elected_as_leader(group_id, callback)
- Call a function when member gets elected as leader.
The callback functions will be executed when run_watchers is called.
- Parameters
- group_id -- The group id to watch
- callback -- The function to execute when a member leaves this group
- watch_join_group(group_id, callback)
- Call a function when group_id sees a new member joined.
The callback functions will be executed when run_watchers is called.
- Parameters
- group_id -- The group id to watch
- callback -- The function to execute when a member joins this group
- watch_leave_group(group_id, callback)
- Call a function when group_id sees a new member leaving.
The callback functions will be executed when run_watchers is called.
- Parameters
- group_id -- The group id to watch
- callback -- The function to execute when a member leaves this group
Consul
Etcd
- class tooz.drivers.etcd.EtcdDriver(member_id, parsed_url, options)
- An etcd based driver.
This driver uses etcd provide the coordination driver semantics and required API(s).
The Etcd driver connection URI should look like:
etcd://[HOST[:PORT]][?OPTION1=VALUE1[&OPTION2=VALUE2[&...]]]
If not specified, HOST defaults to localhost and PORT defaults to 2379. Available options are:
| Name | Default |
| protocol | http |
| timeout | 30 |
| lock_timeout | 30 |
- CHARACTERISTICS = (Characteristics.NON_TIMEOUT_BASED, Characteristics.DISTRIBUTED_ACROSS_THREADS, Characteristics.DISTRIBUTED_ACROSS_PROCESSES, Characteristics.LINEARIZABLE, Characteristics.SERIALIZABLE)
- Tuple of Characteristics introspectable enum member(s) that can be used to interogate how this driver works.
- DEFAULT_HOST = 'localhost'
- Default hostname used when none is provided.
- DEFAULT_PORT = 2379
- Default port used if none provided (4001 or 2379 are the common ones).
- DEFAULT_TIMEOUT = 30
- Default socket/lock/member/leader timeout used when none is provided.
- __init__(member_id, parsed_url, options)
- get_lock(name)
- Return a distributed lock.
This is a exclusive lock, a second call to acquire() will block or return False.
- Parameters
- name -- The lock name that is used to identify it across all nodes.
- heartbeat()
- Update member status to indicate it is still alive.
Method to run once in a while to be sure that the member is not dead and is still an active member of a group.
- Returns
- The number of seconds to wait before sending a new heartbeat.
- lock_encoder_cls
- Class that will be used to encode lock names into a valid etcd url.
alias of Base64LockEncoder
- unwatch_join_group(group_id, callback)
- Stop executing a function when a group_id sees a new member joined.
- Parameters
- group_id -- The group id to unwatch
- callback -- The function that was executed when a member joined this group
- unwatch_leave_group(group_id, callback)
- Stop executing a function when a group_id sees a new member leaving.
- Parameters
- group_id -- The group id to unwatch
- callback -- The function that was executed when a member left this group
- watch_join_group(group_id, callback)
- Call a function when group_id sees a new member joined.
The callback functions will be executed when run_watchers is called.
- Parameters
- group_id -- The group id to watch
- callback -- The function to execute when a member joins this group
- watch_leave_group(group_id, callback)
- Call a function when group_id sees a new member leaving.
The callback functions will be executed when run_watchers is called.
- Parameters
- group_id -- The group id to watch
- callback -- The function to execute when a member leaves this group
Etcd3gw
- class tooz.drivers.etcd3gw.Etcd3Driver(member_id, parsed_url, options)
- An etcd based driver.
This driver uses etcd provide the coordination driver semantics and required API(s).
The Etcd driver connection URI should look like:
etcd3+PROTOCOL://[HOST[:PORT]][?OPTION1=VALUE1[&OPTION2=VALUE2[&...]]]
The PROTOCOL can be http or https. If not specified, HOST defaults to localhost and PORT defaults to 2379. Available options are:
| Name | Default |
| api_version | None |
| ca_cert | None |
| cert_key | None |
| cert_cert | None |
| timeout | 30 |
| lock_timeout | 30 |
| membership_timeout | 30 |
- CHARACTERISTICS = (Characteristics.NON_TIMEOUT_BASED, Characteristics.DISTRIBUTED_ACROSS_THREADS, Characteristics.DISTRIBUTED_ACROSS_PROCESSES, Characteristics.LINEARIZABLE, Characteristics.SERIALIZABLE)
- Tuple of Characteristics introspectable enum member(s) that can be used to interogate how this driver works.
- DEFAULT_HOST = 'localhost'
- Default hostname used when none is provided.
- DEFAULT_PORT = 2379
- Default port used if none provided (4001 or 2379 are the common ones).
- DEFAULT_TIMEOUT = 30
- Default socket/lock/member/leader timeout used when none is provided.
- __init__(member_id, parsed_url, options)
- create_group(group_id)
- Request the creation of a group asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group to create
- Returns
- None
- Return type
- CoordAsyncResult
- delete_group(group_id)
- Delete a group asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group to leave
- Returns
- Result
- Return type
- CoordAsyncResult
- get_groups()
- Return the list composed by all groups ids asynchronously.
- Returns
- the list of all created group ids
- Return type
- CoordAsyncResult
- get_lock(name)
- Return a distributed lock.
This is a exclusive lock, a second call to acquire() will block or return False.
- Parameters
- name -- The lock name that is used to identify it across all nodes.
- get_member_capabilities(group_id, member_id)
- Return the capabilities of a member asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group of the member
- member_id (ascii bytes) -- the id of the member
- Returns
- capabilities of a member
- Return type
- CoordAsyncResult
- get_members(group_id)
- Return the set of all member ids of a group asynchronously.
- Returns
- set of all member ids in the specified group
- Return type
- CoordAsyncResult
- heartbeat()
- Update member status to indicate it is still alive.
Method to run once in a while to be sure that the member is not dead and is still an active member of a group.
- Returns
- The number of seconds to wait before sending a new heartbeat.
- join_group(group_id, capabilities=b'')
- Join a group and establish group membership asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group to join
- capabilities (object) -- the capabilities of the joined member
- Returns
- None
- Return type
- CoordAsyncResult
- leave_group(group_id)
- Leave a group asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group to leave
- Returns
- None
- Return type
- CoordAsyncResult
- static unwatch_elected_as_leader(group_id, callback)
- Call a function when member gets elected as leader.
The callback functions will be executed when run_watchers is called.
- Parameters
- group_id -- The group id to watch
- callback -- The function to execute when a member leaves this group
- update_capabilities(group_id, capabilities)
- Update member capabilities in the specified group.
- Parameters
- group_id (ascii bytes) -- the id of the group of the current member
- capabilities (object) -- the capabilities of the updated member
- Returns
- None
- Return type
- CoordAsyncResult
- static watch_elected_as_leader(group_id, callback)
- Call a function when member gets elected as leader.
The callback functions will be executed when run_watchers is called.
- Parameters
- group_id -- The group id to watch
- callback -- The function to execute when a member leaves this group
File
- class tooz.drivers.file.FileDriver(member_id, parsed_url, options)
- A file based driver.
This driver uses files and directories (and associated file locks) to provide the coordination driver semantics and required API(s). It is missing some functionality but in the future these not implemented API(s) will be filled in.
The File driver connection URI should look like:
file://DIRECTORY[?timeout=TIMEOUT]
DIRECTORY is the location that should be used to store lock files. TIMEOUT defaults to 10.
General recommendations/usage considerations:
- It does not automatically delete members from groups of processes that have died, manual cleanup will be needed for those types of failures.
- It is not distributed (or recommended to be used in those situations, so the developer using this should really take that into account when applying this driver in there app).
- CHARACTERISTICS = (Characteristics.NON_TIMEOUT_BASED, Characteristics.DISTRIBUTED_ACROSS_THREADS, Characteristics.DISTRIBUTED_ACROSS_PROCESSES)
- Tuple of Characteristics introspectable enum member(s) that can be used to interogate how this driver works.
- HASH_ROUTINE = 'sha1'
- This routine is used to hash a member (or group) id into a filesystem safe name that can be used for member lookup and group joining.
- __init__(member_id, parsed_url, options)
- Initialize the file driver.
- create_group(group_id)
- Request the creation of a group asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group to create
- Returns
- None
- Return type
- CoordAsyncResult
- delete_group(group_id)
- Delete a group asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group to leave
- Returns
- Result
- Return type
- CoordAsyncResult
- get_groups()
- Return the list composed by all groups ids asynchronously.
- Returns
- the list of all created group ids
- Return type
- CoordAsyncResult
- get_lock(name)
- Return a distributed lock.
This is a exclusive lock, a second call to acquire() will block or return False.
- Parameters
- name -- The lock name that is used to identify it across all nodes.
- get_member_capabilities(group_id, member_id)
- Return the capabilities of a member asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group of the member
- member_id (ascii bytes) -- the id of the member
- Returns
- capabilities of a member
- Return type
- CoordAsyncResult
- get_members(group_id)
- Return the set of all member ids of a group asynchronously.
- Returns
- set of all member ids in the specified group
- Return type
- CoordAsyncResult
- heartbeat()
- Update member status to indicate it is still alive.
Method to run once in a while to be sure that the member is not dead and is still an active member of a group.
- Returns
- The number of seconds to wait before sending a new heartbeat.
- join_group(group_id, capabilities=b'')
- Join a group and establish group membership asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group to join
- capabilities (object) -- the capabilities of the joined member
- Returns
- None
- Return type
- CoordAsyncResult
- leave_group(group_id)
- Leave a group asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group to leave
- Returns
- None
- Return type
- CoordAsyncResult
- static unwatch_elected_as_leader(group_id, callback)
- Call a function when member gets elected as leader.
The callback functions will be executed when run_watchers is called.
- Parameters
- group_id -- The group id to watch
- callback -- The function to execute when a member leaves this group
- static watch_elected_as_leader(group_id, callback)
- Call a function when member gets elected as leader.
The callback functions will be executed when run_watchers is called.
- Parameters
- group_id -- The group id to watch
- callback -- The function to execute when a member leaves this group
IPC
- class tooz.drivers.ipc.IPCDriver(member_id, parsed_url, options)
- A IPC based driver.
This driver uses IPC concepts to provide the coordination driver semantics and required API(s). It is missing some functionality but in the future these not implemented API(s) will be filled in.
The IPC driver connection URI should look like:
ipc://
General recommendations/usage considerations:
- •
- It is not distributed (or recommended to be used in those situations, so the developer using this should really take that into account when applying this driver in there app).
- CHARACTERISTICS = (Characteristics.NON_TIMEOUT_BASED, Characteristics.DISTRIBUTED_ACROSS_THREADS, Characteristics.DISTRIBUTED_ACROSS_PROCESSES)
- Tuple of Characteristics introspectable enum member(s) that can be used to interogate how this driver works.
- create_group(group_id)
- Request the creation of a group asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group to create
- Returns
- None
- Return type
- CoordAsyncResult
- delete_group(group_id)
- Delete a group asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group to leave
- Returns
- Result
- Return type
- CoordAsyncResult
- get_groups()
- Return the list composed by all groups ids asynchronously.
- Returns
- the list of all created group ids
- Return type
- CoordAsyncResult
- static get_lock(name)
- Return a distributed lock.
This is a exclusive lock, a second call to acquire() will block or return False.
- Parameters
- name -- The lock name that is used to identify it across all nodes.
- watch_join_group(group_id, callback)
- Call a function when group_id sees a new member joined.
The callback functions will be executed when run_watchers is called.
- Parameters
- group_id -- The group id to watch
- callback -- The function to execute when a member joins this group
- watch_leave_group(group_id, callback)
- Call a function when group_id sees a new member leaving.
The callback functions will be executed when run_watchers is called.
- Parameters
- group_id -- The group id to watch
- callback -- The function to execute when a member leaves this group
Memcached
- class tooz.drivers.memcached.MemcachedDriver(member_id, parsed_url, options)
- A memcached based driver.
This driver users memcached concepts to provide the coordination driver semantics and required API(s). It is fully functional and implements all of the coordination driver API(s). It stores data into memcache using expiries and msgpack encoded values.
The Memcached driver connection URI should look like:
memcached://[HOST[:PORT]][?OPTION1=VALUE1[&OPTION2=VALUE2[&...]]]
If not specified, HOST defaults to localhost and PORT defaults to 11211. Available options are:
| Name | Default |
| timeout | 30 |
| membership_timeout | 30 |
| lock_timeout | 30 |
| leader_timeout | 30 |
| max_pool_size | None |
General recommendations/usage considerations:
- •
- Memcache (without different backend technology) is a cache enough said.
- CHARACTERISTICS = (Characteristics.DISTRIBUTED_ACROSS_THREADS, Characteristics.DISTRIBUTED_ACROSS_PROCESSES, Characteristics.DISTRIBUTED_ACROSS_HOSTS, Characteristics.CAUSAL)
- Tuple of Characteristics introspectable enum member(s) that can be used to interogate how this driver works.
- DEFAULT_TIMEOUT = 30
- Default socket/lock/member/leader timeout used when none is provided.
- GROUP_LEADER_PREFIX = b'_TOOZ_GROUP_LEADER_'
- Key prefix attached to leaders of groups (used in name-spacing keys)
- GROUP_LIST_KEY = b'_TOOZ_GROUP_LIST'
- Key where all groups 'known' are stored.
- GROUP_PREFIX = b'_TOOZ_GROUP_'
- Key prefix attached to groups (used in name-spacing keys)
- MEMBER_PREFIX = b'_TOOZ_MEMBER_'
- Key prefix attached to members of groups (used in name-spacing keys)
- STILL_ALIVE = b"It's alive!"
- String used to keep a key/member alive (until it next expires).
- __init__(member_id, parsed_url, options)
- create_group(group_id)
- Request the creation of a group asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group to create
- Returns
- None
- Return type
- CoordAsyncResult
- delete_group(group_id)
- Delete a group asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group to leave
- Returns
- Result
- Return type
- CoordAsyncResult
- get_groups()
- Return the list composed by all groups ids asynchronously.
- Returns
- the list of all created group ids
- Return type
- CoordAsyncResult
- get_leader(group_id)
- Return the leader for a group.
- Parameters
- group_id -- the id of the group:
- Returns
- the leader
- Return type
- CoordAsyncResult
- get_lock(name)
- Return a distributed lock.
This is a exclusive lock, a second call to acquire() will block or return False.
- Parameters
- name -- The lock name that is used to identify it across all nodes.
- get_member_capabilities(group_id, member_id)
- Return the capabilities of a member asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group of the member
- member_id (ascii bytes) -- the id of the member
- Returns
- capabilities of a member
- Return type
- CoordAsyncResult
- get_members(group_id)
- Return the set of all member ids of a group asynchronously.
- Returns
- set of all member ids in the specified group
- Return type
- CoordAsyncResult
- heartbeat()
- Update member status to indicate it is still alive.
Method to run once in a while to be sure that the member is not dead and is still an active member of a group.
- Returns
- The number of seconds to wait before sending a new heartbeat.
- join_group(group_id, capabilities=b'')
- Join a group and establish group membership asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group to join
- capabilities (object) -- the capabilities of the joined member
- Returns
- None
- Return type
- CoordAsyncResult
- leave_group(group_id)
- Leave a group asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group to leave
- Returns
- None
- Return type
- CoordAsyncResult
- run_elect_coordinator()
- Try to leader elect this coordinator & activate hooks on success.
- run_watchers(timeout=None)
- Run the watchers callback.
This may also activate run_elect_coordinator() (depending on driver implementation).
- update_capabilities(group_id, capabilities)
- Update member capabilities in the specified group.
- Parameters
- group_id (ascii bytes) -- the id of the group of the current member
- capabilities (object) -- the capabilities of the updated member
- Returns
- None
- Return type
- CoordAsyncResult
Mysql
- class tooz.drivers.mysql.MySQLDriver(member_id, parsed_url, options)
- A MySQL based driver.
This driver users MySQL database tables to provide the coordination driver semantics and required API(s). It is missing some functionality but in the future these not implemented API(s) will be filled in.
The MySQL driver connection URI should look like:
mysql://USERNAME:PASSWORD@HOST[:PORT]/DBNAME[?OPTION1=VALUE1[&OPTION2=VALUE2[&...]]]
If not specified, PORT defaults to 3306. Available options are:
| Name | Default |
| ssl_ca | None |
| ssl_capath | None |
| ssl_cert | None |
| ssl_key | None |
| ssl_cipher | None |
| ssl_verify_mode | None |
| ssl_check_hostname | True |
| unix_socket | None |
- CHARACTERISTICS = (Characteristics.NON_TIMEOUT_BASED, Characteristics.DISTRIBUTED_ACROSS_THREADS, Characteristics.DISTRIBUTED_ACROSS_PROCESSES, Characteristics.DISTRIBUTED_ACROSS_HOSTS)
- Tuple of Characteristics introspectable enum member(s) that can be used to interogate how this driver works.
- __init__(member_id, parsed_url, options)
- Initialize the MySQL driver.
- get_lock(name)
- Return a distributed lock.
This is a exclusive lock, a second call to acquire() will block or return False.
- Parameters
- name -- The lock name that is used to identify it across all nodes.
- static unwatch_elected_as_leader(group_id, callback)
- Call a function when member gets elected as leader.
The callback functions will be executed when run_watchers is called.
- Parameters
- group_id -- The group id to watch
- callback -- The function to execute when a member leaves this group
- static unwatch_join_group(group_id, callback)
- Stop executing a function when a group_id sees a new member joined.
- Parameters
- group_id -- The group id to unwatch
- callback -- The function that was executed when a member joined this group
- static unwatch_leave_group(group_id, callback)
- Stop executing a function when a group_id sees a new member leaving.
- Parameters
- group_id -- The group id to unwatch
- callback -- The function that was executed when a member left this group
- static watch_elected_as_leader(group_id, callback)
- Call a function when member gets elected as leader.
The callback functions will be executed when run_watchers is called.
- Parameters
- group_id -- The group id to watch
- callback -- The function to execute when a member leaves this group
- static watch_join_group(group_id, callback)
- Call a function when group_id sees a new member joined.
The callback functions will be executed when run_watchers is called.
- Parameters
- group_id -- The group id to watch
- callback -- The function to execute when a member joins this group
- static watch_leave_group(group_id, callback)
- Call a function when group_id sees a new member leaving.
The callback functions will be executed when run_watchers is called.
- Parameters
- group_id -- The group id to watch
- callback -- The function to execute when a member leaves this group
PostgreSQL
- class tooz.drivers.pgsql.PostgresDriver(member_id, parsed_url, options)
- A PostgreSQL based driver.
This driver users PostgreSQL database tables to provide the coordination driver semantics and required API(s). It is missing some functionality but in the future these not implemented API(s) will be filled in.
The PostgreSQL driver connection URI should look like:
postgresql://[USERNAME[:PASSWORD]@]HOST:PORT?dbname=DBNAME
- CHARACTERISTICS = (Characteristics.NON_TIMEOUT_BASED, Characteristics.DISTRIBUTED_ACROSS_THREADS, Characteristics.DISTRIBUTED_ACROSS_PROCESSES, Characteristics.DISTRIBUTED_ACROSS_HOSTS)
- Tuple of Characteristics introspectable enum member(s) that can be used to interogate how this driver works.
- __init__(member_id, parsed_url, options)
- Initialize the PostgreSQL driver.
- get_lock(name)
- Return a distributed lock.
This is a exclusive lock, a second call to acquire() will block or return False.
- Parameters
- name -- The lock name that is used to identify it across all nodes.
- static unwatch_elected_as_leader(group_id, callback)
- Call a function when member gets elected as leader.
The callback functions will be executed when run_watchers is called.
- Parameters
- group_id -- The group id to watch
- callback -- The function to execute when a member leaves this group
- static unwatch_join_group(group_id, callback)
- Stop executing a function when a group_id sees a new member joined.
- Parameters
- group_id -- The group id to unwatch
- callback -- The function that was executed when a member joined this group
- static unwatch_leave_group(group_id, callback)
- Stop executing a function when a group_id sees a new member leaving.
- Parameters
- group_id -- The group id to unwatch
- callback -- The function that was executed when a member left this group
- static watch_elected_as_leader(group_id, callback)
- Call a function when member gets elected as leader.
The callback functions will be executed when run_watchers is called.
- Parameters
- group_id -- The group id to watch
- callback -- The function to execute when a member leaves this group
- static watch_join_group(group_id, callback)
- Call a function when group_id sees a new member joined.
The callback functions will be executed when run_watchers is called.
- Parameters
- group_id -- The group id to watch
- callback -- The function to execute when a member joins this group
- static watch_leave_group(group_id, callback)
- Call a function when group_id sees a new member leaving.
The callback functions will be executed when run_watchers is called.
- Parameters
- group_id -- The group id to watch
- callback -- The function to execute when a member leaves this group
Redis
Zake
- class tooz.drivers.zake.ZakeDriver(member_id, parsed_url, options)
- This driver uses the zake client to mimic real zookeeper
servers.
It should be mainly used (and is really only intended to be used in this manner) for testing and integration (where real zookeeper servers are typically not available).
- CHARACTERISTICS = (Characteristics.NON_TIMEOUT_BASED, Characteristics.DISTRIBUTED_ACROSS_THREADS)
- Tuple of Characteristics introspectable enum member(s) that can be used to interogate how this driver works.
- __init__(member_id, parsed_url, options)
Zookeeper
- class tooz.drivers.zookeeper.KazooDriver(member_id, parsed_url, options)
- This driver uses the kazoo client against real zookeeper
servers.
It is fully functional and implements all of the coordination driver API(s). It stores data into zookeeper using znodes and msgpack encoded values.
To configure the client to your liking a subset of the options defined at http://kazoo.readthedocs.org/en/latest/api/client.html will be extracted from the coordinator url (or any provided options), so that a specific coordinator can be created that will work for you.
The Zookeeper coordinator url should look like:
zookeeper://[USERNAME:PASSWORD@][HOST[:PORT]][?OPTION1=VALUE1[&OPTION2=VALUE2[&...]]]
Currently the following options will be proxied to the contained client:
| Name | Source | Default |
| ca | 'ca' options key | None |
| certfile | 'certfile' options key | None |
| connection_retry | 'connection_retry' options key | None |
| command_retry | 'command_retry' options key | None |
| hosts | url netloc + 'hosts' option key | localhost:2181 |
| keyfile | 'keyfile' options key | None |
| keyfile_password | 'keyfile_password' options key | None |
| randomize_hosts | 'randomize_hosts' options key | True |
| timeout | 'timeout' options key | 10.0 (kazoo default) |
| use_ssl | 'use_ssl' options key | False |
| verify_certs | 'verify_certs' options key | True |
- CHARACTERISTICS = (Characteristics.NON_TIMEOUT_BASED, Characteristics.DISTRIBUTED_ACROSS_THREADS, Characteristics.DISTRIBUTED_ACROSS_PROCESSES, Characteristics.DISTRIBUTED_ACROSS_HOSTS, Characteristics.SEQUENTIAL)
- Tuple of Characteristics introspectable enum member(s) that can be used to interogate how this driver works.
- TOOZ_NAMESPACE = b'tooz'
- Default namespace when none is provided.
- __init__(member_id, parsed_url, options)
- create_group(group_id)
- Request the creation of a group asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group to create
- Returns
- None
- Return type
- CoordAsyncResult
- delete_group(group_id)
- Delete a group asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group to leave
- Returns
- Result
- Return type
- CoordAsyncResult
- get_groups()
- Return the list composed by all groups ids asynchronously.
- Returns
- the list of all created group ids
- Return type
- CoordAsyncResult
- get_leader(group_id)
- Return the leader for a group.
- Parameters
- group_id -- the id of the group:
- Returns
- the leader
- Return type
- CoordAsyncResult
- get_lock(name)
- Return a distributed lock.
This is a exclusive lock, a second call to acquire() will block or return False.
- Parameters
- name -- The lock name that is used to identify it across all nodes.
- get_member_capabilities(group_id, member_id)
- Return the capabilities of a member asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group of the member
- member_id (ascii bytes) -- the id of the member
- Returns
- capabilities of a member
- Return type
- CoordAsyncResult
- get_member_info(group_id, member_id)
- Return the statistics and capabilities of a member asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group of the member
- member_id (ascii bytes) -- the id of the member
- Returns
- capabilities and statistics of a member
- Return type
- CoordAsyncResult
- get_members(group_id)
- Return the set of all member ids of a group asynchronously.
- Returns
- set of all member ids in the specified group
- Return type
- CoordAsyncResult
- heartbeat()
- Update member status to indicate it is still alive.
Method to run once in a while to be sure that the member is not dead and is still an active member of a group.
- Returns
- The number of seconds to wait before sending a new heartbeat.
- join_group(group_id, capabilities=b'')
- Join a group and establish group membership asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group to join
- capabilities (object) -- the capabilities of the joined member
- Returns
- None
- Return type
- CoordAsyncResult
- leave_group(group_id)
- Leave a group asynchronously.
- Parameters
- group_id (ascii bytes) -- the id of the group to leave
- Returns
- None
- Return type
- CoordAsyncResult
- run_elect_coordinator()
- Try to leader elect this coordinator & activate hooks on success.
- run_watchers(timeout=None)
- Run the watchers callback.
This may also activate run_elect_coordinator() (depending on driver implementation).
- stand_down_group_leader(group_id)
- Stand down as the group leader if we are.
- Parameters
- group_id -- The group where we don't want to be a leader anymore
- update_capabilities(group_id, capabilities)
- Update member capabilities in the specified group.
- Parameters
- group_id (ascii bytes) -- the id of the group of the current member
- capabilities (object) -- the capabilities of the updated member
- Returns
- None
- Return type
- CoordAsyncResult
Exceptions
- class tooz.ToozError(message, cause=None)
- Exception raised when an internal error occurs.
Raised for instance in case of server internal error.
- Variables
- cause -- the cause of the exception being raised, when not none this will itself be an exception instance, this is useful for creating a chain of exceptions for versions of python where this is not yet implemented/supported natively.
- __init__(message, cause=None)
- __weakref__
- list of weak references to the object
- class tooz.coordination.ToozConnectionError(message, cause=None)
- Exception raised when the client cannot connect to the server.
- class tooz.coordination.OperationTimedOut(message, cause=None)
- Exception raised when an operation times out.
- class tooz.coordination.GroupNotCreated(group_id)
- Exception raised when the caller request an nonexistent group.
- __init__(group_id)
- class tooz.coordination.GroupAlreadyExist(group_id)
- Exception raised trying to create an already existing group.
- __init__(group_id)
- class tooz.coordination.MemberAlreadyExist(group_id, member_id)
- Exception raised trying to join a group already joined.
- __init__(group_id, member_id)
- class tooz.coordination.MemberNotJoined(group_id, member_id)
- Exception raised trying to access a member not in a group.
- __init__(group_id, member_id)
- class tooz.coordination.GroupNotEmpty(group_id)
- Exception raised when the caller try to delete a group with members.
- __init__(group_id)
- tooz.utils.raise_with_cause(exc_cls, message, *args, **kwargs)
- Helper to raise + chain exceptions (when able) and associate a
cause.
For internal usage only.
NOTE(harlowja): Since in py3.x exceptions can be chained (due to PEP 3134) we should try to raise the desired exception with the given cause.
- Parameters
- exc_cls -- the ToozError class to raise.
- message -- the text/str message that will be passed to the exceptions constructor as its first positional argument.
- args -- any additional positional arguments to pass to the exceptions constructor.
- kwargs -- any additional keyword arguments to pass to the exceptions constructor.
RELEASE NOTES
Read also the tooz Release Notes.
INDICES AND TABLES
- Index
- Module Index
- Search Page
- [1]
- It should be noted that even though it is designed with OpenStack integration in mind, and that is where most of its current integration is it aims to be generally usable and useful in any project.
AUTHOR
Author name not set
COPYRIGHT
2024, OpenStack Foundation
| October 25, 2024 | 6.3.0 |
