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

FirstAvailable

public class FirstAvailable extends Object implements 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)
author
Bill Burke.
author
Sacha Labourey.
version
$Revision: 57188 $
see
org.jboss.ha.framework.interfaces.LoadBalancePolicy

Revisions:

2002/08/24: Sacha Labourey

  1. Use the target repository
  2. First choice is randomly selected to distribute the initial load
  3. When the list of targets change, we try to keep using the same previously elected target node if it still exists. Previously, we were working with the position id of the target node, thus if the list order changed, we were switching to another node while our prefered node was still up

Fields Summary
private static final long
serialVersionUID
protected transient Object
electedTarget
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 ();
      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 voidinit(HARMIClient father)

   
   // Static --------------------------------------------------------
   
   // Constructors --------------------------------------------------
       
    // Public --------------------------------------------------------
   
       
   
      // do not use the HARMIClient in this policy