Beispiel #1
0
        protected ClusterRoundRobinSpec(ClusterRoundRobinSpecConfig config)
            : base(config, typeof(ClusterRoundRobinSpec))
        {
            _config = config;

            router1 = new Lazy <IActorRef>(() => Sys.ActorOf(FromConfig.Instance.Props(Props.Create <ClusterRoundRobinSpecConfig.SomeActor>()), "router1"));
            router2 = new Lazy <IActorRef>(() => Sys.ActorOf(
                                               new ClusterRouterPool(
                                                   new RoundRobinPool(0),
                                                   new ClusterRouterPoolSettings(3, 1, true, null)).Props(Props.Create <ClusterRoundRobinSpecConfig.SomeActor>()),
                                               "router2"));
            router3 = new Lazy <IActorRef>(() => Sys.ActorOf(FromConfig.Instance.Props(Props.Create <ClusterRoundRobinSpecConfig.SomeActor>()), "router3"));
            router4 = new Lazy <IActorRef>(() => Sys.ActorOf(FromConfig.Instance.Props(), "router4"));
            router5 = new Lazy <IActorRef>(() => Sys.ActorOf(new RoundRobinPool(0).Props(Props.Create <ClusterRoundRobinSpecConfig.SomeActor>()), "router5"));
        }
        private Dictionary<Address, int> ReceiveReplays(ClusterRoundRobinSpecConfig.IRouteeType routeeType, int expectedReplies)
        {
            var zero = Roles.Select(c => GetAddress(c)).ToDictionary(c => c, c => 0);
            var replays = ReceiveWhile(5.Seconds(), msg =>
            {
                var routee = msg as ClusterRoundRobinSpecConfig.Reply;
                if (routee != null && routee.RouteeType.GetType() == routeeType.GetType())
                    return FullAddress(routee.ActorRef);
                return null;
            }, expectedReplies).Aggregate(zero, (replyMap, address) =>
            {
                replyMap[address]++;
                return replyMap;
            });

            return replays;
        }
        protected ClusterRoundRobinSpec(ClusterRoundRobinSpecConfig config)
            : base(config)
        {
            _config = config;

            router1 = new Lazy<IActorRef>(() => Sys.ActorOf(FromConfig.Instance.Props(Props.Create<ClusterRoundRobinSpecConfig.SomeActor>()), "router1"));
            router2 = new Lazy<IActorRef>(() => Sys.ActorOf(
                new ClusterRouterPool(
                    new RoundRobinPool(0),
                    new ClusterRouterPoolSettings(3, 1, true, null)).Props(Props.Create<ClusterRoundRobinSpecConfig.SomeActor>()),
                "router2"));
            router3 = new Lazy<IActorRef>(() => Sys.ActorOf(FromConfig.Instance.Props(Props.Create<ClusterRoundRobinSpecConfig.SomeActor>()), "router3"));
            router4 = new Lazy<IActorRef>(() => Sys.ActorOf(FromConfig.Instance.Props(), "router4"));
            router5 = new Lazy<IActorRef>(() => Sys.ActorOf(new RoundRobinPool(0).Props(Props.Create<ClusterRoundRobinSpecConfig.SomeActor>()), "router5"));
        }