Interface GroupRouter<T>
-
public interface GroupRouter<T>
Provides builder style configuration options for group routersNot for user extension. Use
Routers.group(akka.actor.typed.receptionist.ServiceKey<T>)
to create
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description GroupRouter<T>
withConsistentHashingRouting(int virtualNodesFactor, scala.Function1<T,java.lang.String> mapping)
Route messages by using consistent hashing.GroupRouter<T>
withRandomRouting()
Route messages by randomly selecting the routee from the available routees.GroupRouter<T>
withRandomRouting(boolean preferLocalRoutees)
Route messages by randomly selecting the routee from the available routees.GroupRouter<T>
withRoundRobinRouting()
Route messages by using round robin.GroupRouter<T>
withRoundRobinRouting(boolean preferLocalRoutees)
Route messages by using round robin.
-
-
-
Method Detail
-
withConsistentHashingRouting
GroupRouter<T> withConsistentHashingRouting(int virtualNodesFactor, scala.Function1<T,java.lang.String> mapping)
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.
- 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: https://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.
-
withRandomRouting
GroupRouter<T> withRandomRouting()
Route messages by randomly selecting the routee from the available routees. This is the default for group routers.
-
withRandomRouting
GroupRouter<T> withRandomRouting(boolean preferLocalRoutees)
Route messages by randomly selecting the routee from the available routees. This is the default for group routers.- 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
GroupRouter<T> withRoundRobinRouting()
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.
-
withRoundRobinRouting
GroupRouter<T> withRoundRobinRouting(boolean preferLocalRoutees)
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.
- 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 true and there is no local routees, remote routees will be used.
-
-