org.jboss.ha.client.loadbalance
Class RandomRobin

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

public class RandomRobin
extends Object
implements LoadBalancePolicy

LoadBalancePolicy implementation that always fully randomly selects its target (without basing its decision on any history).

Version:
$Revision: 57642 $
Author:
Sacha Labourey., brian.stansberry@jboss.com
See Also:
LoadBalancePolicy, Serialized Form

Field Summary
static Random localRandomizer
          Random used to pick the target.
 
Constructor Summary
RandomRobin()
           
 
Method Summary
 Object chooseTarget(FamilyClusterInfo clusterFamily)
          Gets the target for the next remote call.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

localRandomizer

public static final Random localRandomizer
Random used to pick the target. 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. We make this public so other LoadBalancePolicy implementations can use it.

Constructor Detail

RandomRobin

public RandomRobin()
Method Detail

chooseTarget

public Object chooseTarget(FamilyClusterInfo clusterFamily)
Description copied from interface: LoadBalancePolicy
Gets the target for the next remote call.

Called when the client wishes to know on which node the next invocation must be performed.

Specified by:
chooseTarget in interface LoadBalancePolicy
Parameters:
clusterFamily - object encapsulating a list of potential target nodes
Returns:
The selected target for the next invocation


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