示例#1
0
 def rcv_getrsp(self, getrsp):
     seqno = getrsp.msg_id
     if seqno in self.pending_get_rsp:
         self.pending_get_rsp[seqno].add(
             (getrsp.from_node, getrsp.value, getrsp.metadata))
         if len(self.pending_get_rsp[seqno]) >= DynamoNode.R:
             _logger.info("%s: read %d copies of %s=? so done", self,
                          DynamoNode.R, getrsp.key)
             _logger.debug(
                 "  copies at %s",
                 [(node.name, value)
                  for (node, value, _) in self.pending_get_rsp[seqno]])
             # Build up all the distinct values/metadata values for the response to the original request
             results = set([(value, metadata)
                            for (node, value,
                                 metadata) in self.pending_get_rsp[seqno]])
             # Tidy up tracking data structures
             original_msg = self.pending_get_msg[seqno]
             del self.pending_req[GetReq][seqno]
             del self.pending_get_rsp[seqno]
             del self.pending_get_msg[seqno]
             # Reply to the original client, including all received values
             client_getrsp = ClientGetRsp(
                 original_msg, [value for (value, metadata) in results],
                 [metadata for (value, metadata) in results])
             Framework.send_message(client_getrsp)
     else:
         pass  # Superfluous reply
示例#2
0
 def rcv_getrsp(self, getrsp):
     seqno = getrsp.msg_id
     if seqno in self.pending_get_rsp:
         self.pending_get_rsp[seqno].add(
             (getrsp.from_node, getrsp.value, getrsp.metadata))
         if len(self.pending_get_rsp[seqno]) >= DynamoNode.R:
             results = set([(value, metadata)
                            for (node, value,
                                 metadata) in self.pending_get_rsp[seqno]])
             orig_msg = self.pending_get_msg[seqno]
             del self.pending_req[GetReq][seqno]
             del self.pending_get_rsp[seqno]
             del self.pending_get_msg[seqno]
             client_getrsp = ClientGetRsp(
                 orig_msg, [value for (value, metadata) in results],
                 [metadata for (value, metadata) in results])
             Framework.send_message(client_getrsp)