| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2013 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | |
| | | * underlying connection factories. |
| | | * <p> |
| | | * This algorithm is typically used for load-balancing <i>between</i> data |
| | | * centers, where there is preference to always forward connection |
| | | * requests to the <i>closest available</i> data center. This algorithm |
| | | * contrasts with the {@link RoundRobinLoadBalancingAlgorithm} which is used for |
| | | * load-balancing <i>within</i> a data center. |
| | | * centers, where there is preference to always forward connection requests to |
| | | * the <i>closest available</i> data center. This algorithm contrasts with the |
| | | * {@link RoundRobinLoadBalancingAlgorithm} which is used for load-balancing |
| | | * <i>within</i> a data center. |
| | | * <p> |
| | | * This algorithm selects connection factories based on the order in which they |
| | | * were provided during construction. More specifically, an attempt to obtain a |
| | |
| | | * The ordered collection of connection factories. |
| | | */ |
| | | public FailoverLoadBalancingAlgorithm(final Collection<ConnectionFactory> factories) { |
| | | super(factories); |
| | | this(factories, null, 1, TimeUnit.SECONDS, null); |
| | | } |
| | | |
| | | /** |
| | | * Creates a new fail-over load balancing algorithm which will monitor |
| | | * offline connection factories every 1 second using the default scheduler. |
| | | * |
| | | * @param factories |
| | | * The ordered collection of connection factories. |
| | | * @param listener |
| | | * The event listener which should be notified whenever a |
| | | * connection factory changes state from online to offline or |
| | | * vice-versa. |
| | | */ |
| | | public FailoverLoadBalancingAlgorithm(final Collection<ConnectionFactory> factories, |
| | | final LoadBalancerEventListener listener) { |
| | | this(factories, listener, 1, TimeUnit.SECONDS, null); |
| | | } |
| | | |
| | | /** |
| | | * Creates a new fail-over load balancing algorithm which will monitor |
| | | * offline connection factories using the specified frequency using the |
| | | * default scheduler. |
| | | * |
| | | * @param factories |
| | | * The connection factories. |
| | | * @param listener |
| | | * The event listener which should be notified whenever a |
| | | * connection factory changes state from online to offline or |
| | | * vice-versa. |
| | | * @param interval |
| | | * The interval between attempts to poll offline factories. |
| | | * @param unit |
| | | * The time unit for the interval between attempts to poll |
| | | * offline factories. |
| | | */ |
| | | public FailoverLoadBalancingAlgorithm(final Collection<ConnectionFactory> factories, |
| | | final LoadBalancerEventListener listener, final long interval, final TimeUnit unit) { |
| | | this(factories, listener, interval, unit, null); |
| | | } |
| | | |
| | | /** |
| | | * Creates a new fail-over load balancing algorithm which will monitor |
| | | * offline connection factories using the specified frequency and scheduler. |
| | | * |
| | | * @param factories |
| | | * The connection factories. |
| | | * @param listener |
| | | * The event listener which should be notified whenever a |
| | | * connection factory changes state from online to offline or |
| | | * vice-versa. |
| | | * @param interval |
| | | * The interval between attempts to poll offline factories. |
| | | * @param unit |
| | | * The time unit for the interval between attempts to poll |
| | | * offline factories. |
| | | * @param scheduler |
| | | * The scheduler which should for periodically monitoring dead |
| | | * connection factories to see if they are usable again. |
| | | */ |
| | | public FailoverLoadBalancingAlgorithm(final Collection<ConnectionFactory> factories, |
| | | final LoadBalancerEventListener listener, final long interval, final TimeUnit unit, |
| | | final ScheduledExecutorService scheduler) { |
| | | super(factories, listener, interval, unit, scheduler); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public FailoverLoadBalancingAlgorithm(final Collection<ConnectionFactory> factories, |
| | | final long interval, final TimeUnit unit) { |
| | | super(factories, interval, unit); |
| | | this(factories, null, interval, unit, null); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public FailoverLoadBalancingAlgorithm(final Collection<ConnectionFactory> factories, |
| | | final long interval, final TimeUnit unit, final ScheduledExecutorService scheduler) { |
| | | super(factories, interval, unit, scheduler); |
| | | this(factories, null, interval, unit, scheduler); |
| | | } |
| | | |
| | | /** |