Пример #1
0
 private PeerConnection MapNodeToConnection(ExternalRouteRegistration routeRegistration, ReceiverIdentifier nodeIdentifier)
 {
     if (!nodeToConnectionMap.TryGetValue(nodeIdentifier, out var peerConnection))
     {
         peerConnection = new PeerConnection
         {
             Node      = routeRegistration.Peer,
             Health    = routeRegistration.Health,
             Connected = false
         };
         nodeToConnectionMap[nodeIdentifier] = peerConnection;
     }
     return(peerConnection);
 }
Пример #2
0
 private void MapMessageToActor(InternalRouteRegistration routeRegistration, MessageContract messageContract)
 {
     if (!messageToActorMap.TryGetValue(messageContract.Message, out var actors))
     {
         actors = new HashedLinkedList <ReceiverIdentifier>();
         messageToActorMap[messageContract.Message] = actors;
     }
     if (!actors.Contains(routeRegistration.ReceiverIdentifier))
     {
         var registration = new ReceiverIdentifierRegistration(routeRegistration.ReceiverIdentifier,
                                                               messageContract.KeepRegistrationLocal);
         actors.InsertLast(registration);
     }
 }
Пример #3
0
        private void MapMessageToNode(ExternalRouteRegistration routeRegistration, ReceiverIdentifier nodeIdentifier)
        {
            var messageIdentifier = routeRegistration.Route.Message;

            if (!messageToNodeMap.TryGetValue(messageIdentifier, out var nodes))
            {
                nodes = new HashedLinkedList <ReceiverIdentifier>();
                messageToNodeMap[messageIdentifier] = nodes;
            }
            if (!nodes.Contains(nodeIdentifier))
            {
                nodes.InsertLast(nodeIdentifier);
            }
        }
Пример #4
0
        public Bcl.IEnumerable <ILocalSendingSocket <IMessage> > FindRoutes(InternalRouteLookupRequest lookupRequest)
        {
            HashedLinkedList <ReceiverIdentifier> actors;
            var sockets = new Bcl.List <ILocalSendingSocket <IMessage> >();
            ILocalSendingSocket <IMessage> socket;

            if (lookupRequest.ReceiverIdentity.IsSet())
            {
                if (lookupRequest.ReceiverIdentity.IsMessageHub())
                {
                    if (messageHubs.TryGetValue(lookupRequest.ReceiverIdentity, out socket))
                    {
                        sockets.Add(socket);
                    }
                }
                else
                {
                    if (lookupRequest.ReceiverIdentity.IsActor())
                    {
                        if (actorToSocketMap.TryGetValue(lookupRequest.ReceiverIdentity, out socket))
                        {
                            if (messageToActorMap.TryGetValue(lookupRequest.Message, out actors))
                            {
                                if (actors.Contains(lookupRequest.ReceiverIdentity))
                                {
                                    sockets.Add(socket);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                if (messageToActorMap.TryGetValue(lookupRequest.Message, out actors))
                {
                    if (lookupRequest.Distribution == DistributionPattern.Unicast)
                    {
                        if (actorToSocketMap.TryGetValue(Get(actors), out socket))
                        {
                            sockets.Add(socket);
                        }
                    }
                    else
                    {
                        if (lookupRequest.Distribution == DistributionPattern.Broadcast)
                        {
                            foreach (var actor in actors)
                            {
                                if (actorToSocketMap.TryGetValue(actor, out socket))
                                {
                                    sockets.Add(socket);
                                }
                            }
                        }
                    }
                }
            }

            return(sockets);
        }