def __migrate_remote(self, actor, address): module = actor.getmodule() modulename = module.__name__ if modulename == '__main__': raise Exception('Cannot migrate actors defined in the main module') if ids.ip_from_loc(self.here) != ids.ip_from_loc(address): # Non-local migration src = inspect.getsource(module) local_theatre().store_script(module.__name__, src) conn = rpc.RPCConnector(address) remote_theatre = conn.connect() remote_theatre.get_script(modulename) remote_theatre.disconnect() conn = rpc.RPCConnector(address) actor.state.add_arrived() remote_theatre = conn.connect() remote_theatre.incoming_actor(actor.state) remote_theatre.disconnect()
def incoming_actor(self, actorstate): # Create actor but don't start # TODO: FIX- generation of id, handle local and non-local migrations. log.debug(self, 'receieved migrating actor %s' % actorstate) actor = Actor(local_theatre()) actor.state = actorstate old_actor_id = actor.state.actor_id type = actor.state.actortype if ids.ip(old_actor_id) == ids.ip_from_loc(self.here): # Migration has been local actor_id = ids.change_port(old_actor_id, ids.port_from_loc(self.here)) else: actor_id = ids.change_host(old_actor_id, self.here, self.shared_data.next_id_num()) actor.state.actor_id = actor_id self.__local_actor_store.add_network_actor(actor, actor_id) actor.start() # At the moment even core migrations trigger re-registrations # Could probably forgo these if core migrations are frequent. local_theatre().globally_reregister_network_actor(actor_id, type, old_actor_id) names = actor.state.names for name in names: local_theatre().name(name, actor_id)
def attach(self, name, at): if self.name is None: self.name = name if ids.ip(self.actor_id) != ids.ip_from_loc(at): migrate_to(at)
def store_type(self, actor, manager): ip = ids.ip_from_loc(manager) self.nodes[ip].store_type(actor, manager) self.draw()
def store_name(self, name, actor, manager): ip = ids.ip_from_loc(manager) self.nodes[ip].store_name(name, actor, manager) self.draw()
def add_host(self, loc): ip = ids.ip_from_loc(loc) if ip not in self.nodes: self.nodes[ip] = VisNode(ip) self.nodes[ip].add_host(loc) self.draw()