Package com.yugabyte.ysql
Class ClusterAwareLoadBalancer
java.lang.Object
com.yugabyte.ysql.ClusterAwareLoadBalancer
- All Implemented Interfaces:
LoadBalancer
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionClusterAwareLoadBalancer(LoadBalanceService.LoadBalanceType lb, int refreshInterval) -
Method Summary
Modifier and TypeMethodDescriptionstatic ClusterAwareLoadBalancergetInstance(LoadBalanceService.LoadBalanceType lb, int refreshListSeconds) getLeastLoadedServer(boolean newRequest, List<String> failedHosts, ArrayList<String> timedOutHosts) intbooleanisHostEligible(Map.Entry<String, LoadBalanceService.NodeInfo> e, Byte requestFlags) toString()
-
Field Details
-
LOGGER
-
refreshListSeconds
protected int refreshListSeconds
-
-
Constructor Details
-
ClusterAwareLoadBalancer
-
-
Method Details
-
getRefreshListSeconds
public int getRefreshListSeconds()- Specified by:
getRefreshListSecondsin interfaceLoadBalancer- Returns:
- the value of the property "yb-servers-refresh-interval" specified either in the url or as a property
-
getInstance
public static ClusterAwareLoadBalancer getInstance(LoadBalanceService.LoadBalanceType lb, int refreshListSeconds) -
toString
-
isHostEligible
- Specified by:
isHostEligiblein interfaceLoadBalancer- Parameters:
e- TheLoadBalanceService.NodeInfoobject for the hostrequestFlags- The attributes for the load balancer to make use of- Returns:
- true, if a host is eligible to be considered for a connection request
-
getLeastLoadedServer
public String getLeastLoadedServer(boolean newRequest, List<String> failedHosts, ArrayList<String> timedOutHosts) - Specified by:
getLeastLoadedServerin interfaceLoadBalancer- Parameters:
newRequest- whether this invocation is first for a new connection requestfailedHosts- list of host names which have been known to be downtimedOutHosts- list of host names where connections were attempted but timed out- Returns:
- the name of a host with the least number of connections, as per the driver's stats
-