Class LoadBalancer


  • public class LoadBalancer
    extends Object
    LoadBalancer determines which group of content nodes should be accessed next for each search query when the internal java dispatcher is used. The implementation here is a simplistic least queries in flight + round-robin load balancer
    Author:
    ollivir
    • Constructor Detail

      • LoadBalancer

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

      • takeGroup

        public Optional<Group> takeGroup​(Set<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