def __init__(self, start = [], quorum=1, name = None, shard=None, shard_map=None, host='localhost', port=9092): self.client = None self.channel_name = None self.kafka = KafkaClient('%s:%s' % (host,port)) # redis.StrictRedis(host, port, db) self.producer = SimpleProducer(self.kafka) self.shard_id = shard self.shard_map = shard_map # Configure the shard if shard is not None: assert shard in shard_map shard = shard_map[shard] self.channel_name = 'votes%s' % self.shard_id self.client = Listener(self, self.channel_name) print "Listen on: %s" % self.channel_name else: self.channel_name = 'votes' self.client = Listener(self, self.channel_name) # Initialize the node for consensus. Node.__init__(self, start, quorum, name, shard) # Start the subscription loop and log. self.client.start() self.RLogger = logging.getLogger() print "Init done"
def __init__(self, start = [], quorum=1, name = None, shard=None, shard_map=None, host='localhost', port=6379, db=0): self.r = redis.StrictRedis(host, port, db) self.shard_id = shard self.shard_map = shard_map # Configure the shard if shard is not None: assert shard in shard_map shard = shard_map[shard] self.client = Listener(self, ['votes:%s' % self.shard_id]) else: self.client = Listener(self, ['votes']) # Initialize the node for consensus. Node.__init__(self, start, quorum, name, shard) # Start the subscription loop and log. self.client.start() self.RLogger = logging.getLogger()
def __init__(self, start=[], quorum=1, name=None, shard=None, shard_map=None, host='localhost', port=9092): self.client = None self.channel_name = None self.kafka = KafkaClient( '%s:%s' % (host, port)) # redis.StrictRedis(host, port, db) self.producer = SimpleProducer(self.kafka) self.shard_id = shard self.shard_map = shard_map # Configure the shard if shard is not None: assert shard in shard_map shard = shard_map[shard] self.channel_name = 'votes%s' % self.shard_id self.client = Listener(self, self.channel_name) print "Listen on: %s" % self.channel_name else: self.channel_name = 'votes' self.client = Listener(self, self.channel_name) # Initialize the node for consensus. Node.__init__(self, start, quorum, name, shard) # Start the subscription loop and log. self.client.start() self.RLogger = logging.getLogger() print "Init done"