org.ow2.carol.cmi.lb.policy
Class HASingletonPolicy

java.lang.Object
  extended by org.ow2.carol.cmi.lb.policy.AbsLBPolicy<org.ow2.carol.cmi.reference.CMIReference>
      extended by org.ow2.carol.cmi.lb.policy.HASingletonPolicy
All Implemented Interfaces:
org.ow2.carol.cmi.lb.policy.ILBPolicy<org.ow2.carol.cmi.reference.CMIReference>

@ThreadSafe
public class HASingletonPolicy
extends AbsLBPolicy<org.ow2.carol.cmi.reference.CMIReference>

Implementation of a policy of load-balancing that always favors one server in the cluster.

Author:
The new CMI team

Constructor Summary
HASingletonPolicy()
          Construct a new instance of policy ha-singleton with the policy first available as rescue.
 
Method Summary
 org.ow2.carol.cmi.reference.CMIReference choose(java.util.List<org.ow2.carol.cmi.reference.CMIReference> cmiReferences)
          Always choose the same server (called singleton) on any client.
 java.lang.String getSingleton()
           
 java.util.List<java.lang.String> getSingletons()
          Return the order to elect a singleton in the cluster.
 void setLBStrategy(org.ow2.carol.cmi.lb.strategy.ILBStrategy<org.ow2.carol.cmi.reference.CMIReference> lbStrategy)
          Sets a strategy to modify the behavior of the rescue policy.
 void setSingleton(java.lang.String serverRef)
          Add a server in the list of singleton at the first position (it will be the new master).
 void setSingletons(java.util.List<java.lang.String> serverRefs)
          Set the order to elect a singleton in the cluster.
 java.lang.String toString()
           
 
Methods inherited from class org.ow2.carol.cmi.lb.policy.AbsLBPolicy
getLBStrategy, onInvokeException, onLookupException, onReturn, setClusterViewManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HASingletonPolicy

public HASingletonPolicy()
Construct a new instance of policy ha-singleton with the policy first available as rescue.

Method Detail

choose

public org.ow2.carol.cmi.reference.CMIReference choose(java.util.List<org.ow2.carol.cmi.reference.CMIReference> cmiReferences)
                                                throws org.ow2.carol.cmi.lb.NoLoadBalanceableException
Always choose the same server (called singleton) on any client.

Specified by:
choose in interface org.ow2.carol.cmi.lb.policy.ILBPolicy<org.ow2.carol.cmi.reference.CMIReference>
Specified by:
choose in class AbsLBPolicy<org.ow2.carol.cmi.reference.CMIReference>
Parameters:
cmiReferences - a list of references
Returns:
the singleton
Throws:
org.ow2.carol.cmi.lb.NoLoadBalanceableException - if no server available

setLBStrategy

public void setLBStrategy(org.ow2.carol.cmi.lb.strategy.ILBStrategy<org.ow2.carol.cmi.reference.CMIReference> lbStrategy)
Sets a strategy to modify the behavior of the rescue policy. It will be used only if no singleton is declared.

Specified by:
setLBStrategy in interface org.ow2.carol.cmi.lb.policy.ILBPolicy<org.ow2.carol.cmi.reference.CMIReference>
Overrides:
setLBStrategy in class AbsLBPolicy<org.ow2.carol.cmi.reference.CMIReference>
Parameters:
lbStrategy - a strategy of load-balancing

getSingletons

public java.util.List<java.lang.String> getSingletons()
Return the order to elect a singleton in the cluster. The first element will be the first elected.

Returns:
a list of reference on servers (e.g. {rmi://localhost:9000})

setSingletons

public void setSingletons(java.util.List<java.lang.String> serverRefs)
Set the order to elect a singleton in the cluster. The first element will be the first elected.

Parameters:
serverRefs - a list of reference on servers (e.g. {rmi://localhost:9000})

setSingleton

public void setSingleton(java.lang.String serverRef)
Add a server in the list of singleton at the first position (it will be the new master).

Parameters:
serverRef - a reference on server (e.g. rmi://localhost:9000)

getSingleton

public java.lang.String getSingleton()
Returns:
the reference on server that is at the first position

toString

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


Copyright © 2008 OW2 Consortium. All Rights Reserved.