Class LeastConnectedLoadBalancingStrategy

java.lang.Object
org.neo4j.driver.internal.cluster.loadbalancing.LeastConnectedLoadBalancingStrategy
All Implemented Interfaces:
LoadBalancingStrategy

public class LeastConnectedLoadBalancingStrategy extends Object implements LoadBalancingStrategy
Load balancing strategy that finds server with the least amount of active (checked out of the pool) connections from given readers or writers. It finds a start index for iteration in a round-robin fashion. This is done to prevent choosing same first address over and over when all addresses have the same amount of active connections.
  • Constructor Details

    • LeastConnectedLoadBalancingStrategy

      public LeastConnectedLoadBalancingStrategy(ConnectionPool connectionPool, Logging logging)
  • Method Details

    • selectReader

      public org.neo4j.driver.internal.BoltServerAddress selectReader(List<org.neo4j.driver.internal.BoltServerAddress> knownReaders)
      Description copied from interface: LoadBalancingStrategy
      Select most appropriate read address from the given array of addresses.
      Specified by:
      selectReader in interface LoadBalancingStrategy
      Parameters:
      knownReaders - array of all known readers.
      Returns:
      most appropriate reader or null if it can't be selected.
    • selectWriter

      public org.neo4j.driver.internal.BoltServerAddress selectWriter(List<org.neo4j.driver.internal.BoltServerAddress> knownWriters)
      Description copied from interface: LoadBalancingStrategy
      Select most appropriate write address from the given array of addresses.
      Specified by:
      selectWriter in interface LoadBalancingStrategy
      Parameters:
      knownWriters - array of all known writers.
      Returns:
      most appropriate writer or null if it can't be selected.