![JAR search and dependency download from the Maven repository](/logo.png)
com.bigdata.service.AbstractServiceLoadHelper Maven / Gradle / Ivy
package com.bigdata.service;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
/**
* Base class for abstract implementations with integration points for the
* {@link LoadBalancerService}.
*
* @author Bryan Thompson
* @version $Id$
*/
abstract public class AbstractServiceLoadHelper implements IServiceLoadHelper {
final protected long joinTimeout;
/**
*
* @param joinTimeout
*/
protected AbstractServiceLoadHelper(final long joinTimeout) {
if (joinTimeout <= 0L)
throw new IllegalArgumentException();
this.joinTimeout = joinTimeout;
}
/**
* Return true
iff the service is under-utilized.
*
* @param score
* The score for the service.
* @param scores
* The set of scores for the known services.
*/
abstract protected boolean isUnderUtilizedDataService(
final ServiceScore score, final ServiceScore[] scores);
/**
* Return true
iff the given serviceUUID identifies an
* active {@link IDataService}.
*
* @param serviceUUID
* The service UUID.
*/
abstract protected boolean isActiveDataService(UUID serviceUUID);
/**
* Await the join of an {@link IDataService}.
*
* @param timeout
* The timeout.
* @param unit
* The unit for the timeout.
*/
abstract protected void awaitJoin(long timeout, TimeUnit unit)
throws InterruptedException;
/**
* Return an array of service UUIDs for all of the active
* {@link IDataService}s that we know about right now (snapshot).
*
* @return The array and never null
.
*/
abstract protected UUID[] getActiveServices();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy