Package org.apache.pekko.routing
Class ConsistentHashingGroup
java.lang.Object
org.apache.pekko.routing.ConsistentHashingGroup
- All Implemented Interfaces:
Serializable,Group,RouterConfig,scala.Equals,scala.Product
public final class ConsistentHashingGroup
extends Object
implements Group, scala.Product, Serializable
A router group that uses consistent hashing to select a routee based on the
sent message. The selection is described in
pekko.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.
param: paths string representation of the actor paths of the routees, messages are
sent with pekko.actor.ActorSelection to these paths
param: virtualNodesFactor number of virtual nodes per node, used in pekko.routing.ConsistentHash
param: hashMapping partial function from message to the data to use for the consistent hash key
param: routerDispatcher dispatcher to use for the router head actor, which handles router management messages
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConsistentHashingGroup(com.typesafe.config.Config config) ConsistentHashingGroup(Iterable<String> routeePaths) Java APIConsistentHashingGroup(scala.collection.immutable.Iterable<String> paths, int virtualNodesFactor, scala.PartialFunction<Object, Object> hashMapping, String routerDispatcher) -
Method Summary
Modifier and TypeMethodDescriptionstatic intstatic Stringstatic ConsistentHashingGroupapply(scala.collection.immutable.Iterable<String> paths, int virtualNodesFactor, scala.PartialFunction<Object, Object> hashMapping, String routerDispatcher) static intstatic Stringbooleancopy(scala.collection.immutable.Iterable<String> paths, int virtualNodesFactor, scala.PartialFunction<Object, Object> hashMapping, String routerDispatcher) scala.collection.immutable.Iterable<String>intcreateRouter(ActorSystem system) Create the actual router, responsible for routing messages to routees.booleaninthashCode()scala.collection.immutable.Iterable<String>paths()scala.collection.immutable.Iterable<String>paths(ActorSystem system) intproductElement(int x$1) productElementName(int x$1) scala.collection.Iterator<Object>Dispatcher ID to use for running the “head” actor, which handles supervision, death watch and router management messagestoString()static scala.Option<scala.Tuple4<scala.collection.immutable.Iterable<String>,Object, scala.PartialFunction<Object, Object>, String>> intwithDispatcher(String dispatcherId) Setting the dispatcher to be used for the router head actor, which handles router management messageswithFallback(RouterConfig other) Uses thehashMappingdefined in code, since that can't be defined in configuration.Java API: Setting the mapping from message to the data to use for the consistent hash key.withVirtualNodesFactor(int vnodes) Setting the number of virtual nodes per node, used inpekko.routing.ConsistentHashMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.pekko.routing.Group
createRouterActor, props, routeeForMethods inherited from interface scala.Product
productElementNamesMethods inherited from interface org.apache.pekko.routing.RouterConfig
isManagementMessage, routingLogicController, stopRouterWhenAllRouteesRemoved, verifyConfig
-
Constructor Details
-
ConsistentHashingGroup
-
ConsistentHashingGroup
public ConsistentHashingGroup(com.typesafe.config.Config config) -
ConsistentHashingGroup
Java API- Parameters:
routeePaths- string representation of the actor paths of the routees, messages are sent withpekko.actor.ActorSelectionto these paths
-
-
Method Details
-
$lessinit$greater$default$2
public static int $lessinit$greater$default$2() -
$lessinit$greater$default$3
-
$lessinit$greater$default$4
-
apply
public static ConsistentHashingGroup apply(scala.collection.immutable.Iterable<String> paths, int virtualNodesFactor, scala.PartialFunction<Object, Object> hashMapping, String routerDispatcher) -
apply$default$2
public static int apply$default$2() -
apply$default$3
-
apply$default$4
-
unapply
-
paths
-
virtualNodesFactor
public int virtualNodesFactor() -
hashMapping
-
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
-
paths
-
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
-
withDispatcher
Setting the dispatcher to be used for the router head actor, which handles router management messages -
withVirtualNodesFactor
Setting the number of virtual nodes per node, used inpekko.routing.ConsistentHash -
withHashMapper
Java API: Setting the mapping from message to the data to use for the consistent hash key. -
withFallback
Uses thehashMappingdefined in code, since that can't be defined in configuration.- Specified by:
withFallbackin interfaceRouterConfig
-
copy
public ConsistentHashingGroup copy(scala.collection.immutable.Iterable<String> paths, int virtualNodesFactor, scala.PartialFunction<Object, Object> hashMapping, String routerDispatcher) -
copy$default$1
-
copy$default$2
public int copy$default$2() -
copy$default$3
-
copy$default$4
-
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
-