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

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

public abstract class AbsLBPolicy<T extends org.ow2.carol.cmi.lb.LoadBalanceable>
extends java.lang.Object
implements org.ow2.carol.cmi.lb.policy.ILBPolicy<T>

Abstract implementation of a ILBPolicy, using the class DecisionUtil to take a decision and the class BasicDecisionManager to execute the decision.

Author:
Loris Bouzonnet
See Also:
DecisionUtil, BasicDecisionManager

Constructor Summary
AbsLBPolicy()
          Default constructor.
AbsLBPolicy(org.ow2.carol.cmi.controller.common.ClusterViewManager clusterViewManager)
           
 
Method Summary
abstract  T choose(java.util.List<T> loadBalanceables)
          Chooses a load-balanceable among the list of load-balanceables.
 org.ow2.carol.cmi.lb.strategy.ILBStrategy<T> getLBStrategy()
          Return a strategy to modify the behavior of this policy.
 BasicDecisionManager<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.
 BasicDecisionManager<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>
BasicDecisionManager<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 setClusterViewManager(org.ow2.carol.cmi.controller.common.ClusterViewManager clusterViewManager)
          Set the manager of the cluster view.
 void setLBStrategy(org.ow2.carol.cmi.lb.strategy.ILBStrategy<T> lbStrategy)
          Sets a strategy to modify the behavior of this policy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbsLBPolicy

public AbsLBPolicy()
Default constructor.


AbsLBPolicy

public AbsLBPolicy(org.ow2.carol.cmi.controller.common.ClusterViewManager clusterViewManager)
Parameters:
clusterViewManager - the manager of the cluster view
Method Detail

choose

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

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

onInvokeException

public BasicDecisionManager<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.

Specified by:
onInvokeException in interface org.ow2.carol.cmi.lb.policy.ILBPolicy<T extends org.ow2.carol.cmi.lb.LoadBalanceable>
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

public <ReturnType> BasicDecisionManager<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.

Specified by:
onReturn in interface org.ow2.carol.cmi.lb.policy.ILBPolicy<T extends org.ow2.carol.cmi.lb.LoadBalanceable>
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

onLookupException

public BasicDecisionManager<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.

Specified by:
onLookupException in interface org.ow2.carol.cmi.lb.policy.ILBPolicy<T extends org.ow2.carol.cmi.lb.LoadBalanceable>
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

setLBStrategy

public void setLBStrategy(org.ow2.carol.cmi.lb.strategy.ILBStrategy<T> lbStrategy)
Sets a strategy to modify the behavior of this policy.

Specified by:
setLBStrategy in interface org.ow2.carol.cmi.lb.policy.ILBPolicy<T extends org.ow2.carol.cmi.lb.LoadBalanceable>
Parameters:
lbStrategy - a strategy of load-balancing

getLBStrategy

public org.ow2.carol.cmi.lb.strategy.ILBStrategy<T> getLBStrategy()
Return a strategy to modify the behavior of this policy.

Specified by:
getLBStrategy in interface org.ow2.carol.cmi.lb.policy.ILBPolicy<T extends org.ow2.carol.cmi.lb.LoadBalanceable>
Returns:
a strategy to modify the behavior of this policy

setClusterViewManager

public void setClusterViewManager(org.ow2.carol.cmi.controller.common.ClusterViewManager clusterViewManager)
Set the manager of the cluster view.

Parameters:
clusterViewManager - the manager of the cluster view


Copyright © 2008 OW2 Consortium. All Rights Reserved.