Interface LoadBalancer

All Known Implementing Classes:
ClusterAwareLoadBalancer, TopologyAwareLoadBalancer

public interface LoadBalancer
An interface for any load balancing policy to implement. The LoadBalanceService invokes the implemented methods while processing a new connection request.
See Also:
  • Method Details

    • isHostEligible

      boolean isHostEligible(Map.Entry<String,LoadBalanceService.NodeInfo> e, Byte requestFlags)
      Parameters:
      e - The LoadBalanceService.NodeInfo object for the host
      requestFlags - 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

      String getLeastLoadedServer(boolean newRequest, List<String> failedHosts, ArrayList<String> timedOutHosts)
      Parameters:
      newRequest - whether this invocation is first for a new connection request
      failedHosts - list of host names which have been known to be down
      timedOutHosts - 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
    • getRefreshListSeconds

      int getRefreshListSeconds()
      Returns:
      the value of the property "yb-servers-refresh-interval" specified either in the url or as a property