def on_message(self, event): if event.receiver == self.reply_receiver: response = self.proxy.response(event.message) if self.stage == 1: # # LinkBlocked # if response.results[0].linksBlocked == 1: self.receiver = event.container.create_receiver(self.sender_conn, self.addr) self.stage = 2 self.process() return elif self.stage == 2: # # LinkUnblocked # if response.results[0].linksBlocked == 0: self.stage = 3 self.process() return elif self.stage == 3: # # 250Credits # for link in response.results: if 'M0' + self.addr == link.owningAddr: if link.creditAvailable == 250: self.fail(None) return self.poll_timer = event.reactor.schedule(0.5, PollTimeout(self))
def on_message(self, event): if event.receiver == self.receiver: if self.n_rx not in self.stuck_list: self.accept(event.delivery) else: self.stuck_dlvs.append(event.delivery) self.n_rx += 1 if self.n_rx == self.dlv_count: self.query_stats(len(self.stuck_list) * 2) elif event.receiver == self.reply_receiver: response = self.proxy.response(event.message) self.accept(event.delivery) self.last_stuck = response.results[0].deliveriesStuck if self.last_stuck == self.expected_stuck: if self.close_link: self.receiver.close() else: for dlv in self.stuck_dlvs: self.accept(dlv) self.stuck_dlvs = [] if self.expected_stuck > 0: self.query_stats(0) else: self.fail(None) else: self.poll_timer = event.reactor.schedule(0.5, PollTimeout(self))
def on_message(self, event): if event.receiver == self.probe_receiver: response = self.proxy.response(event.message) self.last_action = "Handling probe response: remote: %d container: %d" \ % (response.remoteCount, response.containerCount) if response.status_code == 200 and response.remoteCount + response.containerCount == 1: self.sender = event.container.create_sender(self.receiver_conn, self.address) self.last_action = "opening test sender" else: self.poll_timer = self.reactor.schedule(0.5, PollTimeout(self))
def on_message(self, event): if event.receiver == self.first_receiver: self.n_rcvd += 1 if event.receiver == self.reply_receiver: response = self.proxy.response(event.message) if response.status_code == 200 and (response.remoteCount + response.containerCount) > 0: if self.poll_timer: self.poll_timer.cancel() self.poll_timer = None self.setup_first_links(event) else: self.poll_timer = event.reactor.schedule(0.25, PollTimeout(self))
def on_message(self, event): if event.receiver == self.receiver: self.n_rcvd += 1 if event.receiver == self.reply_receiver: response = self.proxy.response(event.message) if response.status_code == 200 and (response.remoteCount + response.subscriberCount) > 0: self.sender = event.container.create_sender(self.sender_conn, None) if self.poll_timer: self.poll_timer.cancel() self.poll_timer = None else: self.poll_timer = event.reactor.schedule(0.25, PollTimeout(self))
def on_message(self, event): if event.receiver == self.probe_receiver: response = self.proxy.response(event.message) if response.status_code < 200 or response.status_code > 299: self.fail("Unexpected operation failure: (%d) %s" % (response.status_code, response.status_description)) if self.expect == "not-found": response = self.proxy.response(event.message) for addr in response.results: if "address." in addr.name: self.fail( "Found address on host-a when we didn't expect it - %s" % addr.name) ## # Hook up the two routers to start the sync-up ## self.probe_sender.send( self.proxy.create_connector("IR", port=self.inter_router_port, role="inter-router")) self.expect = "create-success" self.last_action = "created inter-router connector" elif self.expect == "create-success": ## # Start polling for the addresses on host_a ## response = self.proxy.response(event.message) self.probe_sender.send(self.proxy.query_addresses()) self.expect = "query-success" self.last_action = "started probing host_a for addresses" elif self.expect == "query-success": response = self.proxy.response(event.message) got_count = 0 for addr in response.results: if "address." in addr.name: got_count += 1 self.last_action = "Got a query response with %d of the expected addresses" % ( got_count) if got_count == self.count: self.fail(None) else: self.poll_timer = self.reactor.schedule( 0.5, PollTimeout(self))
def on_message(self, event): if event.receiver == self.reply_receiver: response = self.proxy.response(event.message) if response.status_code == 200 and (response.remoteCount + response.containerCount) > 0: if self.poll_timer: self.poll_timer.cancel() self.poll_timer = None self.setup_first_links(event) else: self.poll_timer = event.reactor.schedule(0.25, PollTimeout(self)) return m = event.message self.result.append(m.body) if m.body == 'Send_Short_1': self.send()