org.jboss.ha.framework.interfaces
public class: FirstAvailable [javadoc |
source]
java.lang.Object
org.jboss.ha.framework.interfaces.FirstAvailable
All Implemented Interfaces:
LoadBalancePolicy
LoadBalancingPolicy implementation that always favor the first available target i.e.
no load balancing occurs. Nevertheless, the first target is randomly selected.
This does not mean that fail-over will not occur if the
first member in the list dies. In this case, fail-over will occur, and a new target
will become the first member and invocation will continously be invoked on the same
new target until its death. Each proxy using this policy will elect its own
prefered target: the target is not shared accross the proxy family (for this
behaviour please take a look at FirstAvailableIdenticalAllProxies)
| Field Summary |
|---|
| protected transient Object | electedTarget | |
| Method from org.jboss.ha.framework.interfaces.FirstAvailable Detail: |
public Object chooseTarget(FamilyClusterInfo clusterFamily) {
return chooseTarget(clusterFamily, null);
}
|
public Object chooseTarget(FamilyClusterInfo clusterFamily,
Invocation routingDecision) {
List targets = clusterFamily.getTargets ();
if (targets.size () == 0)
return null;
if ( (this.electedTarget != null) && targets.contains (this.electedTarget) )
{
return this.electedTarget;
}
else
{
int cursor = RandomRobin.localRandomizer.nextInt(targets.size());
this.electedTarget = targets.get(cursor);
return this.electedTarget;
}
}
|
public void init(HARMIClient father) {
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
// do not use the HARMIClient in this policy
}
|