def initiate(self, agent, static_name=None): self.static_name = static_name if self.static_name: agent.resolve_alert(self.static_name, "ok") # Handle a situation when this agent was started when # host agent was still in the 'lobby' and when HA entered # shard it was not yet in a partnership with this agent. # Without code below, such agent would be left there # waiting. if (self.recipient.shard == 'lobby' and agent.get_shard_id() != 'lobby'): return agent.call_remote(self.recipient, 'switch_shard', agent.get_shard_id())
def initiate(self, agent): # Host Agent on the other end is about to join our shard, # his address will change. shard = agent.get_shard_id() self.recipient = recipient.Agent(self.recipient.key, shard) if self.allocation_id is None: f = agent.allocate_resource(hosts=1) f.add_callback(self.set_allocation_id) return f
def discover(cls, agent): return agent.discover_service('alert', timeout=1, shard=agent.get_shard_id())