public final class RoundRobinLoadBalancingAlgorithm extends Object
This algorithm is typically used for load-balancing within data
centers, where load must be distributed equally across multiple data sources.
This algorithm contrasts with the FailoverLoadBalancingAlgorithm
which is used for load-balancing between data centers.
If a problem occurs that temporarily prevents connections from being obtained
for one of the connection factories, then this algorithm automatically
"fails over" to the next operational connection factory in the list. If none
of the connection factories are operational then a
ConnectionException is returned to the client.
The implementation periodically attempts to connect to failed connection factories in order to determine if they have become available again.
| Constructor and Description |
|---|
RoundRobinLoadBalancingAlgorithm(Collection<? extends ConnectionFactory> factories)
Creates a new round robin load balancing algorithm which will monitor
offline connection factories every 1 second using the default scheduler.
|
RoundRobinLoadBalancingAlgorithm(Collection<? extends ConnectionFactory> factories,
LoadBalancerEventListener listener)
Creates a new round robin load balancing algorithm which will monitor
offline connection factories every 1 second using the default scheduler.
|
RoundRobinLoadBalancingAlgorithm(Collection<? extends ConnectionFactory> factories,
LoadBalancerEventListener listener,
long interval,
TimeUnit unit)
Creates a new round robin load balancing algorithm which will monitor
offline connection factories using the specified frequency using the
default scheduler.
|
RoundRobinLoadBalancingAlgorithm(Collection<? extends ConnectionFactory> factories,
LoadBalancerEventListener listener,
long interval,
TimeUnit unit,
ScheduledExecutorService scheduler)
Creates a new round robin load balancing algorithm which will monitor
offline connection factories using the specified frequency and scheduler.
|
RoundRobinLoadBalancingAlgorithm(Collection<? extends ConnectionFactory> factories,
long interval,
TimeUnit unit)
Creates a new round robin load balancing algorithm which will monitor
offline connection factories using the specified frequency using the
default scheduler.
|
RoundRobinLoadBalancingAlgorithm(Collection<? extends ConnectionFactory> factories,
long interval,
TimeUnit unit,
ScheduledExecutorService scheduler)
Creates a new round robin load balancing algorithm which will monitor
offline connection factories using the specified frequency and scheduler.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Releases any resources associated with this algorithm, including any
associated connection factories.
|
ConnectionFactory |
getConnectionFactory()
Returns a connection factory which should be used in order to satisfy the
next connection request.
|
String |
toString() |
public RoundRobinLoadBalancingAlgorithm(Collection<? extends ConnectionFactory> factories)
factories - The ordered collection of connection factories.public RoundRobinLoadBalancingAlgorithm(Collection<? extends ConnectionFactory> factories, LoadBalancerEventListener listener)
factories - The ordered collection of connection factories.listener - The event listener which should be notified whenever a
connection factory changes state from online to offline or
vice-versa.public RoundRobinLoadBalancingAlgorithm(Collection<? extends ConnectionFactory> factories, LoadBalancerEventListener listener, long interval, TimeUnit unit)
factories - The connection factories.listener - The event listener which should be notified whenever a
connection factory changes state from online to offline or
vice-versa.interval - The interval between attempts to poll offline factories.unit - The time unit for the interval between attempts to poll
offline factories.public RoundRobinLoadBalancingAlgorithm(Collection<? extends ConnectionFactory> factories, LoadBalancerEventListener listener, long interval, TimeUnit unit, ScheduledExecutorService scheduler)
factories - The connection factories.listener - The event listener which should be notified whenever a
connection factory changes state from online to offline or
vice-versa.interval - The interval between attempts to poll offline factories.unit - The time unit for the interval between attempts to poll
offline factories.scheduler - The scheduler which should for periodically monitoring dead
connection factories to see if they are usable again.public RoundRobinLoadBalancingAlgorithm(Collection<? extends ConnectionFactory> factories, long interval, TimeUnit unit)
factories - The connection factories.interval - The interval between attempts to poll offline factories.unit - The time unit for the interval between attempts to poll
offline factories.public RoundRobinLoadBalancingAlgorithm(Collection<? extends ConnectionFactory> factories, long interval, TimeUnit unit, ScheduledExecutorService scheduler)
factories - The connection factories.interval - The interval between attempts to poll offline factories.unit - The time unit for the interval between attempts to poll
offline factories.scheduler - The scheduler which should for periodically monitoring dead
connection factories to see if they are usable again.public void close()
LoadBalancingAlgorithmclose in interface Closeableclose in interface AutoCloseableclose in interface LoadBalancingAlgorithmpublic final ConnectionFactory getConnectionFactory() throws LdapException
LoadBalancingAlgorithmgetConnectionFactory in interface LoadBalancingAlgorithmLdapException - If no connection factories are available for use.Copyright © 2011-2015 ForgeRock AS. All Rights Reserved.