Routee that sends the messages to an akka.actor.ActorRef.
Routee that sends the messages to an akka.actor.ActorSelection.
Add a routee by sending this message to the router.
Add a routee by sending this message to the router. It may be handled after other messages.
Increase or decrease the number of routees in a Pool.
Increase or decrease the number of routees in a Pool. It may be handled after other messages.
Positive change
will add that number of routees to the Pool.
Negative change
will remove that number of routees from the Pool.
Routees are stopped by sending a akka.actor.PoisonPill to the routee.
Precautions are taken reduce the risk of dropping messages that are concurrently
being routed to the removed routee, but it is not guaranteed that messages are not
lost.
A router pool that will try to redistribute work from busy routees to idle routees.
A router pool that will try to redistribute work from busy routees to idle routees. All routees share the same mailbox.
Although the technique used in this implementation is commonly known as "work stealing", the actual implementation is probably best described as "work donating" because the actor of which work is being stolen takes the initiative.
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.
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.
initial number of routees in the pool
strategy for supervising the routees, see 'Supervision Setup'
dispatcher to use for the router head actor, which handles supervision, death watch and router management messages
Used to broadcast a message to all routees in a router; only the contained message will be forwarded, i.e.
Used to broadcast a message to all routees in a router; only the
contained message will be forwarded, i.e. the Broadcast(...)
envelope will be stripped off.
A router group that broadcasts a message to all its routees.
A router group that broadcasts a message to all its routees.
The configuration parameter trumps the constructor arguments. This means that
if you provide paths
during instantiation they will be ignored if
the router is defined in the configuration file for the actor being used.
string representation of the actor paths of the routees, messages are sent with akka.actor.ActorSelection to these paths
dispatcher to use for the router head actor, which handles router management messages
A router pool that broadcasts a message to all its routees.
A router pool that broadcasts a message to all its routees.
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.
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.
initial number of routees in the pool
optional resizer that dynamically adjust the pool size
strategy for supervising the routees, see 'Supervision Setup'
dispatcher to use for the router head actor, which handles supervision, death watch and router management messages
Broadcasts a message to all its routees.
Broadcasts a message to all its routees.
Consistent Hashing node ring implementation.
Consistent Hashing node ring implementation.
A good explanation of Consistent Hashing: http://weblogs.java.net/blog/tomwhite/archive/2007/11/consistent_hash.html
Note that toString of the ring nodes are used for the node hash, i.e. make sure it is different for different nodes.
A router group that uses consistent hashing to select a routee based on the sent message.
A router group that uses consistent hashing to select a routee based on the sent message. The selection is described in akka.routing.ConsistentHashingRoutingLogic.
The configuration parameter trumps the constructor arguments. This means that
if you provide paths
during instantiation they will be ignored if
the router is defined in the configuration file for the actor being used.
string representation of the actor paths of the routees, messages are sent with akka.actor.ActorSelection to these paths
number of virtual nodes per node, used in akka.routing.ConsistentHash
partial function from message to the data to use for the consistent hash key
dispatcher to use for the router head actor, which handles router management messages
A router pool that uses consistent hashing to select a routee based on the sent message.
A router pool that uses consistent hashing to select a routee based on the sent message. The selection is described in akka.routing.ConsistentHashingRoutingLogic.
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.
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.
initial number of routees in the pool
optional resizer that dynamically adjust the pool size
number of virtual nodes per node, used in akka.routing.ConsistentHash
partial function from message to the data to use for the consistent hash key
strategy for supervising the routees, see 'Supervision Setup'
dispatcher to use for the router head actor, which handles supervision, death watch and router management messages
Uses consistent hashing to select a routee based on the sent message.
Uses consistent hashing to select a routee based on the sent message.
There is 3 ways to define what data to use for the consistent hash key.
1. You can define hashMapping
/ withHashMapper
of the router to map incoming messages to their consistent hash key.
This makes the decision transparent for the sender.
2. The messages may implement akka.routing.ConsistentHashingRouter.ConsistentHashable. The key is part of the message and it's convenient to define it together with the message definition.
3. The messages can be be wrapped in a akka.routing.ConsistentHashingRouter.ConsistentHashableEnvelope to define what data to use for the consistent hash key. The sender knows the key to use.
These ways to define the consistent hash key can be use together and at
the same time for one router. The hashMapping
is tried first.
the actor system hosting this router
number of virtual nodes per node, used in akka.routing.ConsistentHash
partial function from message to the data to use for the consistent hash key
If a custom router implementation is not a Group nor a Pool it may extend this base class.
This resizer resizes the pool to an optimal size that provides the most message throughput.
This resizer resizes the pool to an optimal size that provides the most message throughput.
This resizer works best when you expect the pool size to performance function to be a convex function.
For example, when you have a CPU bound tasks, the optimal size is bound to the number of CPU cores. When your task is IO bound, the optimal size is bound to optimal number of concurrent connections to that IO service - e.g. a 4 node elastic search cluster may handle 4-8 concurrent requests at optimal speed.
It achieves this by keeping track of message throughput at each pool size and performing the following three resizing operations (one at a time) periodically:
* Downsize if it hasn't seen all routees ever fully utilized for a period of time. * Explore to a random nearby pool size to try and collect throughput metrics. * Optimize to a nearby pool size with a better (than any other nearby sizes) throughput metrics.
When the pool is fully-utilized (i.e. all routees are busy), it randomly choose between exploring and optimizing. When the pool has not been fully-utilized for a period of time, it will downsize the pool to the last seen max utilization multiplied by a configurable ratio.
By constantly exploring and optimizing, the resizer will eventually walk to the optimal size and remain nearby. When the optimal size changes it will start walking towards the new one.
It keeps a performance log so it's stateful as well as having a larger memory footprint than the default Resizer. The memory usage is O(n) where n is the number of sizes you allow, i.e. upperBound - lowerBound.
For documentation about the parameters, see the reference.conf - akka.actor.deployment.default.optimal-size-exploring-resizer
Implementation of Resizer that adjust the Pool based on specified thresholds.
The fewest number of routees the router should ever have.
The most number of routees the router should ever have. Must be greater than or equal to lowerBound
.
Threshold to evaluate if routee is considered to be busy (under pressure). Implementation depends on this value (default is 1).
pressureThreshold
messages in their mailbox. Note that estimating mailbox size of
default UnboundedMailbox is O(N) operation.Percentage to increase capacity whenever all routees are busy. For example, 0.2 would increase 20% (rounded up), i.e. if current capacity is 6 it will request an increase of 2 more routees.
Minimum fraction of busy routees before backing off. For example, if this is 0.3, then we'll remove some routees only when less than 30% of routees are busy, i.e. if current capacity is 10 and 3 are busy then the capacity is unchanged, but if 2 or less are busy the capacity is decreased. Use 0.0 or negative to avoid removal of routees.
Fraction of routees to be removed when the resizer reaches the backoffThreshold. For example, 0.1 would decrease 10% (rounded up), i.e. if current capacity is 9 it will request an decrease of 1 routee.
Number of messages between resize operation. Use 1 to resize before each message.
Java API: Wraps a akka.actor.Props to mark the actor as externally configurable to be used with a router.
Java API: Wraps a akka.actor.Props to mark the actor as externally configurable to be used with a router. If a akka.actor.Props is not wrapped with FromConfig then the actor will ignore the router part of the deployment section in the configuration.
This can be used when the dispatcher to be used for the head Router needs to be configured (defaults to default-dispatcher).
Sending this message to a router will make it send back its currently used routees.
Sending this message to a router will make it send back its currently used routees. A Routees message is sent asynchronously to the "requester" containing information about what routees the router is routing over.
RouterConfig
for router actor with routee actors that are created external to the
router and the router sends messages to the specified path using actor selection,
without watching for termination.
Java API: Base class for custom router Group
Listeners is a generic trait to implement listening capability on an Actor.
Listeners is a generic trait to implement listening capability on an Actor.
Use the gossip(msg)
method to have it sent to the listeners.
Send Listen(self)
to start listening.
Send Deafen(self)
to stop listening.
Send WithListeners(fun)
to traverse the current listeners.
Routing configuration that indicates no routing; this is also the default value which hence overrides the merge strategy in order to accept values from lower-precedence sources.
Routing configuration that indicates no routing; this is also the default value which hence overrides the merge strategy in order to accept values from lower-precedence sources. The decision whether or not to create a router is taken in the LocalActorRefProvider based on Props.
RouterConfig
for router actor that creates routees as child actors and removes
them from the router if they terminate.
Java API: Base class for custom router Pool
A router group that randomly selects one of the target routees to send a message to.
A router group that randomly selects one of the target routees to send a message to.
The configuration parameter trumps the constructor arguments. This means that
if you provide paths
during instantiation they will be ignored if
the router is defined in the configuration file for the actor being used.
string representation of the actor paths of the routees, messages are sent with akka.actor.ActorSelection to these paths
dispatcher to use for the router head actor, which handles router management messages
A router pool that randomly selects one of the target routees to send a message to.
A router pool that randomly selects one of the target routees to send a message to.
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.
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.
initial number of routees in the pool
optional resizer that dynamically adjust the pool size
strategy for supervising the routees, see 'Supervision Setup'
dispatcher to use for the router head actor, which handles supervision, death watch and router management messages
Randomly selects one of the target routees to send a message to
Randomly selects one of the target routees to send a message to
Remove a specific routee by sending this message to the router.
Remove a specific routee by sending this message to the router. It may be handled after other messages.
For a pool, with child routees, the routee is stopped by sending a akka.actor.PoisonPill to the routee. Precautions are taken reduce the risk of dropping messages that are concurrently being routed to the removed routee, but there are no guarantees.
Pool routers with dynamically resizable number of routees are implemented by providing a Resizer implementation in the akka.routing.Pool configuration.
A router group that uses round-robin to select a routee.
A router group that uses round-robin to select a routee. For concurrent calls, round robin is just a best effort.
The configuration parameter trumps the constructor arguments. This means that
if you provide paths
during instantiation they will be ignored if
the router is defined in the configuration file for the actor being used.
string representation of the actor paths of the routees, messages are sent with akka.actor.ActorSelection to these paths
dispatcher to use for the router head actor, which handles router management messages
A router pool that uses round-robin to select a routee.
A router pool that uses round-robin to select a routee. For concurrent calls, round robin is just a best effort.
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.
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.
initial number of routees in the pool
optional resizer that dynamically adjust the pool size
strategy for supervising the routees, see 'Supervision Setup'
dispatcher to use for the router head actor, which handles supervision, death watch and router management messages
Uses round-robin to select a routee.
Uses round-robin to select a routee. For concurrent calls, round robin is just a best effort.
Abstraction of a destination for messages routed via a Router.
Message used to carry information about what routees the router is currently using.
Message used to carry information about what routees the router is currently using.
For each message that is sent through the router via the #route method the RoutingLogic decides to which Routee to send the message.
For each message that is sent through the router via the #route method the
RoutingLogic decides to which Routee to send the message. The Routee itself
knows how to perform the actual sending. Normally the RoutingLogic picks one of the
contained routees
, but that is up to the implementation of the RoutingLogic.
A Router
is immutable and the RoutingLogic must be thread safe.
This trait represents a router factory: it produces the actual router actor and creates the routing table (a function which determines the recipients for each message which is to be dispatched).
This trait represents a router factory: it produces the actual router actor and creates the routing table (a function which determines the recipients for each message which is to be dispatched). The resulting RoutedActorRef optimizes the sending of the message so that it does NOT go through the router’s mailbox unless the route returns an empty recipient set.
Caution: This means that the route function is evaluated concurrently without protection by the RoutedActorRef: either provide a reentrant (i.e. pure) implementation or do the locking yourself!
Caution: Please note that the akka.routing.Router which needs to
be returned by createActor()
should not send a message to itself in its
constructor or preStart()
or publish its self reference from there: if
someone tries sending a message to that reference before the constructor of
RoutedActorRef has returned, there will be a NullPointerException
!
Only the contained message will be forwarded to the destination, i.e.
Only the contained message will be forwarded to the destination, i.e. the envelope will be stripped off.
The interface of the routing logic that is used in a Router to select destination routed messages.
The interface of the routing logic that is used in a Router to select destination routed messages.
The implementation must be thread safe.
A router group that broadcasts the message to all routees, and replies with the first response.
A router group that broadcasts the message to all routees, and replies with the first response.
The configuration parameter trumps the constructor arguments. This means that
if you provide paths
during instantiation they will be ignored if
the router is defined in the configuration file for the actor being used.
string representation of the actor paths of the routees, messages are sent with akka.actor.ActorSelection to these paths
expecting at least one reply within this duration, otherwise it will reply with akka.pattern.AskTimeoutException in a akka.actor.Status.Failure
dispatcher to use for the router head actor, which handles router management messages
A router pool that broadcasts the message to all routees, and replies with the first response.
A router pool that broadcasts the message to all routees, and replies with the first response.
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.
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.
initial number of routees in the pool
optional resizer that dynamically adjust the pool size
expecting at least one reply within this duration, otherwise it will reply with akka.pattern.AskTimeoutException in a akka.actor.Status.Failure
strategy for supervising the routees, see 'Supervision Setup'
dispatcher to use for the router head actor, which handles supervision, death watch and router management messages
Broadcasts the message to all routees, and replies with the first response.
Broadcasts the message to all routees, and replies with the first response.
expecting at least one reply within this duration, otherwise it will reply with akka.pattern.AskTimeoutException in a akka.actor.Status.Failure
Routee that sends each message to all routees
.
A router pool that tries to send to the non-suspended routee with fewest messages in mailbox.
A router pool that tries to send to the non-suspended routee with fewest messages in mailbox. The selection is done in this order:
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.
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.
initial number of routees in the pool
optional resizer that dynamically adjust the pool size
strategy for supervising the routees, see 'Supervision Setup'
dispatcher to use for the router head actor, which handles supervision, death watch and router management messages
Tries to send to the non-suspended routee with fewest messages in mailbox.
Tries to send to the non-suspended routee with fewest messages in mailbox. The selection is done in this order:
A router group with retry logic, intended for cases where a return message is expected in response to a message sent to the routee.
A router group with retry logic, intended for cases where a return message is expected in
response to a message sent to the routee. As each message is sent to the routing group, the
routees are randomly ordered. The message is sent to the first routee. If no response is received
before the interval
has passed, the same message is sent to the next routee. This process repeats
until either a response is received from some routee, the routees in the group are exhausted, or
the within
duration has passed since the first send. If no routee sends
a response in time, a akka.actor.Status.Failure wrapping a akka.pattern.AskTimeoutException
is sent to the sender.
Refer to akka.routing.TailChoppingRoutingLogic for comments regarding the goal of this routing algorithm.
The configuration parameter trumps the constructor arguments. This means that
if you provide paths
during instantiation they will be ignored if
the router is defined in the configuration file for the actor being used.
string representation of the actor paths of the routees, messages are sent with akka.actor.ActorSelection to these paths
expecting at least one reply within this duration, otherwise it will reply with akka.pattern.AskTimeoutException in a akka.actor.Status.Failure
duration after which the message will be sent to the next routee
dispatcher to use for the router head actor, which handles router management messages
A router pool with retry logic, intended for cases where a return message is expected in response to a message sent to the routee.
A router pool with retry logic, intended for cases where a return message is expected in
response to a message sent to the routee. As each message is sent to the routing pool, the
routees are randomly ordered. The message is sent to the first routee. If no response is received
before the interval
has passed, the same message is sent to the next routee. This process repeats
until either a response is received from some routee, the routees in the pool are exhausted, or
the within
duration has passed since the first send. If no routee sends
a response in time, a akka.actor.Status.Failure wrapping a akka.pattern.AskTimeoutException
is sent to the sender.
Refer to akka.routing.TailChoppingRoutingLogic for comments regarding the goal of this routing algorithm.
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.
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.
initial number of routees in the pool
optional resizer that dynamically adjust the pool size
expecting at least one reply within this duration, otherwise it will reply with akka.pattern.AskTimeoutException in a akka.actor.Status.Failure
duration after which the message will be sent to the next routee
strategy for supervising the routees, see 'Supervision Setup'
dispatcher to use for the router head actor, which handles supervision, death watch and router management messages
As each message is sent to the router, the routees are randomly ordered.
As each message is sent to the router, the routees are randomly ordered. The message is sent to the
first routee. If no response is received before the interval
has passed, the same message is sent
to the next routee. This process repeats until either a response is received from some routee, the
routees in the pool are exhausted, or the within
duration has passed since the first send. If no
routee sends a response in time, a akka.actor.Status.Failure wrapping a akka.pattern.AskTimeoutException
is sent to the sender.
The goal of this routing algorithm is to decrease tail latencies ("chop off the tail latency") in situations where multiple routees can perform the same piece of work, and where a routee may occasionally respond more slowly than expected. In this case, sending the same work request (also known as a "backup request") to another actor results in decreased response time - because it's less probable that multiple actors are under heavy load simultaneously. This technique is explained in depth in Jeff Dean's presentation on Achieving Rapid Response Times in Large Online Services.
schedules sending messages to routees
expecting at least one reply within this duration, otherwise it will reply with akka.pattern.AskTimeoutException in a akka.actor.Status.Failure
duration after which the message will be sent to the next routee
execution context used by scheduler
Wraps a akka.actor.Props to mark the actor as externally configurable to be used with a router.
Wraps a akka.actor.Props to mark the actor as externally configurable to be used with a router. If a akka.actor.Props is not wrapped with FromConfig then the actor will ignore the router part of the deployment section in the configuration.
An object designed to generate well-distributed non-cryptographic hashes.
An object designed to generate well-distributed non-cryptographic hashes. It is designed to hash a collection of integers; along with the integers to hash, it generates two magic streams of integers to increase the distribution of repetitive input sequences. Thus, three methods need to be called at each step (to start and to incorporate a new integer) to update the values. Only one method needs to be called to finalize the hash.
Routee that doesn't send the message to any routee.
Routee that doesn't send the message to any routee.
The Router will send the message to deadLetters
if
NoRoutee
is returned from RoutingLogic#select