コード例 #1
0
ファイル: peer.py プロジェクト: eswartz/emul
 def sendPeerRemovedEvent(self):
     for l in protocol.getLocator().getListeners():
         try:
             l.peerRemoved(self.rw_attrs.get(ATTR_ID))
         except Exception as x:
             protocol.log("Unhandled exception in Locator listener", x)
     try:
         args = [self.rw_attrs.get(ATTR_ID)]
         protocol.sendEvent(locator.NAME, "peerRemoved", json.dumps(args))
     except IOError as x:
         protocol.log("Locator: failed to send 'peerRemoved' event", x)
コード例 #2
0
ファイル: peer.py プロジェクト: eswartz/emul
 def sendPeerAddedEvent(self):
     for l in protocol.getLocator().getListeners():
         try:
             l.peerAdded(self)
         except Exception as x:
             protocol.log("Unhandled exception in Locator listener", x)
     try:
         args = [self.rw_attrs]
         protocol.sendEvent(locator.NAME, "peerAdded", json.dumps(args))
     except IOError as x:
         protocol.log("Locator: failed to send 'peerAdded' event", x)
     self.last_heart_beat_time = int(time.time() * 1000)
コード例 #3
0
ファイル: peer.py プロジェクト: wind-river-cdt/tcf
 def updateAttributes(self, attrs):
     equ = True
     assert attrs.get(ATTR_ID) == self.rw_attrs.get(ATTR_ID)
     for key in self.rw_attrs.keys():
         if self.rw_attrs.get(key) != attrs.get(key):
             equ = False
             break
     for key in attrs.keys():
         if attrs.get(key) != self.rw_attrs.get(key):
             equ = False
             break
     timeVal = int(time.time() * 1000)
     if not equ:
         self.rw_attrs.clear()
         self.rw_attrs.update(attrs)
         for l in protocol.getLocator().getListeners():
             try:
                 l.peerChanged(self)
             except Exception as x:
                 protocol.log("Unhandled exception in Locator listener", x)
         try:
             args = [self.rw_attrs]
             protocol.sendEvent(locator.NAME, "peerChanged",
                                channel.toJSONSequence(args))
         except IOError as x:
             protocol.log("Locator: failed to send 'peerChanged' event", x)
         self.last_heart_beat_time = timeVal
     elif self.last_heart_beat_time + locator.DATA_RETENTION_PERIOD / 4 \
                                                                 < timeVal:
         for l in protocol.getLocator().getListeners():
             try:
                 l.peerHeartBeat(attrs.get(ATTR_ID))
             except Exception as x:
                 protocol.log("Unhandled exception in Locator listener", x)
         try:
             args = [self.rw_attrs.get(ATTR_ID)]
             protocol.sendEvent(locator.NAME, "peerHeartBeat",
                                channel.toJSONSequence(args))
         except IOError as x:
             protocol.log(
                 "Locator: failed to send 'peerHeartBeat' event", x)
         self.last_heart_beat_time = timeVal