org.ow2.carol.cmi.lb.policy
Interface ILBPolicy<T extends LoadBalanceable>

Type Parameters:
T - The type of object that was load-balanced

public interface ILBPolicy<T extends LoadBalanceable>

Interface of the policies for load-balancing.

Author:
The new CMI team

Method Summary
 T choose(java.util.List<T> loadBalanceables)
          Chooses a load-balanceable among the list of load-balanceables.
 ILBStrategy<T> getLBStrategy()
          Return a strategy to modify the behavior of this policy.
 DecisionManager<java.lang.Void> onInvokeException(java.lang.reflect.Method method, java.lang.Object[] parameters, T loadBalanceable, java.lang.Throwable thr)
          Returns a decision when an exception is thrown during an invocation for a given load-balanceable.
 DecisionManager<java.lang.Void> onLookupException(T loadBalanceable, java.lang.Throwable thr)
          Returns a decision when an exception is thrown during an access to a registry for a given load-balanceable.
<ReturnType>
DecisionManager<ReturnType>
onReturn(java.lang.reflect.Method method, java.lang.Object[] parameters, T loadBalanceable, ReturnType retVal)
          Returns a decision when the invocation of a remote method ends.
 void setLBStrategy(ILBStrategy<T> lbStrategy)
          Sets a strategy to modify the behavior of this policy.
 

Method Detail

choose

T choose(java.util.List<T> loadBalanceables)
                                 throws NoLoadBalanceableException
Chooses a load-balanceable among the list of load-balanceables.

Parameters:
loadBalanceables - a list of load-balanceables
Returns:
the chosen load-balanceable
Throws:
NoLoadBalanceableException - if no server is available

getLBStrategy

ILBStrategy<T> getLBStrategy()
Return a strategy to modify the behavior of this policy.

Returns:
a strategy to modify the behavior of this policy

setLBStrategy

void setLBStrategy(ILBStrategy<T> lbStrategy)
Sets a strategy to modify the behavior of this policy.

Parameters:
lbStrategy - a strategy of load-balancing

onLookupException

DecisionManager<java.lang.Void> onLookupException(T loadBalanceable,
                                                  java.lang.Throwable thr)
Returns a decision when an exception is thrown during an access to a registry for a given load-balanceable.

Parameters:
loadBalanceable - the load-balanceable that have caused the exception
thr - the exception that is thrown
Returns:
the decision when an exception is thrown during an access to a registry for a given load-balanceable

onInvokeException

DecisionManager<java.lang.Void> onInvokeException(java.lang.reflect.Method method,
                                                  java.lang.Object[] parameters,
                                                  T loadBalanceable,
                                                  java.lang.Throwable thr)
Returns a decision when an exception is thrown during an invocation for a given load-balanceable.

Parameters:
method - the method that was invoked
parameters - the parameters of the method
loadBalanceable - the load-balanceable that have caused the exception
thr - the exception that is thrown
Returns:
the decision when an exception is thrown during an invocation for a given load-balanceable

onReturn

<ReturnType> DecisionManager<ReturnType> onReturn(java.lang.reflect.Method method,
                                                  java.lang.Object[] parameters,
                                                  T loadBalanceable,
                                                  ReturnType retVal)
Returns a decision when the invocation of a remote method ends.

Type Parameters:
ReturnType - the type of the returned value
Parameters:
method - the method that was invoked
parameters - the parameters of the method
loadBalanceable - the load-balanceable used for the invocation
retVal - the returned value
Returns:
the decision when the invocation of a remote method ends


Copyright © 2008 OW2 Consortium. All Rights Reserved.