public RoutedActorCell(ActorSystem system, InternalActorRef supervisor, Props routerProps, Props routeeProps, ActorPath path, Mailbox mailbox) : base(system, supervisor, routerProps, path, mailbox) { RouteeProps = routeeProps; routerConfig = routerProps.RouterConfig; Router = routerConfig.CreateRouter(system); routerConfig.Match() .With<Pool>(r => { var routees = new List<Routee>(); for (int i = 0; i < r.NrOfInstances; i++) { var routee = this.ActorOf(RouteeProps); routees.Add(new ActorRefRoutee(routee)); } AddRoutees(routees.ToArray()); }) .With<Group>(r => { var routees = routerConfig.GetRoutees(this).ToArray(); AddRoutees(routees); }); Self = new RoutedActorRef(path, this); }
private RouterConfig OverrideUnsetConfig(RouterConfig other) { if (other is Pool pool) { RandomPool wssConf; if (SupervisorStrategy != null && SupervisorStrategy.Equals(DefaultSupervisorStrategy) && !pool.SupervisorStrategy.Equals(DefaultSupervisorStrategy)) { wssConf = WithSupervisorStrategy(pool.SupervisorStrategy); } else { wssConf = this; } if (wssConf.Resizer == null && pool.Resizer != null) { return(wssConf.WithResizer(pool.Resizer)); } return(wssConf); } return(this); }
protected RouterConfig OverrideUnsetConfig(RouterConfig other) { if (other is NoRouter) { return(this); // NoRouter is the default, hence "neutral" } if (other is Pool) { Pool wssConf; var p = other as Pool; if (SupervisorStrategy == null || (SupervisorStrategy.Equals(Pool.DefaultStrategy) && !p.SupervisorStrategy.Equals(Pool.DefaultStrategy))) { wssConf = this.WithSupervisorStrategy(p.SupervisorStrategy); } else { wssConf = this; } if (wssConf.Resizer == null && p.Resizer != null) { return(wssConf.WithResizer(p.Resizer)); } return(wssConf); } return(this); }
public RoutedActorCell(ActorSystem system, InternalActorRef supervisor, Props routerProps, Props routeeProps, ActorPath path, Mailbox mailbox) : base(system, supervisor, routerProps, path, mailbox) { RouteeProps = routeeProps; routerConfig = routerProps.RouterConfig; Router = routerConfig.CreateRouter(system); routerConfig.Match() .With <Pool>(r => { var routees = new List <Routee>(); for (int i = 0; i < r.NrOfInstances; i++) { var routee = this.ActorOf(RouteeProps); routees.Add(new ActorRefRoutee(routee)); } AddRoutees(routees.ToArray()); }) .With <Group>(r => { var routees = routerConfig.GetRoutees(this).ToArray(); AddRoutees(routees); }); Self = new RoutedActorRef(path, this); }
public Deploy(string path, Config config, RouterConfig routerConfig, Scope scope, string dispatcher) { Path = path; Config = config; RouterConfig = routerConfig; Scope = scope; Dispatcher = dispatcher; }
internal override void Post(ActorRef sender, object message) { if (!(RouterConfig.IsManagementMessage(message)) && resizer.IsTimeForResize(Interlocked.Increment(ref _resizeCounter) - 1) && Interlocked.Exchange(ref _resizeInProgress, ResizeInProgressState.True) == ResizeInProgressState.False) { base.Post(Self, new Resize()); } base.Post(sender, message); }
public override void SendMessage(IActorRef sender, object message) { if (!(RouterConfig.IsManagementMessage(message)) && resizer.IsTimeForResize(_resizeCounter.GetAndIncrement()) && _resizeInProgress.CompareAndSet(false, true)) { base.SendMessage(Self, new Resize()); } base.SendMessage(sender, message); }
/// <summary> /// TBD /// </summary> /// <param name="envelope">TBD</param> public override void SendMessage(Envelope envelope) { if (!(RouterConfig.IsManagementMessage(envelope.Message)) && resizer.IsTimeForResize(_resizeCounter.GetAndIncrement()) && _resizeInProgress.CompareAndSet(false, true)) { base.SendMessage(new Envelope(new Resize(), Self, System)); } base.SendMessage(envelope); }
public override bool Equals(RouterConfig other) { if (!base.Equals(other)) { return(false); } var otherGroup = other as Group; if (otherGroup == null) { return(false); //should never be true due to the previous check } return(Paths.Intersect(otherGroup.Paths).Count() == Paths.Length); }
/// <summary> /// Configure the current router with an auxiliary router for routes that it does not know how to handle. /// </summary> /// <param name="routerConfig">The router to use as an auxiliary source.</param> /// <exception cref="ArgumentException"> /// This exception is thrown if the given <paramref name="routerConfig"/> is not a <see cref="ConsistentHashingGroup"/>. /// </exception> /// <returns>The router configured with the auxiliary information.</returns> public override RouterConfig WithFallback(RouterConfig routerConfig) { if (routerConfig is FromConfig || routerConfig is NoRouter) { return(base.WithFallback(routerConfig)); } else if (routerConfig is ConsistentHashingGroup other) { return(WithHashMapping(other._hashMapping)); } else { throw new ArgumentException($"Expected ConsistentHashingGroup, got {routerConfig}", nameof(routerConfig)); } }
/// <summary> /// Configure the current router with an auxiliary router for routes that it does not know how to handle. /// </summary> /// <param name="routerConfig">The router to use as an auxiliary source.</param> /// <exception cref="ArgumentException"> /// This exception is thrown if the given <paramref name="routerConfig"/> is not a <see cref="ConsistentHashingPool"/>. /// </exception> /// <returns>The router configured with the auxiliary information.</returns> public override RouterConfig WithFallback(RouterConfig routerConfig) { if (routerConfig is FromConfig || routerConfig is NoRouter) { return(OverrideUnsetConfig(routerConfig)); } else if (routerConfig is ConsistentHashingPool) { var other = routerConfig as ConsistentHashingPool; return(WithHashMapping(other._hashMapping).OverrideUnsetConfig(other)); } else { throw new ArgumentException($"Expected ConsistentHashingPool, got {routerConfig}", nameof(routerConfig)); } }
public override RouterConfig WithFallback(RouterConfig routerConfig) { if (routerConfig is FromConfig || routerConfig is NoRouter) { return(base.WithFallback(routerConfig)); } else if (routerConfig is ConsistentHashingGroup) { var other = routerConfig as ConsistentHashingGroup; return(WithHashMapping(other.HashMapping)); } else { throw new ArgumentException(string.Format("Expected ConsistentHashingGroup, got {0}", routerConfig), "routerConfig"); } }
public RoutedActorCell(ActorSystemImpl system, InternalActorRef self, Props routerProps, MessageDispatcher dispatcher, Props routeeProps, InternalActorRef supervisor) : base(system, self, routerProps, dispatcher, supervisor) { _routeeProps = routeeProps; _routerConfig = routerProps.RouterConfig; _router = _routerConfig.CreateRouter(system); _routerConfig.Match() .With<Pool>(r => { var routees = new List<Routee>(); for(int i = 0; i < r.NrOfInstances; i++) { var routee = ActorOf(_routeeProps); routees.Add(new ActorRefRoutee(routee)); } AddRoutees(routees.ToArray()); }) .With<Group>(r => { var routees = _routerConfig.GetRoutees(this).ToArray(); AddRoutees(routees); }); }
public RoutedActorCell(ActorSystemImpl system, InternalActorRef self, Props routerProps, MessageDispatcher dispatcher, Props routeeProps, InternalActorRef supervisor) : base(system, self, routerProps, dispatcher, supervisor) { _routeeProps = routeeProps; _routerConfig = routerProps.RouterConfig; _router = _routerConfig.CreateRouter(system); _routerConfig.Match() .With <Pool>(r => { var routees = new List <Routee>(); for (int i = 0; i < r.NrOfInstances; i++) { var routee = ActorOf(_routeeProps); routees.Add(new ActorRefRoutee(routee)); } AddRoutees(routees.ToArray()); }) .With <Group>(r => { var routees = _routerConfig.GetRoutees(this).ToArray(); AddRoutees(routees); }); }
private RouterConfig OverrideUnsetConfig(RouterConfig other) { if (other is NoRouter) { return(this); } else { var pool = other as Pool; if (pool != null) { RoundRobinPool wssConf; if (SupervisorStrategy != null && SupervisorStrategy.Equals(Pool.DefaultSupervisorStrategy) && !(pool.SupervisorStrategy.Equals(Pool.DefaultSupervisorStrategy))) { wssConf = this.WithSupervisorStrategy(pool.SupervisorStrategy); } else { wssConf = this; } if (wssConf.Resizer == null && pool.Resizer != null) { return(wssConf.WithResizer(pool.Resizer)); } return(wssConf); } else { return(this); } } }
public static bool NoRouter(this RouterConfig config) { return(config == null || config is NoRouter); }
public virtual RouterConfig WithFallback(RouterConfig routerConfig) { return this; }
public override RouterConfig WithFallback(RouterConfig routerConfig) { var localFallback = (ClusterRouterGroup) routerConfig; if (localFallback != null && (localFallback.Local is ClusterRouterGroup)) throw new ConfigurationException("ClusterRouterGroup is not allowed to wrap a ClusterRouterGroup"); if (localFallback != null) return Copy(Local.WithFallback(localFallback.Local).AsInstanceOf<Group>()); return Copy(Local.WithFallback(routerConfig).AsInstanceOf<Group>()); }
public override RouterConfig WithFallback(RouterConfig routerConfig) { if (routerConfig is FromConfig || routerConfig is NoRouter) { return base.WithFallback(routerConfig); } else if (routerConfig is ConsistentHashingGroup) { var other = routerConfig as ConsistentHashingGroup; return WithHashMapping(other.HashMapping); } else { throw new ArgumentException(string.Format("Expected ConsistentHashingGroup, got {0}", routerConfig), "routerConfig"); } }
/// <summary> /// Configure the current router with an auxiliary router for routes that it does not know how to handle. /// </summary> /// <param name="routerConfig">The router to use as an auxiliary source.</param> /// <exception cref="ArgumentException"> /// This exception is thrown if the given <paramref name="routerConfig"/> is not a <see cref="ConsistentHashingGroup"/>. /// </exception> /// <returns>The router configured with the auxiliary information.</returns> public override RouterConfig WithFallback(RouterConfig routerConfig) { if (routerConfig is FromConfig || routerConfig is NoRouter) { return base.WithFallback(routerConfig); } else if (routerConfig is ConsistentHashingGroup) { var other = routerConfig as ConsistentHashingGroup; return WithHashMapping(other._hashMapping); } else { throw new ArgumentException($"Expected ConsistentHashingGroup, got {routerConfig}", nameof(routerConfig)); } }
public virtual RouterConfig WithFallback(RouterConfig routerConfig) { return(this); }
public RoutedActorCell(ActorSystemImpl system, IInternalActorRef self, Props routerProps, MessageDispatcher dispatcher, Props routeeProps, IInternalActorRef supervisor) : base(system, self, routerProps, dispatcher, supervisor) { _routeeProps = routeeProps; _routerConfig = routerProps.RouterConfig; }
public override RouterConfig WithFallback(RouterConfig routerConfig) { var other = routerConfig as RemoteRouterConfig; if(other != null && other.Local is RemoteRouterConfig) throw new ArgumentException("RemoteRouterConfig is not allowed to wrap a RemoteRouterConfig", "routerConfig"); if (other != null && other.Local != null) return Copy(Local.WithFallback(other.Local).AsInstanceOf<Pool>()); return Copy(Local.WithFallback(routerConfig).AsInstanceOf<Pool>()); }
public override bool Equals(RouterConfig other) { if (!base.Equals(other)) return false; var otherRemote = other as RemoteRouterConfig; if (otherRemote == null) return false; //should never be true due to the previous check return Local.Equals(otherRemote.Local) && Nodes.Intersect(otherRemote.Nodes).Count() == Nodes.Count; }
public override RouterConfig WithFallback(RouterConfig routerConfig) { if (routerConfig is FromConfig || routerConfig is NoRouter) { return OverrideUnsetConfig(routerConfig); } else if (routerConfig is ConsistentHashingPool) { var other = routerConfig as ConsistentHashingPool; return WithHashMapping(other._hashMapping).OverrideUnsetConfig(other); } else { throw new ArgumentException(string.Format("Expected ConsistentHashingPool, got {0}", routerConfig), "routerConfig"); } }
/// <summary> /// Configure the current router with an auxiliary router for routes that it does not know how to handle. /// </summary> /// <param name="routerConfig">The router to use as an auxiliary source.</param> /// <returns>The router configured with the auxiliary information.</returns> public override RouterConfig WithFallback(RouterConfig routerConfig) { return OverrideUnsetConfig(routerConfig); }
public Deploy WithRouterConfig(RouterConfig routerConfig) { var copy = Copy(); copy.RouterConfig = routerConfig; return copy; }
public override RouterConfig WithFallback(RouterConfig other) { var localFallback = other as ClusterRouterGroup; if (localFallback != null && (localFallback.Local is ClusterRouterGroup)) { throw new ConfigurationException("ClusterRouterGroup is not allowed to wrap a ClusterRouterGroup"); } if (localFallback != null) { return Copy(Local.WithFallback(localFallback.Local).AsInstanceOf<Group>()); } return Copy(Local.WithFallback(other).AsInstanceOf<Group>()); }
public Deploy(RouterConfig routerConfig, Scope scope) : this() { RouterConfig = routerConfig; Scope = scope; }
/// <summary> /// Configure the current router with an auxiliary router for routes that it does not know how to handle. /// </summary> /// <param name="routerConfig">The router to use as an auxiliary source.</param> /// <returns>The router configured with the auxiliary information.</returns> public override RouterConfig WithFallback(RouterConfig routerConfig) { return(OverrideUnsetConfig(routerConfig)); }
public Deploy(RouterConfig routerConfig) { RouterConfig = routerConfig; }
private RouterConfig OverrideUnsetConfig(RouterConfig other) { if (other is NoRouter) { return this; } else { var pool = other as Pool; if (pool != null) { ConsistentHashingPool wssConf; if (SupervisorStrategy != null && SupervisorStrategy.Equals(Pool.DefaultSupervisorStrategy) && !(pool.SupervisorStrategy.Equals(Pool.DefaultSupervisorStrategy))) { wssConf = this.WithSupervisorStrategy(pool.SupervisorStrategy); } else { wssConf = this; } if (wssConf.Resizer == null && pool.Resizer != null) return wssConf.WithResizer(pool.Resizer); return wssConf; } else { return this; } } }
public override RouterConfig WithFallback(RouterConfig routerConfig) { var otherClusterRouterPool = (ClusterRouterPool) routerConfig; if(otherClusterRouterPool != null && otherClusterRouterPool.Local is ClusterRouterPool) throw new ConfigurationException("ClusterRouterPool is not allowed to wrap a ClusterRouterPool"); if (otherClusterRouterPool != null) return Copy(Local.WithFallback(otherClusterRouterPool.Local).AsInstanceOf<Pool>()); return Copy(Local.WithFallback(routerConfig).AsInstanceOf<Pool>()); }
/// <summary> /// TBD /// </summary> /// <param name="routerConfig">TBD</param> /// <returns>TBD</returns> public override RouterConfig WithFallback(RouterConfig routerConfig) { return(routerConfig); }