org.ow2.cmi.lb.policy
Class FirstAvailable<T extends org.ow2.cmi.lb.LoadBalanceable>

java.lang.Object
  extended by org.ow2.cmi.lb.policy.AbstractPolicy<T>
      extended by 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 org.ow2.cmi.lb.policy.AbstractPolicy
getStrategy, onChoose, onInvokeException, onLookupException, onReturn, setClusterViewManager, setStrategy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FirstAvailable

public FirstAvailable()
Build the first available policy.

Method Detail

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.