def __init__(self, node, **kwargs): """Constructor for the Gossip class. Args: node (Node): The local node. MinimumRetries (int): The minimum number of retries on message transmission. RetryInterval (float): The time between retries, in seconds. """ super(Gossip, self).__init__() if 'MinimumRetries' in kwargs: self.MinimumRetries = kwargs['MinimumRetries'] if 'RetryInterval' in kwargs: self.RetryInterval = kwargs['RetryInterval'] self.LocalNode = node self.NodeMap = {} self.PendingAckMap = {} self.MessageHandledMap = {} self.MessageHandlerMap = {} self.SequenceNumber = 0 self.NextCleanup = time.time() + self.CleanupInterval self.NextKeepAlive = time.time() + self.KeepAliveInterval self._initgossipstats() connect_message.register_message_handlers(self) gossip_debug.register_message_handlers(self) shutdown_message.register_message_handlers(self) topology_message.register_message_handlers(self) random_walk_message.register_message_handlers(self) # setup connectivity events self.onNodeDisconnect = event_handler.EventHandler('onNodeDisconnect') # setup the timer events self.onHeartbeatTimer = event_handler.EventHandler('onHeartbeatTimer') self.onHeartbeatTimer += self._timertransmit self.onHeartbeatTimer += self._timercleanup self.onHeartbeatTimer += self._keepalive self._HeartbeatTimer = task.LoopingCall(self._heartbeat) self._HeartbeatTimer.start(0.05) self.MessageQueue = Queue.Queue() try: self.ProcessIncomingMessages = True self.Listener = reactor.listenUDP(self.LocalNode.NetPort, self, interface=self.LocalNode.NetHost) reactor.callInThread(self._dispatcher) except: logger.critical( "failed to connect local socket, server shutting down", exc_info=True) raise GossipException("Failed to connect local " "socket, server shutting down")
def __init__(self, node, **kwargs): """Constructor for the Gossip class. Args: node (Node): The local node. MinimumRetries (int): The minimum number of retries on message transmission. RetryInterval (float): The time between retries, in seconds. """ super(Gossip, self).__init__() if 'MinimumRetries' in kwargs: self.MinimumRetries = kwargs['MinimumRetries'] if 'RetryInterval' in kwargs: self.RetryInterval = kwargs['RetryInterval'] self.LocalNode = node self.NodeMap = {} self.PendingAckMap = {} self.MessageHandledMap = {} self.MessageHandlerMap = {} self.SequenceNumber = 0 self.NextCleanup = time.time() + self.CleanupInterval self.NextKeepAlive = time.time() + self.KeepAliveInterval self._initgossipstats() connect_message.register_message_handlers(self) gossip_debug.register_message_handlers(self) shutdown_message.register_message_handlers(self) topology_message.register_message_handlers(self) random_walk_message.register_message_handlers(self) # setup connectivity events self.onNodeDisconnect = event_handler.EventHandler('onNodeDisconnect') # setup the timer events self.onHeartbeatTimer = event_handler.EventHandler('onHeartbeatTimer') self.onHeartbeatTimer += self._timertransmit self.onHeartbeatTimer += self._timercleanup self.onHeartbeatTimer += self._keepalive self._HeartbeatTimer = task.LoopingCall(self._heartbeat) self._HeartbeatTimer.start(0.05) self.MessageQueue = MessageQueue() try: self.ProcessIncomingMessages = True self.Listener = reactor.listenUDP(self.LocalNode.NetPort, self) reactor.callInThread(self._dispatcher) except: logger.critical( "failed to connect local socket, server shutting down", exc_info=True) raise GossipException( "Failed to connect local " "socket, server shutting down")
def __init__(self, node, minimum_retries=None, retry_interval=None, stat_domains=None): """Constructor for the Gossip class. Args: node (Node): The local node. MinimumRetries (int): The minimum number of retries on message transmission. RetryInterval (float): The time between retries, in seconds. """ super(Gossip, self).__init__() self.blacklist = [] if minimum_retries is not None: self.MinimumRetries = minimum_retries if retry_interval is not None: self.RetryInterval = retry_interval self.LocalNode = node self.NodeMap = {} self.PendingAckMap = {} self.MessageHandledMap = {} self.SequenceNumber = 0 self.NextCleanup = time.time() + self.CleanupInterval self.NextKeepAlive = time.time() + self.KeepAliveInterval self._init_gossip_stats(stat_domains) self.dispatcher = MessageDispatcher(self) connect_message.register_message_handlers(self) gossip_debug.register_message_handlers(self) random_walk_message.register_message_handlers(self) shutdown_message.register_message_handlers(self) topology_message.register_message_handlers(self) # setup connectivity events self.onNodeDisconnect = event_handler.EventHandler('onNodeDisconnect') # setup the timer events self.dispatcher.on_heartbeat += self._timer_transmit self.dispatcher.on_heartbeat += self._timer_cleanup self.dispatcher.on_heartbeat += self._keep_alive self.IncomingMessageQueue = MessageQueue() try: self.ProcessIncomingMessages = True self.Listener = reactor.listenUDP(self.LocalNode.NetPort, self) reactor.callInThread(self._dispatcher) except Exception as e: logger.critical( "failed to connect local socket, server shutting down", exc_info=True) raise GossipException( "Failed to connect local " "socket, server shutting down")