Exemplo n.º 1
0
class ConsistentHashingClient(object):

    def __init__(self, clients):
        self.ring = ConsistentHashRing(clients)

    def write(self, data):
        """Hash based on the metric name, then send to the right client."""
        metric_name, rest = data.split(":", 1)
        client = self.ring.get_node(metric_name)
        client.write(data)
Exemplo n.º 2
0
class ConsistentHashingClient(object):
    def __init__(self, clients):
        self.ring = ConsistentHashRing(clients)

    def write(self, data):
        """Hash based on the metric name, then send to the right client."""
        metric_name, rest = str(data).split(":", 1)
        client = self.ring.get_node(metric_name)
        client.write(data)

    def connect(self):
        """Connect all ring nodes."""
        for node in self.ring.nodes:
            node.connect()

    def disconnect(self):
        """Disconnect all ring nodes"""
        for node in self.ring.nodes:
            node.disconnect()
Exemplo n.º 3
0
class ConsistentHashingClient(object):

    def __init__(self, clients):
        self.ring = ConsistentHashRing(clients)

    def write(self, data):
        """Hash based on the metric name, then send to the right client."""
        metric_name, rest = str(data).split(":", 1)
        client = self.ring.get_node(metric_name)
        client.write(data)

    def connect(self):
        """Connect all ring nodes."""
        for node in self.ring.nodes:
            node.connect()

    def disconnect(self):
        """Disconnect all ring nodes"""
        for node in self.ring.nodes:
            node.disconnect()
Exemplo n.º 4
0
 def __init__(self, clients):
     self.ring = ConsistentHashRing(clients)
Exemplo n.º 5
0
 def __init__(self, clients):
     self.ring = ConsistentHashRing(clients)