FileDocCategorySizeDatePackage
RandomRobin.javaAPI DocJBoss 4.2.12811Fri Jul 13 20:52:38 BST 2007org.jboss.ha.framework.interfaces

RandomRobin

public class RandomRobin extends Object implements LoadBalancePolicy
LoadBalancingPolicy implementation that always fully randomly select its target (without basing its decision on any historic).
author
Sacha Labourey.
version
$Revision: 57188 $
see
org.jboss.ha.framework.interfaces.LoadBalancePolicy

Fields Summary
private static final long
serialVersionUID
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.
Constructors Summary
Methods Summary
public java.lang.ObjectchooseTarget(FamilyClusterInfo clusterFamily)

      return chooseTarget(clusterFamily, null);
   
public java.lang.ObjectchooseTarget(FamilyClusterInfo clusterFamily, org.jboss.invocation.Invocation routingDecision)

      ArrayList targets = clusterFamily.getTargets ();
      int max = targets.size();

      if (max == 0)
         return null;

      int cursor = localRandomizer.nextInt (max);
      return targets.get(cursor);
   
public voidinit(HARMIClient father)


   // Static --------------------------------------------------------
   
   // Constructors --------------------------------------------------
       
    // Public --------------------------------------------------------
   
   // LoadBalancePolicy implementation ----------------------------------------------

       
   
      // do not use the HARMIClient in this policy