Class LoadBalancer


  • public class LoadBalancer
    extends java.lang.Object
    LoadBalancer determines which group of content nodes should be accessed next for each search query when the internal java dispatcher is used.
    Author:
    ollivir
    • Constructor Summary

      Constructors 
      Constructor Description
      LoadBalancer​(SearchCluster searchCluster, boolean roundRobin)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void releaseGroup​(Group group, boolean success, double searchTimeMs)
      Release an allocation given by takeGroup(java.util.Set<java.lang.Integer>).
      java.util.Optional<Group> takeGroup​(java.util.Set<java.lang.Integer> rejectedGroups)
      Select and allocate the search cluster group which is to be used for the next search query.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LoadBalancer

        public LoadBalancer​(SearchCluster searchCluster,
                            boolean roundRobin)
    • Method Detail

      • takeGroup

        public java.util.Optional<Group> takeGroup​(java.util.Set<java.lang.Integer> rejectedGroups)
        Select and allocate the search cluster group which is to be used for the next search query. Callers must call releaseGroup(com.yahoo.search.dispatch.searchcluster.Group, boolean, double) symmetrically for each taken allocation.
        Parameters:
        rejectedGroups - if not null, the load balancer will only return groups with IDs not in the set
        Returns:
        the node group to target, or empty if the internal dispatch logic cannot be used
      • releaseGroup

        public void releaseGroup​(Group group,
                                 boolean success,
                                 double searchTimeMs)
        Release an allocation given by takeGroup(java.util.Set<java.lang.Integer>). The release must be done exactly once for each allocation.
        Parameters:
        group - previously allocated group
        success - was the query successful
        searchTimeMs - query execution time in milliseconds, used for adaptive load balancing