Class 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 spawned

    INTERNAL API

    See Also:
    Serialized Form
    • Method Detail

      • $lessinit$greater$default$2

        public static <T> boolean $lessinit$greater$default$2()
      • apply$default$2

        public static <T> boolean apply$default$2()
      • preferLocalRoutees

        public boolean preferLocalRoutees()
      • 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 interface GroupRouter<T>
        Specified by:
        withRandomRouting in class GroupRouter<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 interface GroupRouter<T>
        Specified by:
        withRoundRobinRouting in class GroupRouter<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 interface GroupRouter<T>
        Specified by:
        withRoundRobinRouting in class GroupRouter<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 class GroupRouter<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 interface GroupRouter<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$default$1

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

        public <T> boolean copy$default$2()
      • 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