Class ConsistentHashingRoutingLogic

java.lang.Object
org.apache.pekko.routing.ConsistentHashingRoutingLogic
All Implemented Interfaces:
Serializable, NoSerializationVerificationNeeded, RoutingLogic, scala.Equals, scala.Product

public final class ConsistentHashingRoutingLogic extends Object implements RoutingLogic, scala.Product, Serializable
See Also:
  • Constructor Details

    • ConsistentHashingRoutingLogic

      public ConsistentHashingRoutingLogic(ActorSystem system, int virtualNodesFactor, scala.PartialFunction<Object,Object> hashMapping)
    • ConsistentHashingRoutingLogic

      public ConsistentHashingRoutingLogic(ActorSystem system)
      Java API
      Parameters:
      system - the actor system hosting this router
  • Method Details

    • $lessinit$greater$default$2

      public static int $lessinit$greater$default$2()
      Uses consistent hashing to select a routee based on the sent message.

      There is 3 ways to define what data to use for the consistent hash key.

      1. You can define hashMapping / withHashMapper of the router to map incoming messages to their consistent hash key. This makes the decision transparent for the sender.

      2. The messages may implement pekko.routing.ConsistentHashingRouter.ConsistentHashable. The key is part of the message and it's convenient to define it together with the message definition.

      3. The messages can be wrapped in a pekko.routing.ConsistentHashingRouter.ConsistentHashableEnvelope to define what data to use for the consistent hash key. The sender knows the key to use.

      These ways to define the consistent hash key can be use together and at the same time for one router. The hashMapping is tried first.

      Parameters:
      virtualNodesFactor - number of virtual nodes per node, used in pekko.routing.ConsistentHash

      hashMapping - partial function from message to the data to use for the consistent hash key

      system - the actor system hosting this router
    • $lessinit$greater$default$3

      public static scala.PartialFunction<Object,Object> $lessinit$greater$default$3()
    • defaultAddress

      public static Address defaultAddress(ActorSystem system)
    • apply

      public static ConsistentHashingRoutingLogic apply(ActorSystem system, int virtualNodesFactor, scala.PartialFunction<Object,Object> hashMapping)
      Uses consistent hashing to select a routee based on the sent message.

      There is 3 ways to define what data to use for the consistent hash key.

      1. You can define hashMapping / withHashMapper of the router to map incoming messages to their consistent hash key. This makes the decision transparent for the sender.

      2. The messages may implement pekko.routing.ConsistentHashingRouter.ConsistentHashable. The key is part of the message and it's convenient to define it together with the message definition.

      3. The messages can be wrapped in a pekko.routing.ConsistentHashingRouter.ConsistentHashableEnvelope to define what data to use for the consistent hash key. The sender knows the key to use.

      These ways to define the consistent hash key can be use together and at the same time for one router. The hashMapping is tried first.

      Parameters:
      virtualNodesFactor - number of virtual nodes per node, used in pekko.routing.ConsistentHash

      hashMapping - partial function from message to the data to use for the consistent hash key

      system - the actor system hosting this router
    • apply$default$2

      public static int apply$default$2()
    • apply$default$3

      public static scala.PartialFunction<Object,Object> apply$default$3()
    • unapply

      public static scala.Option<scala.Tuple3<ActorSystem,Object,scala.PartialFunction<Object,Object>>> unapply(ConsistentHashingRoutingLogic x$0)
    • system

      public ActorSystem system()
    • virtualNodesFactor

      public int virtualNodesFactor()
    • hashMapping

      public scala.PartialFunction<Object,Object> hashMapping()
    • vnodes

      public int vnodes()
    • withVirtualNodesFactor

      public ConsistentHashingRoutingLogic withVirtualNodesFactor(int vnodes)
      Setting the number of virtual nodes per node, used in pekko.routing.ConsistentHash
    • withHashMapper

      Java API: Setting the mapping from message to the data to use for the consistent hash key.
    • select

      public Routee select(Object message, scala.collection.immutable.IndexedSeq<Routee> routees)
      Description copied from interface: RoutingLogic
      Pick the destination for a given message. Normally it picks one of the passed routees, but in the end it is up to the implementation to return whatever pekko.routing.Routee to use for sending a specific message.

      When implemented from Java it can be good to know that routees.apply(index) can be used to get an element from the IndexedSeq.

      Specified by:
      select in interface RoutingLogic
    • copy

      public ConsistentHashingRoutingLogic copy(ActorSystem system, int virtualNodesFactor, scala.PartialFunction<Object,Object> hashMapping)
    • copy$default$1

      public ActorSystem copy$default$1()
    • copy$default$2

      public int copy$default$2()
    • copy$default$3

      public scala.PartialFunction<Object,Object> copy$default$3()
    • productPrefix

      public String productPrefix()
      Specified by:
      productPrefix in interface scala.Product
    • productArity

      public int productArity()
      Specified by:
      productArity in interface scala.Product
    • productElement

      public Object productElement(int x$1)
      Specified by:
      productElement in interface scala.Product
    • productIterator

      public scala.collection.Iterator<Object> productIterator()
      Specified by:
      productIterator in interface scala.Product
    • canEqual

      public boolean canEqual(Object x$1)
      Specified by:
      canEqual in interface scala.Equals
    • productElementName

      public String productElementName(int x$1)
      Specified by:
      productElementName in interface scala.Product
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object x$1)
      Specified by:
      equals in interface scala.Equals
      Overrides:
      equals in class Object