Example #1
0
    def ccquery (self, msg, blob = None):
        """Sends query to CC, waits for answer."""
        assert isinstance (msg, BaseMessage)
        if not self.cc: self.connect_cc()

        cmsg = self.xtx.create_cmsg (msg, blob)
        cmsg.send_to (self.cc)

        crep = CCMessage(self.cc.recv_multipart())
        return crep.get_payload(self.xtx)
Example #2
0
 def router_on_recv (self, zmsg):
     """ Got reply from worker via "router" connection """
     cmsg = CCMessage (zmsg)
     data = cmsg.get_payload (self.xtx)
     fi = (data['d_hostname'], data['d_st_dev'], data['d_st_ino'], data['d_filename'])
     fd = self.files[fi]
     if fd.waddr is None:
         fd.waddr = zmsg[0]
         fd.wname = data['worker']
     else:
         assert fd.waddr == zmsg[0] and fd.wname == data['worker']
     fd.atime = time.time()
     fd.count -= 1
     assert fd.count >= 0
Example #3
0
 def router_on_recv(self, zmsg):
     """ Got reply from worker via "router" connection """
     cmsg = CCMessage(zmsg)
     data = cmsg.get_payload(self.xtx)
     fi = (data['d_hostname'], data['d_st_dev'], data['d_st_ino'],
           data['d_filename'])
     fd = self.files[fi]
     if fd.waddr is None:
         fd.waddr = zmsg[0]
         fd.wname = data['worker']
     else:
         assert fd.waddr == zmsg[0] and fd.wname == data['worker']
     fd.atime = time.time()
     fd.count -= 1
     assert fd.count >= 0
Example #4
0
    def handle_recv_real(self, zmsg):
        """Actual callback that can throw exceptions."""

        cmsg = CCMessage(zmsg)

        route = cmsg.get_route()
        if len(route) != 1:
            self.log.error('Invalid reply route: %r', route)
            return

        qid = route[0]
        if qid not in self.query_cache:
            self.log.error('reply for unknown query: %r', qid)
            return

        msg = cmsg.get_payload(self.xtx)

        qi = self.query_cache[qid]
        qi.launch_cb(msg)
Example #5
0
    def handle_recv_real(self, zmsg):
        """Actual callback that can throw exceptions."""

        cmsg = CCMessage(zmsg)

        route = cmsg.get_route()
        if len(route) != 1:
            self.log.error('Invalid reply route: %r', route)
            return

        qid = route[0]
        if qid not in self.query_cache:
            self.log.error('reply for unknown query: %r', qid)
            return

        msg = cmsg.get_payload(self.xtx)

        qi = self.query_cache[qid]
        qi.launch_cb(msg)