Class BalancingPool
- All Implemented Interfaces:
Serializable,Pool,RouterConfig,scala.Equals,scala.Product
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.
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(org.apache.pekko.actor.SupervisorStrategy). 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.
param: nrOfInstances initial number of routees in the pool
param: supervisorStrategy strategy for supervising the routees, see 'Supervision Setup'
param: routerDispatcher dispatcher to use for the router head actor, which handles supervision, death watch and router management messages
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBalancingPool(int nr) Java APIBalancingPool(int nrOfInstances, SupervisorStrategy supervisorStrategy, String routerDispatcher) BalancingPool(com.typesafe.config.Config config) -
Method Summary
Modifier and TypeMethodDescriptionstatic SupervisorStrategystatic Stringstatic BalancingPoolapply(int nrOfInstances, SupervisorStrategy supervisorStrategy, String routerDispatcher) static SupervisorStrategystatic Stringbooleancopy(int nrOfInstances, SupervisorStrategy supervisorStrategy, String routerDispatcher) intcreateRouter(ActorSystem system) Create the actual router, responsible for routing messages to routees.booleaninthashCode()intintnrOfInstances(ActorSystem sys) Initial number of routee instancesintproductElement(int x$1) productElementName(int x$1) scala.collection.Iterator<Object>scala.Option<Resizer>resizer()Resizer cannot be used together with BalancingPoolDispatcher ID to use for running the “head” actor, which handles supervision, death watch and router management messagesSupervisorStrategy for the head actor, i.e.toString()static scala.Option<scala.Tuple3<Object,SupervisorStrategy, String>> unapply(BalancingPool x$0) withDispatcher(String dispatcherId) Setting the dispatcher to be used for the router head actor, which handles supervision, death watch and router management messages.withFallback(RouterConfig other) Uses the supervisor strategy of the given RouterConfig if this RouterConfig doesn't have one.withSupervisorStrategy(SupervisorStrategy strategy) Setting the supervisor strategy to be used for the “head” Router actor.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.pekko.routing.Pool
createRouterActor, enrichWithPoolDispatcher, props, stopRouterWhenAllRouteesRemoved, usePoolDispatcherMethods inherited from interface scala.Product
productElementNamesMethods inherited from interface org.apache.pekko.routing.RouterConfig
isManagementMessage, routingLogicController, verifyConfig
-
Constructor Details
-
BalancingPool
public BalancingPool(int nrOfInstances, SupervisorStrategy supervisorStrategy, String routerDispatcher) -
BalancingPool
public BalancingPool(com.typesafe.config.Config config) -
BalancingPool
public BalancingPool(int nr) Java API- Parameters:
nr- initial number of routees in the pool
-
-
Method Details
-
$lessinit$greater$default$2
-
$lessinit$greater$default$3
-
apply
public static BalancingPool apply(int nrOfInstances, SupervisorStrategy supervisorStrategy, String routerDispatcher) -
apply$default$2
-
apply$default$3
-
unapply
public static scala.Option<scala.Tuple3<Object,SupervisorStrategy, unapplyString>> (BalancingPool x$0) -
nrOfInstances
public int nrOfInstances() -
supervisorStrategy
Description copied from interface:PoolSupervisorStrategy for the head actor, i.e. for supervising the routees of the pool.- Specified by:
supervisorStrategyin interfacePool
-
routerDispatcher
Description copied from interface:RouterConfigDispatcher ID to use for running the “head” actor, which handles supervision, death watch and router management messages- Specified by:
routerDispatcherin interfaceRouterConfig
-
createRouter
Description copied from interface:RouterConfigCreate the actual router, responsible for routing messages to routees.- Specified by:
createRouterin interfaceRouterConfig- Parameters:
system- the ActorSystem this router belongs to
-
withSupervisorStrategy
Setting the supervisor strategy to be used for the “head” Router actor. -
withDispatcher
Setting the dispatcher to be used for the router head actor, which handles supervision, death watch and router management messages. -
nrOfInstances
Description copied from interface:PoolInitial number of routee instances- Specified by:
nrOfInstancesin interfacePool
-
withFallback
Uses the supervisor strategy of the given RouterConfig if this RouterConfig doesn't have one.- Specified by:
withFallbackin interfaceRouterConfig
-
resizer
Resizer cannot be used together with BalancingPool -
copy
public BalancingPool copy(int nrOfInstances, SupervisorStrategy supervisorStrategy, String routerDispatcher) -
copy$default$1
public int copy$default$1() -
copy$default$2
-
copy$default$3
-
productPrefix
- Specified by:
productPrefixin interfacescala.Product
-
productArity
public int productArity()- Specified by:
productArityin interfacescala.Product
-
productElement
- Specified by:
productElementin interfacescala.Product
-
productIterator
- Specified by:
productIteratorin interfacescala.Product
-
canEqual
- Specified by:
canEqualin interfacescala.Equals
-
productElementName
- Specified by:
productElementNamein interfacescala.Product
-
hashCode
public int hashCode() -
toString
-
equals
-