# Path: tooz/utils.py
# class Base64LockEncoder(object):
# class ProxyExecutor(object):
# class SerializationError(tooz.ToozError):
#     def __init__(self, keyspace_url, prefix=''):
#     def check_and_encode(self, name):
#     def encode(self, name):
#     def __init__(self, driver_name, default_executor_factory):
#     def build(cls, driver_name, options):
#     def start(self):
#     def stop(self):
#     def submit(self, cb, *args, **kwargs):
# def safe_abs_path(rooted_at, *pieces):
# def convert_blocking(blocking):
# def collapse(config, exclude=None, item_selector=operator.itemgetter(-1)):
# def to_binary(text, encoding='ascii'):
# def dumps(data, excp_cls=SerializationError):
# def loads(blob, excp_cls=SerializationError):
# def millis_to_datetime(milliseconds):
# def raise_with_cause(exc_cls, message, *args, **kwargs):
#     KIND_TO_FACTORY = {
#         'threaded': (lambda:
#                      futurist.ThreadPoolExecutor(max_workers=1)),
#         'synchronous': lambda: futurist.SynchronousExecutor(),
#     }
#     DEFAULT_KIND = 'threaded'


import bisect
import hashlib
import tooz
from oslo_utils.secretutils import md5
from tooz import utils
        self.nodes = {}
        self._ring = dict()
        self._partitions = []
        self._partition_number = partitions
        self._hash_function = hash_function

        self.add_nodes(set(nodes))

    def add_node(self, node, weight=1):
        """Add a node to the hashring.

        :param node: Node to add.
        :param weight: How many resource instances this node should manage
        compared to the other nodes (default 1). Higher weights will be
        assigned more resources. Three nodes A, B and C with weights 1, 2 and 3
        will each handle 1/6, 1/3 and 1/2 of the resources, respectively.

        """
        return self.add_nodes((node,), weight)

    def add_nodes(self, nodes, weight=1):
        """Add nodes to the hashring with equal weight

        :param nodes: Nodes to add.
        :param weight: How many resource instances this node should manage
        compared to the other nodes (default 1). Higher weights will be
        assigned more resources. Three nodes A, B and C with weights 1, 2 and 3
        will each handle 1/6, 1/3 and 1/2 of the resources, respectively.
        """
        for node in nodes:

# Path: tooz/utils.py
# class Base64LockEncoder(object):
# class ProxyExecutor(object):
# class SerializationError(tooz.ToozError):
#     def __init__(self, keyspace_url, prefix=''):
#     def check_and_encode(self, name):
#     def encode(self, name):
#     def __init__(self, driver_name, default_executor_factory):
#     def build(cls, driver_name, options):
#     def start(self):
#     def stop(self):
#     def submit(self, cb, *args, **kwargs):
# def safe_abs_path(rooted_at, *pieces):
# def convert_blocking(blocking):
# def collapse(config, exclude=None, item_selector=operator.itemgetter(-1)):
# def to_binary(text, encoding='ascii'):
# def dumps(data, excp_cls=SerializationError):
# def loads(blob, excp_cls=SerializationError):
# def millis_to_datetime(milliseconds):
# def raise_with_cause(exc_cls, message, *args, **kwargs):
#     KIND_TO_FACTORY = {
#         'threaded': (lambda:
#                      futurist.ThreadPoolExecutor(max_workers=1)),
#         'synchronous': lambda: futurist.SynchronousExecutor(),
#     }
#     DEFAULT_KIND = 'threaded'


# Path: tooz/hashring.py
import bisect
import hashlib
import tooz
from oslo_utils.secretutils import md5
from tooz import utils

        self.nodes = {}
        self._ring = dict()
        self._partitions = []
        self._partition_number = partitions
        self._hash_function = hash_function

        self.add_nodes(set(nodes))

    def add_node(self, node, weight=1):
        """Add a node to the hashring.

        :param node: Node to add.
        :param weight: How many resource instances this node should manage
        compared to the other nodes (default 1). Higher weights will be
        assigned more resources. Three nodes A, B and C with weights 1, 2 and 3
        will each handle 1/6, 1/3 and 1/2 of the resources, respectively.

        """
        return self.add_nodes((node,), weight)

    def add_nodes(self, nodes, weight=1):
        """Add nodes to the hashring with equal weight

        :param nodes: Nodes to add.
        :param weight: How many resource instances this node should manage
        compared to the other nodes (default 1). Higher weights will be
        assigned more resources. Three nodes A, B and C with weights 1, 2 and 3
        will each handle 1/6, 1/3 and 1/2 of the resources, respectively.
        """
        for node in nodes:

            key = utils.to_binary(node, 'utf-8')