Class PoolRouterBuilder<T>
- java.lang.Object
-
- akka.actor.typed.Behavior<T>
-
- akka.actor.typed.internal.BehaviorImpl.DeferredBehavior<T>
-
- akka.actor.typed.javadsl.PoolRouter<T>
-
- akka.actor.typed.internal.routing.PoolRouterBuilder<T>
-
- All Implemented Interfaces:
PoolRouter<T>
,java.io.Serializable
,scala.Equals
,scala.Product
public final class PoolRouterBuilder<T> extends PoolRouter<T> implements PoolRouter<T>, scala.Product, java.io.Serializable
INTERNAL API- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class akka.actor.typed.Behavior
Behavior.BehaviorDecorators<Inner>, Behavior.BehaviorDecorators$
-
-
Constructor Summary
Constructors Constructor Description PoolRouterBuilder(int poolSize, Behavior<T> behavior, scala.Function1<ActorSystem<?>,RoutingLogic<T>> logicFactory, scala.Function1<T,java.lang.Object> broadcastPredicate, Props routeeProps)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> scala.Function1<ActorSystem<?>,RoutingLogics.RoundRobinLogic<T>>
$lessinit$greater$default$3()
static <T> scala.Function1<java.lang.Object,java.lang.Object>
$lessinit$greater$default$4()
static <T> Props
$lessinit$greater$default$5()
Behavior<T>
apply(TypedActorContext<T> ctx)
static <T> scala.Function1<ActorSystem<?>,RoutingLogics.RoundRobinLogic<T>>
apply$default$3()
static <T> scala.Function1<java.lang.Object,java.lang.Object>
apply$default$4()
static <T> Props
apply$default$5()
Behavior<T>
behavior()
scala.Function1<T,java.lang.Object>
broadcastPredicate()
boolean
canEqual(java.lang.Object x$1)
<T> PoolRouterBuilder<T>
copy(int poolSize, Behavior<T> behavior, scala.Function1<ActorSystem<?>,RoutingLogic<T>> logicFactory, scala.Function1<T,java.lang.Object> broadcastPredicate, Props routeeProps)
<T> int
copy$default$1()
<T> Behavior<T>
copy$default$2()
<T> scala.Function1<ActorSystem<?>,RoutingLogic<T>>
copy$default$3()
<T> scala.Function1<T,java.lang.Object>
copy$default$4()
<T> Props
copy$default$5()
boolean
equals(java.lang.Object x$1)
int
hashCode()
scala.Function1<ActorSystem<?>,RoutingLogic<T>>
logicFactory()
int
poolSize()
int
productArity()
java.lang.Object
productElement(int x$1)
java.lang.String
productElementName(int x$1)
scala.collection.Iterator<java.lang.Object>
productIterator()
java.lang.String
productPrefix()
Props
routeeProps()
java.lang.String
toString()
static <T> scala.Option<scala.Tuple5<java.lang.Object,Behavior<T>,scala.Function1<ActorSystem<?>,RoutingLogic<T>>,scala.Function1<T,java.lang.Object>,Props>>
unapply(PoolRouterBuilder<T> x$0)
PoolRouter<T>
withBroadcastPredicate(java.util.function.Predicate<T> pred)
Any message that the predicate returns true for will be broadcast to all routees.PoolRouter<T>
withBroadcastPredicate(scala.Function1<T,java.lang.Object> pred)
Any message that the predicate returns true for will be broadcast to all routees.PoolRouter<T>
withConsistentHashingRouting(int virtualNodesFactor, java.util.function.Function<T,java.lang.String> mapping)
Route messages by using consistent hashing.PoolRouterBuilder<T>
withConsistentHashingRouting(int virtualNodesFactor, scala.Function1<T,java.lang.String> mapping)
Route messages by using consistent hashing.PoolRouterBuilder<T>
withPoolSize(int poolSize)
Set a new pool size from the one set at constructionPoolRouterBuilder<T>
withRandomRouting()
Route messages by randomly selecting the routee from the available routees.PoolRouterBuilder<T>
withRoundRobinRouting()
Route messages through round robin, providing a fair distribution of messages across the routees.PoolRouterBuilder<T>
withRouteeProps(Props routeeProps)
Set the props used to spawn the pool's routees-
Methods inherited from class akka.actor.typed.Behavior
_tag, BehaviorDecorators, canonicalize, existsInStack, interpretMessage, interpretSignal, isAlive, isDeferred, isUnhandled, narrow, start, unsafeCast, validateAsInitial
-
-
-
-
Constructor Detail
-
PoolRouterBuilder
public PoolRouterBuilder(int poolSize, Behavior<T> behavior, scala.Function1<ActorSystem<?>,RoutingLogic<T>> logicFactory, scala.Function1<T,java.lang.Object> broadcastPredicate, Props routeeProps)
-
-
Method Detail
-
$lessinit$greater$default$3
public static <T> scala.Function1<ActorSystem<?>,RoutingLogics.RoundRobinLogic<T>> $lessinit$greater$default$3()
-
$lessinit$greater$default$4
public static <T> scala.Function1<java.lang.Object,java.lang.Object> $lessinit$greater$default$4()
-
$lessinit$greater$default$5
public static <T> Props $lessinit$greater$default$5()
-
apply$default$3
public static <T> scala.Function1<ActorSystem<?>,RoutingLogics.RoundRobinLogic<T>> apply$default$3()
-
apply$default$4
public static <T> scala.Function1<java.lang.Object,java.lang.Object> apply$default$4()
-
apply$default$5
public static <T> Props apply$default$5()
-
unapply
public static <T> scala.Option<scala.Tuple5<java.lang.Object,Behavior<T>,scala.Function1<ActorSystem<?>,RoutingLogic<T>>,scala.Function1<T,java.lang.Object>,Props>> unapply(PoolRouterBuilder<T> x$0)
-
poolSize
public int poolSize()
-
logicFactory
public scala.Function1<ActorSystem<?>,RoutingLogic<T>> logicFactory()
-
broadcastPredicate
public scala.Function1<T,java.lang.Object> broadcastPredicate()
-
routeeProps
public Props routeeProps()
-
apply
public Behavior<T> apply(TypedActorContext<T> ctx)
- Specified by:
apply
in classBehaviorImpl.DeferredBehavior<T>
-
withRandomRouting
public PoolRouterBuilder<T> withRandomRouting()
Description copied from class:PoolRouter
Route messages by randomly selecting the routee from the available routees.Random routing makes it less likely that every
poolsize
message from a single producer ends up in the same mailbox of a slow actor.- Specified by:
withRandomRouting
in interfacePoolRouter<T>
- Specified by:
withRandomRouting
in classPoolRouter<T>
-
withRoundRobinRouting
public PoolRouterBuilder<T> withRoundRobinRouting()
Description copied from class:PoolRouter
Route messages through round robin, providing a fair distribution of messages across the routees.Round robin gives fair routing where every available routee gets the same amount of messages
This is the default for pool routers.
- Specified by:
withRoundRobinRouting
in interfacePoolRouter<T>
- Specified by:
withRoundRobinRouting
in classPoolRouter<T>
-
withConsistentHashingRouting
public PoolRouter<T> withConsistentHashingRouting(int virtualNodesFactor, java.util.function.Function<T,java.lang.String> mapping)
Description copied from class:PoolRouter
Route messages by using consistent hashing.From wikipedia: Consistent hashing is based on mapping each object to a point on a circle (or equivalently, mapping each object to a real angle). The system maps each available machine (or other storage bucket) to many pseudo-randomly distributed points on the same circle.
- Specified by:
withConsistentHashingRouting
in classPoolRouter<T>
- Parameters:
virtualNodesFactor
- This factor has to be greater or equal to 1. Assuming that the reader knows what consistent hashing is (if not, please refer: http://www.tom-e-white.com/2007/11/consistent-hashing.html or wiki). This number is responsible for creating additional, virtual addresses for a provided set of routees, so that in the total number of points on hashing ring will be equal to numberOfRoutees * virtualNodesFactor (if virtualNodesFactor is equal to 1, then no additional points will be created).Those virtual nodes are being created by additionally rehashing routees to evenly distribute them across hashing ring. Consider increasing this number when you have a small number of routees. For bigger loads one can aim in having around 100-200 total addresses.
mapping
- Hash key extractor. This function will be used in consistent hashing process. Result of this operation should possibly uniquely distinguish messages.
-
withConsistentHashingRouting
public PoolRouterBuilder<T> withConsistentHashingRouting(int virtualNodesFactor, scala.Function1<T,java.lang.String> mapping)
Description copied from interface:PoolRouter
Route messages by using consistent hashing.From wikipedia: Consistent hashing is based on mapping each object to a point on a circle (or equivalently, mapping each object to a real angle). The system maps each available machine (or other storage bucket) to many pseudo-randomly distributed points on the same circle.
- Specified by:
withConsistentHashingRouting
in interfacePoolRouter<T>
- Parameters:
virtualNodesFactor
- This factor has to be greater or equal to 1. Assuming that the reader knows what consistent hashing is (if not, please refer: http://www.tom-e-white.com/2007/11/consistent-hashing.html or wiki). This number is responsible for creating additional, virtual addresses for a provided set of routees, so that in the total number of points on hashing ring will be equal to numberOfRoutees * virtualNodesFactor (if virtualNodesFactor is equal to 1, then no additional points will be created).Those virtual nodes are being created by additionally rehashing routees to evenly distribute them across hashing ring. Consider increasing this number when you have a small number of routees. For bigger loads one can aim in having around 100-200 total addresses.
mapping
- Hash key extractor. This function will be used in consistent hashing process. Result of this operation should possibly uniquely distinguish messages.
-
withPoolSize
public PoolRouterBuilder<T> withPoolSize(int poolSize)
Description copied from class:PoolRouter
Set a new pool size from the one set at construction- Specified by:
withPoolSize
in interfacePoolRouter<T>
- Specified by:
withPoolSize
in classPoolRouter<T>
-
withRouteeProps
public PoolRouterBuilder<T> withRouteeProps(Props routeeProps)
Description copied from class:PoolRouter
Set the props used to spawn the pool's routees- Specified by:
withRouteeProps
in interfacePoolRouter<T>
- Specified by:
withRouteeProps
in classPoolRouter<T>
-
withBroadcastPredicate
public PoolRouter<T> withBroadcastPredicate(java.util.function.Predicate<T> pred)
Description copied from class:PoolRouter
Any message that the predicate returns true for will be broadcast to all routees.- Specified by:
withBroadcastPredicate
in classPoolRouter<T>
-
withBroadcastPredicate
public PoolRouter<T> withBroadcastPredicate(scala.Function1<T,java.lang.Object> pred)
Description copied from interface:PoolRouter
Any message that the predicate returns true for will be broadcast to all routees.- Specified by:
withBroadcastPredicate
in interfacePoolRouter<T>
-
copy
public <T> PoolRouterBuilder<T> copy(int poolSize, Behavior<T> behavior, scala.Function1<ActorSystem<?>,RoutingLogic<T>> logicFactory, scala.Function1<T,java.lang.Object> broadcastPredicate, Props routeeProps)
-
copy$default$1
public <T> int copy$default$1()
-
copy$default$2
public <T> Behavior<T> copy$default$2()
-
copy$default$3
public <T> scala.Function1<ActorSystem<?>,RoutingLogic<T>> copy$default$3()
-
copy$default$4
public <T> scala.Function1<T,java.lang.Object> copy$default$4()
-
copy$default$5
public <T> Props copy$default$5()
-
productPrefix
public java.lang.String productPrefix()
- Specified by:
productPrefix
in interfacescala.Product
-
productArity
public int productArity()
- Specified by:
productArity
in interfacescala.Product
-
productElement
public java.lang.Object productElement(int x$1)
- Specified by:
productElement
in interfacescala.Product
-
productIterator
public scala.collection.Iterator<java.lang.Object> productIterator()
- Specified by:
productIterator
in interfacescala.Product
-
canEqual
public boolean canEqual(java.lang.Object x$1)
- Specified by:
canEqual
in interfacescala.Equals
-
productElementName
public java.lang.String productElementName(int x$1)
- Specified by:
productElementName
in interfacescala.Product
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object x$1)
- Specified by:
equals
in interfacescala.Equals
- Overrides:
equals
in classjava.lang.Object
-
-