Ejemplo n.º 1
0
 public void Setup()
 {
     _queue       = new BlockingCollection <string>();
     timeout      = TimeSpan.FromMinutes(1);
     _system      = ActorSystem.Create("system");
     _pipe        = _system.ActorOf(KilometrePipeline.Prop(_queue));
     _distributor = _system.ActorOf(PipelineDistributor.Prop("roundrobin", _queue));
 }
Ejemplo n.º 2
0
        private IActorRef RouterFactory(string routerStrategy, BlockingCollection <string> queue)
        {
            var       resizer = new DefaultResizer(lower: 4, upper: 8, pressureThreshold: 1, rampupRate: 0.2, backoffThreshold: 0.3, backoffRate: 0.1, messagesPerResize: 1000);
            IActorRef routerActor;

            switch (routerStrategy.ToLower())
            {
            case "consistenthashing":
                routerActor = Context.System.ActorOf(KilometrePipeline.Prop(queue).WithRouter(new ConsistentHashingPool(4).WithResizer(resizer)), "ConsistentHashing");
                break;

            case "smallestmailbox":
                routerActor = Context.System.ActorOf(KilometrePipeline.Prop(queue).WithRouter(new SmallestMailboxPool(4).WithResizer(resizer)), "SmallestMailbox");
                break;

            default:
                routerActor = Context.System.ActorOf(KilometrePipeline.Prop(queue).WithRouter(new RoundRobinPool(4).WithResizer(resizer)), "RoundRobin");
                break;
            }
            //var t = Context.System.ActorOf(Props..Create<KilometrePipeline>().WithRouter(new ConsistentHashingPool(4).WithResizer(resizer)), "ConsistentHashing");
            return(routerActor);
        }