Package com.yahoo.search.dispatch
Class LoadBalancer
- java.lang.Object
-
- com.yahoo.search.dispatch.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 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 bytakeGroup(java.util.Set<java.lang.Integer>)
.Optional<Group>
takeGroup(Set<Integer> rejectedGroups)
Select and allocate the search cluster group which is to be used for the next search query.
-
-
-
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 callreleaseGroup(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 bytakeGroup(java.util.Set<java.lang.Integer>)
. The release must be done exactly once for each allocation.- Parameters:
group
- previously allocated groupsuccess
- was the query successfulsearchTimeMs
- query execution time in milliseconds, used for adaptive load balancing
-
-