com.bigdata.service
Class AbstractRoundRobinServiceLoadHelper

java.lang.Object
  extended by com.bigdata.service.AbstractRoundRobinServiceLoadHelper
All Implemented Interfaces:
IServiceLoadHelper
Direct Known Subclasses:
LoadBalancerService.RoundRobinServiceLoadHelper

public abstract class AbstractRoundRobinServiceLoadHelper
extends Object
implements IServiceLoadHelper

A round robin implementation that may be used when there are no scores available. Services are selected using a round robin policy. The class will notice service joins and service leaves and will incorporate the new set of services into its decision making while preserving a (mostly) round robin behavior.

Note: This has internal state in order to provide a round-robin policy. Therefore the load balancer MUST use a single instance of this class for stateful behavior to be observed.

Version:
$Id: AbstractRoundRobinServiceLoadHelper.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson

Field Summary
protected static boolean INFO
           
protected static org.apache.log4j.Logger log
           
 
Constructor Summary
protected AbstractRoundRobinServiceLoadHelper()
           
 
Method Summary
protected abstract  UUID[] awaitServices(int minCount, long timeout)
          Await the availability of at least the specified #of IDataServices.
 UUID[] getUnderUtilizedDataServices(int minCount, int maxCount, UUID exclude)
          Issues UUIDs using a round-robin over those that are joined.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.log4j.Logger log

INFO

protected static final boolean INFO
Constructor Detail

AbstractRoundRobinServiceLoadHelper

protected AbstractRoundRobinServiceLoadHelper()
Method Detail

awaitServices

protected abstract UUID[] awaitServices(int minCount,
                                        long timeout)
                                 throws InterruptedException,
                                        TimeoutException
Await the availability of at least the specified #of IDataServices.

Parameters:
minCount - The minimum #of data services.
timeout - The timeout (ms).
Returns:
An array #of the UUIDs of the IDataServices that have been discovered. Note that at least minDataServices elements will be present in this array but that ALL discovered data services may be reported.
Throws:
InterruptedException
TimeoutException
See Also:
AbstractScaleOutFederation.awaitServices(int, long)

getUnderUtilizedDataServices

public UUID[] getUnderUtilizedDataServices(int minCount,
                                           int maxCount,
                                           UUID exclude)
                                    throws InterruptedException,
                                           TimeoutException
Issues UUIDs using a round-robin over those that are joined. For this purpose, the joined DataServices are appended to an ordered set. The index of the most recently assigned service is maintained in a counter. Services that leave are removed from the set, but we do not bother to adjust the counter. We always return the UUID of the service at index MOD N, where N is the #of services that are joined at the time that this method looks at the set. We then post-increment the counter.

The round-robin allocate strategy is a good choice where there is little real data on the services, or when there is a set of services whose scores place them into an equivalence class such that we have no principled reason for preferring one service over another among those in the equivalence class.

Specified by:
getUnderUtilizedDataServices in interface IServiceLoadHelper
Returns:
Throws:
TimeoutException
InterruptedException
See Also:
TestLoadBalancerRoundRobin
TODO:
develop the concept of equivalence classes further. divide the joined services into a set of equivalence classes. parameterize this method to accept an equivalence class. always apply this method when drawing from an equivalence class.


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.