org.jboss.ha.client.loadbalance.aop
Class FirstAvailable

java.lang.Object
  extended by org.jboss.ha.client.loadbalance.FirstAvailable
      extended by org.jboss.ha.client.loadbalance.aop.FirstAvailable
All Implemented Interfaces:
Serializable, AopLoadBalancePolicy, LoadBalancePolicy

public class FirstAvailable
extends FirstAvailable
implements AopLoadBalancePolicy

LoadBalancePolicy implementation that, once a target is chosen, always favors that same target; i.e. no further load balancing occurs. Useful in cases where "sticky session" behavior is desired. Differs from the superclass in the way that the chooseTarget(FamilyClusterInfo, Invocation) method initially selects the target. Instead of always randomly selecting the target, the method will check the passed invocation's metadata for the ClusterConstants.HA_TARGET key in the ClusterConstants.CLUSTERED_REMOTING group. If an object is found there and it is a valid target associated with the given FamilyClusterInfo, that target will be used. Otherwise the target will be randomly chosen. This mechanism allows the proxy that contains this policy to specify the preferred target via invocation metadata.

Each proxy using this policy will choose its own preferred target: the target is not shared accross the proxy family. For shared behaviour please take a look at FirstAvailableIdenticalAllProxies.

Version:
$Revision: 57642 $
Author:
Brian Stansberry
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jboss.ha.client.loadbalance.FirstAvailable
electedTarget
 
Constructor Summary
FirstAvailable()
           
 
Method Summary
 Object chooseTarget(FamilyClusterInfo clusterFamily, org.jboss.aop.joinpoint.Invocation invocation)
          Called when the stub wishes to know on which node the next invocation must be performed.
 
Methods inherited from class org.jboss.ha.client.loadbalance.FirstAvailable
chooseTarget, electTarget
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.ha.client.loadbalance.LoadBalancePolicy
chooseTarget
 

Constructor Detail

FirstAvailable

public FirstAvailable()
Method Detail

chooseTarget

public Object chooseTarget(FamilyClusterInfo clusterFamily,
                           org.jboss.aop.joinpoint.Invocation invocation)
Description copied from interface: AopLoadBalancePolicy
Called when the stub wishes to know on which node the next invocation must be performed.

Specified by:
chooseTarget in interface AopLoadBalancePolicy
Parameters:
clusterFamily - A list of potential target nodes
invocation - The actual invocation object if the policy wants to have some kind of invocation-based routing strategy
Returns:
The selected target for the next invocation


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.