public override Deploy ParseConfig(string key, Config config) { var deploy = base.ParseConfig(key, config); if (deploy == null) { return(null); } if (deploy.Config.GetBoolean("cluster.enabled")) { if (deploy.Scope != Deploy.NoScopeGiven) { throw new ConfigurationException(string.Format("Cluster deployment can't be combined with scope [{0}]", deploy.Scope)); } if (deploy.RouterConfig is RemoteRouterConfig) { throw new ConfigurationException(string.Format("Cluster deployment can't be combined with [{0}]", deploy.Config)); } if (deploy.RouterConfig is Pool) { return (deploy.WithScope(scope: ClusterScope.Instance) .WithRouterConfig(new ClusterRouterPool(deploy.RouterConfig as Pool, ClusterRouterPoolSettings.FromConfig(deploy.Config)))); } else if (deploy.RouterConfig is Group) { return (deploy.WithScope(scope: ClusterScope.Instance) .WithRouterConfig(new ClusterRouterGroup(deploy.RouterConfig as Group, ClusterRouterGroupSettings.FromConfig(deploy.Config)))); } else { throw new ArgumentException(string.Format("Cluster-aware router can only wrap Pool or Group, got [{0}]", deploy.RouterConfig.GetType())); } } else { return(deploy); } }
public void Cluster_aware_routers_must_use_provided_supervisor_strategy() { var escalator = new OneForOneStrategy( exception => { TestActor.Tell("supervised"); return(Directive.Stop); }); var settings = new ClusterRouterPoolSettings(1, 1, true); var router = Sys.ActorOf( new ClusterRouterPool(new RoundRobinPool(1, null, escalator, Dispatchers.DefaultDispatcherId), settings) .Props(Props.Create(() => new KillableActor(TestActor))), "therouter"); router.Tell("go away"); ExpectMsg("supervised"); }
private void Must_have_routees_at_startup() { AwaitClusterUp(_config.First, _config.Second, _config.Third); Within(TimeSpan.FromSeconds(20), () => { RunOn(() => { var pool = new RoundRobinPool(10); var routerPoolSettings = new ClusterRouterPoolSettings(1000, 1, true, "b"); var config = new ClusterRouterPool(pool, routerPoolSettings); var router = Sys.ActorOf(Props.Create(() => new EchoActor()).WithRouter(config), "myRouter"); AwaitAssert(() => { router.Tell("i"); ExpectMsg("i", TimeSpan.FromMilliseconds(100)); }, interval: TimeSpan.FromMilliseconds(250)); }, _config.First); EnterBarrier("after-1"); }); }
private static Proto.Msg.ClusterRouterPoolSettings ClusterRouterPoolSettingsToProto(ClusterRouterPoolSettings clusterRouterPoolSettings) { var message = new Proto.Msg.ClusterRouterPoolSettings(); message.TotalInstances = (uint)clusterRouterPoolSettings.TotalInstances; message.MaxInstancesPerNode = (uint)clusterRouterPoolSettings.MaxInstancesPerNode; message.AllowLocalRoutees = clusterRouterPoolSettings.AllowLocalRoutees; message.UseRole = clusterRouterPoolSettings.UseRole ?? string.Empty; return(message); }