Package org.jppf.load.balancer
Class AbstractBundler<T extends LoadBalancingProfile>
java.lang.Object
org.jppf.load.balancer.AbstractBundler<T>
- Type Parameters:
T- the type of parameters profile used by this bundler.
- All Implemented Interfaces:
Bundler<T>,ContextAwareness
- Direct Known Subclasses:
AbstractAdaptiveBundler,AutotunedDelegatingBundler,FixedSizeBundler,NodeThreadsBundler
public abstract class AbstractBundler<T extends LoadBalancingProfile>
extends Object
implements Bundler<T>, ContextAwareness
Abstract implementation of the
Bundler interface. In general, it will be more convenient to extend this class than
to implement Bundler directly.
It provides working implementations of the getTimestamp(), getProfile(),
setup() and dispose() methods, along with an empty implementation of feedback(int, double).
It also adds the maxSize() method which uses an internal context object to compute a usable cap for the value returned by getBundleSize().
- Author:
- Laurent Cohen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intThe bundler number for this bundler.protected TThe parameters of this load-balancing algorithm.protected final longThe creation timestamp for this bundler.Fields inherited from interface org.jppf.load.balancer.Bundler
BUNDLER_COUNT -
Constructor Summary
ConstructorsConstructorDescriptionAbstractBundler(T profile) Creates a new instance with the specified parameters profile. -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()Release the resources used by this bundler.voidfeedback(int bundleSize, double totalTime) This implementation does nothing and should be overridden in subclasses that compute the bundle size based on the feedback from the nodes.intGet this bundler's number (a unique Bundle instance count).Get the corresponding node's context information.Get the parameters of this load-balancing algorithm.longGet the timestamp at which this bundler was created.intmaxSize()Get the max bundle size that can be used for this bundler.voidsetJPPFContext(JPPFContext context) Set the corresponding node's context information.voidsetup()Perform context-independent initializations.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jppf.load.balancer.Bundler
getBundleSize
-
Field Details
-
bundlerNumber
protected final int bundlerNumberThe bundler number for this bundler. -
timestamp
protected final long timestampThe creation timestamp for this bundler. -
profile
The parameters of this load-balancing algorithm.
-
-
Constructor Details
-
AbstractBundler
Creates a new instance with the specified parameters profile.- Parameters:
profile- the parameters of the load-balancing algorithm,
-
-
Method Details
-
maxSize
public int maxSize()Get the max bundle size that can be used for this bundler.- Returns:
- the bundle size as an int.
-
feedback
public void feedback(int bundleSize, double totalTime) This implementation does nothing and should be overridden in subclasses that compute the bundle size based on the feedback from the nodes.- Specified by:
feedbackin interfaceBundler<T extends LoadBalancingProfile>- Parameters:
bundleSize- the number of tasks retruning from execution on a node.totalTime- the total round-trip time of the tasks, from the server to the node and back.
-
getTimestamp
public long getTimestamp()Get the timestamp at which this bundler was created. This is used to enable node channels to know when the bundler settings have changed.- Specified by:
getTimestampin interfaceBundler<T extends LoadBalancingProfile>- Returns:
- the timestamp as a long value.
-
getBundlerNumber
public int getBundlerNumber()Get this bundler's number (a unique Bundle instance count). Used for logging and debugging.- Returns:
- the bundler number as an int.
-
setup
public void setup()Perform context-independent initializations.- Specified by:
setupin interfaceBundler<T extends LoadBalancingProfile>
-
dispose
public void dispose()Release the resources used by this bundler.- Specified by:
disposein interfaceBundler<T extends LoadBalancingProfile>
-
getProfile
Get the parameters of this load-balancing algorithm.- Specified by:
getProfilein interfaceBundler<T extends LoadBalancingProfile>- Returns:
- an instance of an implementation of
LoadBalancingProfile.
-
getJPPFContext
Description copied from interface:ContextAwarenessGet the corresponding node's context information.- Specified by:
getJPPFContextin interfaceContextAwareness- Returns:
- the JPPF context for this bundler.
-
setJPPFContext
Description copied from interface:ContextAwarenessSet the corresponding node's context information. This method is called beforeBundler.setup()with context instance. And withnullafterBundler.dispose().- Specified by:
setJPPFContextin interfaceContextAwareness- Parameters:
context- the JPPF context for this bundler.
-