org.jboss.ha.framework.interfaces
public class: RandomRobin [javadoc |
source]
java.lang.Object
org.jboss.ha.framework.interfaces.RandomRobin
All Implemented Interfaces:
LoadBalancePolicy
LoadBalancingPolicy implementation that always fully randomly select its target
(without basing its decision on any historic).
| Field Summary |
|---|
| public static final Random | localRandomizer | This needs to be a class variable or else you end up with multiple
Random numbers with the same seed when many clients lookup a proxy. |
| Method from org.jboss.ha.framework.interfaces.RandomRobin Detail: |
public Object chooseTarget(FamilyClusterInfo clusterFamily) {
return chooseTarget(clusterFamily, null);
}
|
public Object chooseTarget(FamilyClusterInfo clusterFamily,
Invocation routingDecision) {
List targets = clusterFamily.getTargets ();
int max = targets.size();
if (max == 0)
return null;
int cursor = localRandomizer.nextInt (max);
return targets.get(cursor);
}
|
public void init(HARMIClient father) {
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
// LoadBalancePolicy implementation ----------------------------------------------
// do not use the HARMIClient in this policy
}
|