Class AdaptiveLoadBalancingPool
A router pool that performs load balancing of messages to cluster nodes based on cluster metric data.
It uses random selection of routees based on probabilities derived from the remaining capacity of corresponding node.
The configuration parameter trumps the constructor arguments. This means that
if you provide nrOfInstances
during instantiation they will be ignored if
the router is defined in the configuration file for the actor being used.
Supervision Setup
Any routees that are created by a router will be created as the router's children. The router is therefore also the children's supervisor.
The supervision strategy of the router actor can be configured with [[#withSupervisorStrategy]]. If no strategy is provided, routers default to a strategy of “always escalateâ€. This means that errors are passed up to the router's supervisor for handling.
The router's supervisor will treat the error as an error with the router itself. Therefore a directive to stop or restart will cause the router itself to stop or restart. The router, in turn, will cause its children to stop and restart.
Inherited Members
Namespace: Akka.Cluster.Metrics
Assembly: Akka.Cluster.Metrics.dll
Syntax
public sealed class AdaptiveLoadBalancingPool : Pool, ISurrogated, IEquatable<RouterConfig>, IEquatable<Pool>
Constructors
| Improve this Doc View SourceAdaptiveLoadBalancingPool(IMetricsSelector, Int32, SupervisorStrategy, String, Boolean)
Creates instance of AdaptiveLoadBalancingPool
Declaration
public AdaptiveLoadBalancingPool(IMetricsSelector metricsSelector = null, int nrOfInstances = 0, SupervisorStrategy supervisorStrategy = null, string routerDispatcher = null, bool usePoolDispatcher = false)
Parameters
Type | Name | Description |
---|---|---|
IMetricsSelector | metricsSelector | Decides what probability to use for selecting a routee, based on remaining capacity as indicated by the node metrics |
Int32 | nrOfInstances | Initial number of routees in the pool |
SupervisorStrategy | supervisorStrategy | strategy for supervising the routees, see 'Supervision Setup' in class summary |
String | routerDispatcher | Dispatcher to use for the router head actor, which handles supervision, death watch and router management messages |
Boolean | usePoolDispatcher |
AdaptiveLoadBalancingPool(Config)
Creates instance of AdaptiveLoadBalancingPool using configuration
Declaration
public AdaptiveLoadBalancingPool(Config config)
Parameters
Type | Name | Description |
---|---|---|
Config | config |
Properties
| Improve this Doc View SourceMetricsSelector
Metrics selector
Declaration
public IMetricsSelector MetricsSelector { get; }
Property Value
Type | Description |
---|---|
IMetricsSelector |
Resizer
Retrieve the resizer to use when dynamically allocating routees to the pool.
Declaration
public override Resizer Resizer { get; }
Property Value
Type | Description |
---|---|
Resizer |
Overrides
Methods
| Improve this Doc View SourceCreateRouter(ActorSystem)
Creates a router that is responsible for routing messages to routees within the provided system
.
Declaration
public override Router CreateRouter(ActorSystem system)
Parameters
Type | Name | Description |
---|---|---|
ActorSystem | system | The ActorSystem this router belongs to. |
Returns
Type | Description |
---|---|
Router | The newly created router tied to the given system. |
Overrides
| Improve this Doc View SourceGetNrOfInstances(ActorSystem)
Used by the Akka.Routing.RoutedActorCell to determine the initial number of routees.
Declaration
public override int GetNrOfInstances(ActorSystem system)
Parameters
Type | Name | Description |
---|---|---|
ActorSystem | system | The actor system that owns this router. |
Returns
Type | Description |
---|---|
Int32 | The number of routees associated with this pool. |
Overrides
| Improve this Doc View SourceRoutingLogicController(RoutingLogic)
Possibility to define an actor for controlling the routing logic from external stimuli(e.g.monitoring metrics). This actor will be a child of the router "head" actor. Management messages not handled by the "head" actor are delegated to this controller actor.
Declaration
public override Props RoutingLogicController(RoutingLogic routingLogic)
Parameters
Type | Name | Description |
---|---|---|
RoutingLogic | routingLogic |
Returns
Type | Description |
---|---|
Props |
Overrides
| Improve this Doc View SourceToSurrogate(ActorSystem)
Creates a surrogate representation of the current router.
Declaration
public override ISurrogate ToSurrogate(ActorSystem system)
Parameters
Type | Name | Description |
---|---|---|
ActorSystem | system | The actor system that owns this router. |
Returns
Type | Description |
---|---|
ISurrogate | The surrogate representation of the current router. |
Overrides
| Improve this Doc View SourceWithDispatcher(String)
Setting the dispatcher to be used for the router head actor, which handles supervision, death watch and router management messages.
Declaration
public AdaptiveLoadBalancingPool WithDispatcher(string dispatcherId)
Parameters
Type | Name | Description |
---|---|---|
String | dispatcherId |
Returns
Type | Description |
---|---|
AdaptiveLoadBalancingPool |
WithFallback(RouterConfig)
Configure the current router with an auxiliary router for routes that it does not know how to handle.
Declaration
public override RouterConfig WithFallback(RouterConfig routerConfig)
Parameters
Type | Name | Description |
---|---|---|
RouterConfig | routerConfig | The router to use as an auxiliary source. |
Returns
Type | Description |
---|---|
RouterConfig | The router configured with the auxiliary information. |
Overrides
| Improve this Doc View SourceWithSupervisorStrategy(SupervisorStrategy)
Setting the supervisor strategy to be used for the “head†Router actor.
Declaration
public AdaptiveLoadBalancingPool WithSupervisorStrategy(SupervisorStrategy strategy)
Parameters
Type | Name | Description |
---|---|---|
SupervisorStrategy | strategy |
Returns
Type | Description |
---|---|
AdaptiveLoadBalancingPool |