public final class FailoverLoadBalancingAlgorithm extends Object
This algorithm is typically used for load-balancing between data
centers, where there is preference to always forward connection requests to
the closest available data center. This algorithm contrasts with the
RoundRobinLoadBalancingAlgorithm which is used for load-balancing
within a data center.
This algorithm selects connection factories based on the order in which they were provided during construction. More specifically, an attempt to obtain a connection factory will always return the first operational connection factory in the list. Applications should, therefore, organize the connection factories such that the preferred (usually the closest) connection factories appear before those which are less preferred.
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 |
|---|
FailoverLoadBalancingAlgorithm(Collection<? extends ConnectionFactory> factories)
Creates a new fail-over load balancing algorithm which will monitor
offline connection factories every 1 second using the default scheduler.
|
FailoverLoadBalancingAlgorithm(Collection<? extends ConnectionFactory> factories,
LoadBalancerEventListener listener)
Creates a new fail-over load balancing algorithm which will monitor
offline connection factories every 1 second using the default scheduler.
|
FailoverLoadBalancingAlgorithm(Collection<? extends ConnectionFactory> factories,
LoadBalancerEventListener listener,
long interval,
TimeUnit unit)
Creates a new fail-over load balancing algorithm which will monitor
offline connection factories using the specified frequency using the
default scheduler.
|
FailoverLoadBalancingAlgorithm(Collection<? extends ConnectionFactory> factories,
LoadBalancerEventListener listener,
long interval,
TimeUnit unit,
ScheduledExecutorService scheduler)
Creates a new fail-over load balancing algorithm which will monitor
offline connection factories using the specified frequency and scheduler.
|
FailoverLoadBalancingAlgorithm(Collection<? extends ConnectionFactory> factories,
long interval,
TimeUnit unit)
Creates a new fail-over load balancing algorithm which will monitor
offline connection factories using the specified frequency using the
default scheduler.
|
FailoverLoadBalancingAlgorithm(Collection<? extends ConnectionFactory> factories,
long interval,
TimeUnit unit,
ScheduledExecutorService scheduler)
Creates a new fail-over 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 FailoverLoadBalancingAlgorithm(Collection<? extends ConnectionFactory> factories)
factories - The ordered collection of connection factories.public FailoverLoadBalancingAlgorithm(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 FailoverLoadBalancingAlgorithm(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 FailoverLoadBalancingAlgorithm(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 FailoverLoadBalancingAlgorithm(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 FailoverLoadBalancingAlgorithm(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.