private async Task MemberJoinedAsync(MemberJoinedEvent msg) { _logger.LogInformation("Member Joined {0}", msg.Address); //TODO: right now we transfer ownership on a per actor basis. //this could be done in a batch //ownership is also racy, new nodes should maybe forward requests to neighbours (?) foreach (var(actorId, _) in _partition.ToArray()) { var address = await MemberList.GetMemberAsync(actorId, _kind); if (address != ProcessRegistry.Instance.Address) { TransferOwnership(actorId, address); } } }
private void GetPid(IContext context, PidCacheRequest msg) { if (_cache.TryGetValue(msg.Name, out var pid)) { context.Respond(new ActorPidResponse { Pid = pid }); return; //found the pid, replied, exit } var name = msg.Name; var kind = msg.Kind; context.ReenterAfter(MemberList.GetMemberAsync(name, kind), address => { var remotePid = Partition.PartitionForKind(address.Result, kind); var req = new ActorPidRequest { Kind = kind, Name = name }; var resp = remotePid.RequestAsync <ActorPidResponse>(req); context.ReenterAfter(resp, t => { var res = t.Result; var respid = res.Pid; var key = respid.ToShortString(); _cache[name] = respid; _reverseCache[key] = name; context.Watch(respid); context.Respond(res); return(Actor.Done); }); return(Actor.Done); }); }