Class GroupRouterBuilder<T>
- java.lang.Object
-
- akka.actor.typed.Behavior<T>
-
- akka.actor.typed.internal.BehaviorImpl.DeferredBehavior<T>
-
- akka.actor.typed.javadsl.GroupRouter<T>
-
- akka.actor.typed.internal.routing.GroupRouterBuilder<T>
-
- All Implemented Interfaces:
GroupRouter<T>
,java.io.Serializable
,scala.Equals
,scala.Product
public final class GroupRouterBuilder<T> extends GroupRouter<T> implements GroupRouter<T>, scala.Product, java.io.Serializable
Provides builder style configuration options for group routers while still being a behavior that can be spawnedINTERNAL 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 GroupRouterBuilder(ServiceKey<T> key, boolean preferLocalRoutees, scala.Function1<ActorSystem<?>,RoutingLogic<T>> logicFactory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> boolean
$lessinit$greater$default$2()
static <T> scala.Function1<ActorSystem<?>,RoutingLogics.RandomLogic<T>>
$lessinit$greater$default$3()
Behavior<T>
apply(TypedActorContext<T> ctx)
static <T> boolean
apply$default$2()
static <T> scala.Function1<ActorSystem<?>,RoutingLogics.RandomLogic<T>>
apply$default$3()
boolean
canEqual(java.lang.Object x$1)
<T> GroupRouterBuilder<T>
copy(ServiceKey<T> key, boolean preferLocalRoutees, scala.Function1<ActorSystem<?>,RoutingLogic<T>> logicFactory)
<T> ServiceKey<T>
copy$default$1()
<T> boolean
copy$default$2()
<T> scala.Function1<ActorSystem<?>,RoutingLogic<T>>
copy$default$3()
boolean
equals(java.lang.Object x$1)
int
hashCode()
ServiceKey<T>
key()
scala.Function1<ActorSystem<?>,RoutingLogic<T>>
logicFactory()
boolean
preferLocalRoutees()
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()
java.lang.String
toString()
static <T> scala.Option<scala.Tuple3<ServiceKey<T>,java.lang.Object,scala.Function1<ActorSystem<?>,RoutingLogic<T>>>>
unapply(GroupRouterBuilder<T> x$0)
GroupRouterBuilder<T>
withConsistentHashingRouting(int virtualNodesFactor, java.util.function.Function<T,java.lang.String> mapping)
Route messages by using consistent hashing.GroupRouterBuilder<T>
withConsistentHashingRouting(int virtualNodesFactor, scala.Function1<T,java.lang.String> mapping)
Route messages by using consistent hashing.GroupRouterBuilder<T>
withRandomRouting()
Route messages by randomly selecting the routee from the available routees.GroupRouterBuilder<T>
withRandomRouting(boolean preferLocalRoutees)
Route messages by randomly selecting the routee from the available routees.GroupRouterBuilder<T>
withRoundRobinRouting()
Route messages by using round robin.GroupRouterBuilder<T>
withRoundRobinRouting(boolean preferLocalRoutees)
Route messages by using round robin.-
Methods inherited from class akka.actor.typed.Behavior
_tag, BehaviorDecorators, canonicalize, existsInStack, interpretMessage, interpretSignal, isAlive, isDeferred, isUnhandled, narrow, start, unsafeCast, validateAsInitial
-
-
-
-
Constructor Detail
-
GroupRouterBuilder
public GroupRouterBuilder(ServiceKey<T> key, boolean preferLocalRoutees, scala.Function1<ActorSystem<?>,RoutingLogic<T>> logicFactory)
-
-
Method Detail
-
$lessinit$greater$default$2
public static <T> boolean $lessinit$greater$default$2()
-
$lessinit$greater$default$3
public static <T> scala.Function1<ActorSystem<?>,RoutingLogics.RandomLogic<T>> $lessinit$greater$default$3()
-
apply$default$2
public static <T> boolean apply$default$2()
-
apply$default$3
public static <T> scala.Function1<ActorSystem<?>,RoutingLogics.RandomLogic<T>> apply$default$3()
-
unapply
public static <T> scala.Option<scala.Tuple3<ServiceKey<T>,java.lang.Object,scala.Function1<ActorSystem<?>,RoutingLogic<T>>>> unapply(GroupRouterBuilder<T> x$0)
-
key
public ServiceKey<T> key()
-
preferLocalRoutees
public boolean preferLocalRoutees()
-
logicFactory
public scala.Function1<ActorSystem<?>,RoutingLogic<T>> logicFactory()
-
apply
public Behavior<T> apply(TypedActorContext<T> ctx)
- Specified by:
apply
in classBehaviorImpl.DeferredBehavior<T>
-
withRandomRouting
public GroupRouterBuilder<T> withRandomRouting()
Description copied from class:GroupRouter
Route messages by randomly selecting the routee from the available routees.This is the default for group routers.
- Specified by:
withRandomRouting
in interfaceGroupRouter<T>
- Specified by:
withRandomRouting
in classGroupRouter<T>
-
withRandomRouting
public GroupRouterBuilder<T> withRandomRouting(boolean preferLocalRoutees)
Description copied from class:GroupRouter
Route messages by randomly selecting the routee from the available routees.This is the default for group routers.
- Specified by:
withRandomRouting
in interfaceGroupRouter<T>
- Specified by:
withRandomRouting
in classGroupRouter<T>
- Parameters:
preferLocalRoutees
- if the value is false, all reachable routees will be used; if the value is true and there are local routees, only local routees will be used. if the value is true and there is no local routees, remote routees will be used.
-
withRoundRobinRouting
public GroupRouterBuilder<T> withRoundRobinRouting()
Description copied from class:GroupRouter
Route messages by using round robin.Round robin gives fair routing where every available routee gets the same amount of messages as long as the set of routees stays relatively stable, but may be unfair if the set of routees changes a lot.
- Specified by:
withRoundRobinRouting
in interfaceGroupRouter<T>
- Specified by:
withRoundRobinRouting
in classGroupRouter<T>
-
withRoundRobinRouting
public GroupRouterBuilder<T> withRoundRobinRouting(boolean preferLocalRoutees)
Description copied from class:GroupRouter
Route messages by using round robin.Round robin gives fair routing where every available routee gets the same amount of messages as long as the set of routees stays relatively stable, but may be unfair if the set of routees changes a lot.
- Specified by:
withRoundRobinRouting
in interfaceGroupRouter<T>
- Specified by:
withRoundRobinRouting
in classGroupRouter<T>
- Parameters:
preferLocalRoutees
- if the value is false, all reachable routees will be used; if the value is true and there are local routees, only local routees will be used. if the value is true and there is no local routees, remote routees will be used.
-
withConsistentHashingRouting
public GroupRouterBuilder<T> withConsistentHashingRouting(int virtualNodesFactor, java.util.function.Function<T,java.lang.String> mapping)
Description copied from class:GroupRouter
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 classGroupRouter<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.
Please also note that setting this number to a too big value will cause reasonable overhead when new routees will be added or old one removed.
mapping
- Hash key extractor. This function will be used in consistent hashing process. Result of this operation should possibly uniquely distinguish messages.
-
withConsistentHashingRouting
public GroupRouterBuilder<T> withConsistentHashingRouting(int virtualNodesFactor, scala.Function1<T,java.lang.String> mapping)
Description copied from interface:GroupRouter
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 interfaceGroupRouter<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.
Please also note that setting this number to a too big value will cause reasonable overhead when new routees will be added or old one removed.
mapping
- Hash key extractor. This function will be used in consistent hashing process. Result of this operation should possibly uniquely distinguish messages.
-
copy
public <T> GroupRouterBuilder<T> copy(ServiceKey<T> key, boolean preferLocalRoutees, scala.Function1<ActorSystem<?>,RoutingLogic<T>> logicFactory)
-
copy$default$1
public <T> ServiceKey<T> copy$default$1()
-
copy$default$2
public <T> boolean copy$default$2()
-
copy$default$3
public <T> scala.Function1<ActorSystem<?>,RoutingLogic<T>> copy$default$3()
-
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
-
-