Exemple #1
0
 def dispatch(self, envelope):
     """
     Dispatch received request.
     The serial number of failed requests is added to the blacklist
     help prevent dispatching both failure and success replies.  The
     primary cause of this is when the watchdog has replied on the agent's
     behalf but the agent actually completes the request and later sends
     a reply.
     @param envelope: The received envelope.
     @type envelope: L{Envelope}
     """
     try:
         reply = Reply(envelope)
         if envelope.sn in self.blacklist:
             # ignored
             return
         if reply.started():
             self.watchdog.started(envelope.sn)
             reply = Started(envelope)
             reply.notify(self.listener)
             return
         if reply.progress():
             self.watchdog.progress(envelope.sn)
             reply = Progress(envelope)
             reply.notify(self.listener)
             return
         if reply.succeeded():
             self.blacklist.add(envelope.sn)
             self.watchdog.completed(envelope.sn)
             reply = Succeeded(envelope)
             reply.notify(self.listener)
             return
         if reply.failed():
             self.blacklist.add(envelope.sn)
             self.watchdog.completed(envelope.sn)
             reply = Failed(envelope)
             reply.notify(self.listener)
             return
     except Exception:
         log.exception(envelope)
Exemple #2
0
 def dispatch(self, document):
     """
     Dispatch received request.
     The serial number of failed requests is added to the blacklist
     help prevent dispatching both failure and success replies.
     :param document: The received document.
     :type document: Document
     """
     try:
         reply = Reply(document)
         if document.sn in self.blacklist:
             # ignored
             return
         if reply.accepted():
             reply = Accepted(document)
             reply.notify(self.listener)
             return
         if reply.rejected():
             reply = Rejected(document)
             reply.notify(self.listener)
             return
         if reply.started():
             reply = Started(document)
             reply.notify(self.listener)
             return
         if reply.progress():
             reply = Progress(document)
             reply.notify(self.listener)
             return
         if reply.succeeded():
             self.blacklist.add(document.sn)
             reply = Succeeded(document)
             reply.notify(self.listener)
             return
         if reply.failed():
             self.blacklist.add(document.sn)
             reply = Failed(document)
             reply.notify(self.listener)
             return
     except Exception:
         log.exception(document)
Exemple #3
0
 def dispatch(self, document):
     """
     Dispatch received request.
     The serial number of failed requests is added to the blacklist
     help prevent dispatching both failure and success replies.
     :param document: The received document.
     :type document: Document
     """
     try:
         reply = Reply(document)
         if document.sn in self.blacklist:
             # ignored
             return
         if reply.accepted():
             reply = Accepted(document)
             reply.notify(self.listener)
             return
         if reply.rejected():
             reply = Rejected(document)
             reply.notify(self.listener)
             return
         if reply.started():
             reply = Started(document)
             reply.notify(self.listener)
             return
         if reply.progress():
             reply = Progress(document)
             reply.notify(self.listener)
             return
         if reply.succeeded():
             self.blacklist.add(document.sn)
             reply = Succeeded(document)
             reply.notify(self.listener)
             return
         if reply.failed():
             self.blacklist.add(document.sn)
             reply = Failed(document)
             reply.notify(self.listener)
             return
     except Exception:
         log.exception(document)