org.ow2.cmi.lb.policy
Class FirstAvailable<T extends org.ow2.cmi.lb.LoadBalanceable>
java.lang.Object
org.ow2.cmi.lb.policy.AbstractPolicy<T>
org.ow2.cmi.lb.policy.FirstAvailable<T>
- Type Parameters:
T - The type of objects that are load-balanced
- All Implemented Interfaces:
- org.ow2.cmi.lb.policy.IPolicy<T>
@ThreadSafe
public final class FirstAvailable<T extends org.ow2.cmi.lb.LoadBalanceable>
- extends AbstractPolicy<T>
Implementation of a policy of load-balancing that always favors the first available load-balanceable.
When the list of servers change, we try to keep the current elected load-balanceable if it still exists.
If the list order changed, we were switching to another load-balanceable.
- Author:
- The new CMI team
|
Constructor Summary |
FirstAvailable()
Build the first available policy. |
|
Method Summary |
T |
choose(java.util.Collection<T> loadBalanceables)
Chooses the first load-balanceable available among the list of load-balanceable. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
FirstAvailable
public FirstAvailable()
- Build the first available policy.
choose
public T choose(java.util.Collection<T> loadBalanceables)
throws org.ow2.cmi.lb.NoLoadBalanceableException
- Chooses the first load-balanceable available among the list of load-balanceable.
- Specified by:
choose in interface org.ow2.cmi.lb.policy.IPolicy<T extends org.ow2.cmi.lb.LoadBalanceable>- Specified by:
choose in class AbstractPolicy<T extends org.ow2.cmi.lb.LoadBalanceable>
- Parameters:
loadBalanceables - the list of load-balanceables
- Returns:
- the chosen load-balanceable
- Throws:
org.ow2.cmi.lb.NoLoadBalanceableException - if no server available
toString
public java.lang.String toString()
- Overrides:
toString in class java.lang.Object
Copyright © 2009 OW2 Consortium. All Rights Reserved.