private void MapActorToNode(ExternalRouteRegistration routeRegistration, ReceiverIdentifier nodeIdentifier) { if (!nodeActors.TryGetValue(nodeIdentifier, out var actors)) { actors = new Bcl.HashSet <ReceiverIdentifier>(); nodeActors[nodeIdentifier] = actors; } actors.Add(routeRegistration.Route.Receiver); }
private void MapActorToMessage(ExternalRouteRegistration routeRegistration) { if (!actorToMessageMap.TryGetValue(routeRegistration.Route.Receiver, out var actorMessages)) { actorMessages = new Bcl.HashSet <MessageIdentifier>(); actorToMessageMap[routeRegistration.Route.Receiver] = actorMessages; } actorMessages.Add(routeRegistration.Route.Message); }
private static void MapActorToMessage(InternalRouteRegistration routeRegistration, Bcl.IDictionary <ReceiverIdentifier, Bcl.HashSet <MessageIdentifier> > actorMessages, MessageContract messageContract) { if (!actorMessages.TryGetValue(routeRegistration.ReceiverIdentifier, out var messages)) { messages = new Bcl.HashSet <MessageIdentifier>(); actorMessages[routeRegistration.ReceiverIdentifier] = messages; } messages.Add(messageContract.Message); }
private void MapMessageHubToNode(ExternalRouteRegistration routeRegistration, ReceiverIdentifier nodeIdentifier) { var messageHub = routeRegistration.Route.Receiver; if (!nodeMessageHubs.TryGetValue(nodeIdentifier, out var messageHubs)) { messageHubs = new Bcl.HashSet <ReceiverIdentifier>(); nodeMessageHubs[nodeIdentifier] = messageHubs; } messageHubs.Add(messageHub); }
private void MapConnectionToNode(PeerConnection connection) { var uri = connection.Node.Uri.ToSocketAddress(); if (!uriToNodeMap.TryGetValue(uri, out var nodes)) { nodes = new Bcl.HashSet <ReceiverIdentifier>(); uriToNodeMap[uri] = nodes; } nodes.Add(new ReceiverIdentifier(connection.Node.SocketIdentity)); logger.Debug($"[{nodes.Count}] node(s) registered at {uri}."); }
private Bcl.IEnumerable <MessageActorRoute> GetNodeActors(ReceiverIdentifier node) { return(GetNodeMessageToActorsMap() .Select(ma => new MessageActorRoute { Message = ma.Key, Actors = ma.Value .Select(a => new ReceiverIdentifierRegistration(a, false)) .ToList() }) .ToList()); Bcl.IDictionary <MessageIdentifier, Bcl.HashSet <ReceiverIdentifier> > GetNodeMessageToActorsMap() { var messageActors = new Bcl.Dictionary <MessageIdentifier, Bcl.HashSet <ReceiverIdentifier> >(); if (nodeActors.TryGetValue(node, out var actors)) { foreach (var actor in actors) { if (actorToMessageMap.TryGetValue(actor, out var actorMessages)) { foreach (var message in actorMessages) { if (!messageActors.TryGetValue(message, out var tmpActors)) { tmpActors = new Bcl.HashSet <ReceiverIdentifier>(); messageActors[message] = tmpActors; } tmpActors.Add(actor); } } } } return(messageActors); } }