Class 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
    • Method Detail

      • $lessinit$greater$default$4

        public static <T> Props $lessinit$greater$default$4()
      • apply$default$4

        public static <T> Props apply$default$4()
      • poolSize

        public int poolSize()
      • routeeProps

        public Props routeeProps()
      • 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 interface PoolRouter<T>
        Specified by:
        withRandomRouting in class PoolRouter<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 interface PoolRouter<T>
        Specified by:
        withRoundRobinRouting in class PoolRouter<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 class PoolRouter<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 interface PoolRouter<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.
      • copy$default$1

        public <T> int copy$default$1()
      • copy$default$2

        public <T> Behavior<T> copy$default$2()
      • copy$default$4

        public <T> Props copy$default$4()
      • productPrefix

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

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

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

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

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

        public java.lang.String productElementName​(int x$1)
      • hashCode

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

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

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