Beispiel #1
0
 def retry_failed_node(self, _):  # Permanently repeating timer
     if self.failed_nodes:
         node = self.failed_nodes.pop(0)
         # Send a test message to the oldest failed node
         pingmsg = PingReq(self, node)
         Framework.send_message(pingmsg)
     # Restart the timer
     TimerManager.start_timer(self, reason="retry", priority=15, callback=self.retry_failed_node)
Beispiel #2
0
 def retry_failed_node(self, _):  # Permanently repeating timer
     if self.failed_nodes:
         node = self.failed_nodes.pop(0)
         # Send a test message to the oldest failed node
         pingmsg = PingReq(self, node)
         Framework.send_message(pingmsg)
     # Restart the timer
     TimerManager.start_timer(self, reason="retry", priority=15, callback=self.retry_failed_node)
 def send_message(cls, msg, expect_reply=True):
     cls.queue.append(msg)
     if (expect_reply and not isinstance(msg, ResponseMessage)
             and 'rsp_timer_pop' in msg.from_node.__class__.__dict__ and
             callable(msg.from_node.__class__.__dict__['rsp_timer_pop'])):
         cls.pending_timers[msg] = TimerManager.start_timer(
             msg.from_node, reason=msg, callback=Framework.rsp_timer_pop)
Beispiel #4
0
 def send_message(cls, msg, expect_reply=True):
     """Send a message"""
     _logger.info("Enqueue %s->%s: %s", msg.from_node, msg.to_node, msg)
     cls.queue.append(msg)
     History.add("send", msg)
     # Automatically run timers for request messages if the sender can cope
     # with retry timer pops
     if (expect_reply and not isinstance(msg, ResponseMessage)
             and 'rsp_timer_pop' in msg.from_node.__class__.__dict__ and
             callable(msg.from_node.__class__.__dict__['rsp_timer_pop'])):
         cls.pending_timers[msg] = TimerManager.start_timer(
             msg.from_node, reason=msg, callback=Framework.rsp_timer_pop)
 def send_message(cls, msg, expect_reply=True):
     """Send a message"""
     _logger.info("Enqueue %s->%s: %s", msg.from_node, msg.to_node, msg)
     cls.queue.append(msg)
     History.add("send", msg)
     # Automatically run timers for request messages if the sender can cope
     # with retry timer pops
     if (expect_reply and
         not isinstance(msg, ResponseMessage) and
         'rsp_timer_pop' in msg.from_node.__class__.__dict__ and
         callable(msg.from_node.__class__.__dict__['rsp_timer_pop'])):
         cls.pending_timers[msg] = TimerManager.start_timer(msg.from_node, reason=msg, callback=Framework.rsp_timer_pop)
Beispiel #6
0
    def retry_failed_node(self):  # Permanently repeating timer
        #modified
        while True:
        ####################
            gevent.sleep(5)
#            print 'sleeping...'
            if self.failed_nodes:
                
                if len(self.failed_nodes) < 1:
                    continue
#                print "self.failed_nodes: ",self.failed_nodes
                node = self.failed_nodes.pop(0)
                # Send a test message to the oldest failed node
                pingmsg = PingReq(self.addr, node)
                #modified
                con = self.connections[self.servers.index(node)]
                result = Framework.send_message(pingmsg, con)
                if result is False and node not in self.failed_nodes:
                    self.failed_nodes.append(node)
                ############################
        # Restart the timer
        TimerManager.start_timer(self, reason="retry", priority=15, callback=None)#self.retry_failed_node)
Beispiel #7
0
 def send_message(cls, msg, con, expect_reply=True):
     """receive a message"""
     _logger.info("Enqueue %s->%s: %s", msg.from_node, msg.to_node, msg)
     cls.queue.append(msg)
     History.add("receive", msg)
     # Automatically run timers for request messages if the sender can cope
     # with retry timer pops
     if (expect_reply and
         not isinstance(msg, ResponseMessage) and
         'rsp_timer_pop' in msg.from_node.__class__.__dict__ and
         callable(msg.from_node.__class__.__dict__['rsp_timer_pop'])):
         cls.pending_timers[msg] = TimerManager.start_timer(msg.from_node, reason=msg, callback=Framework.rsp_timer_pop)
     #modified
     try:
         pmsg = pickle.dumps(msg)
         return con.rcvmsg(pmsg)
     except zerorpc.TimeoutExpired:
         print "time out when", msg.from_node, "calls", msg.to_node
         return False