public abstract class AbstractRoundRobinServiceLoadHelper extends Object implements IServiceLoadHelper
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.
Modifier and Type | Field and Description |
---|---|
protected static boolean |
INFO |
protected static org.apache.log4j.Logger |
log |
Modifier | Constructor and Description |
---|---|
protected |
AbstractRoundRobinServiceLoadHelper() |
Modifier and Type | Method and Description |
---|---|
protected abstract UUID[] |
awaitServices(int minCount,
long timeout)
Await the availability of at least the specified #of
IDataService s. |
UUID[] |
getUnderUtilizedDataServices(int minCount,
int maxCount,
UUID exclude)
Issues
UUID s using a round-robin over those that are joined. |
protected static final org.apache.log4j.Logger log
protected static final boolean INFO
protected AbstractRoundRobinServiceLoadHelper()
protected abstract UUID[] awaitServices(int minCount, long timeout) throws InterruptedException, TimeoutException
IDataService
s.minCount
- The minimum #of data services.timeout
- The timeout (ms).UUID
s of the IDataService
s
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.InterruptedException
TimeoutException
AbstractScaleOutFederation.awaitServices(int, long)
public UUID[] getUnderUtilizedDataServices(int minCount, int maxCount, UUID exclude) throws InterruptedException, TimeoutException
UUID
s using a round-robin over those that are joined. For
this purpose, the joined DataService
s 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.
getUnderUtilizedDataServices
in interface IServiceLoadHelper
TimeoutException
InterruptedException
TestLoadBalancerRoundRobin
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.