async def prepare_result_notification(self, request: ACLMessage) -> ACLMessage: self_deallocation_mt = Template() self_deallocation_mt.set_metadata('protocol', 'ContractNet') self_deallocation_mt.set_metadata('action', SelfDeallocationRequest.__key__) self_deallocation_behaviour = SelfDeallocationInitiator() self.agent.add_behaviour(self_deallocation_behaviour) await self_deallocation_behaviour.join() response = ACLMessage(to=str(request.sender)) response.performative = Performative.INFORM response.action = DeallocationRequest.__key__ response.protocol = 'Request' response.ontology = self.agent.ontology.name self.agent.release_lock() return response
async def prepare_result_notification(self, request: ACLMessage) -> ACLMessage: content: SelfDeallocationRequest = self.agent.content_manager.extract_content( request) blocking_containers = self.agent.get_blocking_containers( content.container_id) for container_id, _, container_agent_jid in blocking_containers: await self.agent.remove_container(container_id) await self._reallocate_container(container_agent_jid) await self.agent.remove_container(content.container_id) self.agent.release_lock() response = ACLMessage(to=str(request.sender), sender=str(self.agent.jid)) response.protocol = 'Request' response.ontology = self.agent.ontology.name response.performative = Performative.INFORM response.action = SelfDeallocationRequest.__key__ return response
async def prepare_result_notification(self, request: ACLMessage) -> ACLMessage: content: ContainersDeallocationRequest = self.agent.content_manager.extract_content( request) deallocation_mt = Template() deallocation_mt.set_metadata('protocol', 'Request') deallocation_mt.set_metadata('action', DeallocationRequest.__key__) for container_jid in content.containers_jids: deallocation_behaviour = DeallocationInitiator(container_jid) self.agent.add_behaviour(deallocation_behaviour, deallocation_mt) await deallocation_behaviour.join() self.agent.log('Containers deallocated by Port Manager') response = ACLMessage(to=str(request.sender)) response.performative = Performative.INFORM response.protocol = 'Request' response.ontology = self.agent.ontology.name response.action = ContainersDeallocationRequest.__key__ return response
async def prepare_result_notification(self, request: ACLMessage) -> ACLMessage: content: ReallocationRequest = self.agent.content_manager.extract_content( request) if content.slot_id == self.agent.slot_id: allocation_mt = Template() allocation_mt.set_metadata('protocol', 'ContractNet') allocation_mt.set_metadata('action', AllocationRequest.__key__) allocation_behaviour = AllocationInitiator( self.agent.available_slots_jids, False) self.agent.add_behaviour(allocation_behaviour, allocation_mt) await allocation_behaviour.join() response = ACLMessage(to=str(request.sender)) response.performative = Performative.INFORM response.action = ReallocationRequest.__key__ response.protocol = 'Request' response.ontology = self.agent.ontology.name self.agent.release_lock() return response