コード例 #1
0
 def detect(self, memberlist):
     self._logger.debug('Detecting failures.')
     dead_nodes = []
     current_timestamp = timestamp()
     for node in memberlist.itervalues():
         if node.timestamp + self._dead_timeout * 1000 < current_timestamp:
             print 'failed node: %r' % node 
             node.status = MemberStatus.Dead
             dead_nodes.append(node)
     
     # self._logger.debug('Detecting failures.')
     return dead_nodes
コード例 #2
0
 def beat(self, message):
     with self._memberlist.lock():
         address = message.address
         memberlist_key = self._memberlist.generate_key(address.host, address.port)
         
         # TODO: add locking for memberlist
         node = Member(Address(address.host, address.port), message.seq_num, timestamp())
         
         if memberlist_key in self._memberlist:
             self._memberlist[memberlist_key].merge(node)
         else:
             self._memberlist[memberlist_key] = node
     
     self._logger.debug('Received heartbeat message %s from %s.' % (message.seq_num, node.address))