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

java.lang.Object
  extended by org.ow2.carol.cmi.lb.policy.AbsLBPolicy<T>
      extended by org.ow2.carol.cmi.lb.policy.FirstAvailablePolicy<T>
Type Parameters:
T - The type of object that was load-balanced
All Implemented Interfaces:
org.ow2.carol.cmi.lb.policy.ILBPolicy<T>

@ThreadSafe
public final class FirstAvailablePolicy<T extends org.ow2.carol.cmi.lb.LoadBalanceable>
extends AbsLBPolicy<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
FirstAvailablePolicy()
          Build the first available policy.
 
Method Summary
 T choose(java.util.List<T> loadBalanceables)
          Chooses the first load-balanceable available among the list of load-balanceable.
 java.lang.String toString()
           
 
Methods inherited from class org.ow2.carol.cmi.lb.policy.AbsLBPolicy
getLBStrategy, onInvokeException, onLookupException, onReturn, setClusterViewManager, setLBStrategy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FirstAvailablePolicy

public FirstAvailablePolicy()
Build the first available policy.

Method Detail

choose

public T choose(java.util.List<T> loadBalanceables)
                                                      throws org.ow2.carol.cmi.lb.NoLoadBalanceableException
Chooses the first load-balanceable available among the list of load-balanceable.

Specified by:
choose in interface org.ow2.carol.cmi.lb.policy.ILBPolicy<T extends org.ow2.carol.cmi.lb.LoadBalanceable>
Specified by:
choose in class AbsLBPolicy<T extends org.ow2.carol.cmi.lb.LoadBalanceable>
Parameters:
loadBalanceables - the list of load-balanceables
Returns:
the chosen load-balanceable
Throws:
org.ow2.carol.cmi.lb.NoLoadBalanceableException - if no server available

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2008 OW2 Consortium. All Rights Reserved.