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

    Fields
    Modifier and Type
    Field
    Description
    protected final int
    The bundler number for this bundler.
    protected T
    The parameters of this load-balancing algorithm.
    protected final long
    The creation timestamp for this bundler.

    Fields inherited from interface org.jppf.load.balancer.Bundler

    BUNDLER_COUNT
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractBundler(T profile)
    Creates a new instance with the specified parameters profile.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Release the resources used by this bundler.
    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.
    int
    Get this bundler's number (a unique Bundle instance count).
    Get the corresponding node's context information.
    Get the parameters of this load-balancing algorithm.
    long
    Get the timestamp at which this bundler was created.
    int
    Get the max bundle size that can be used for this bundler.
    void
    Set the corresponding node's context information.
    void
    Perform context-independent initializations.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.jppf.load.balancer.Bundler

    getBundleSize
  • Field Details

    • bundlerNumber

      protected final int bundlerNumber
      The bundler number for this bundler.
    • timestamp

      protected final long timestamp
      The creation timestamp for this bundler.
    • profile

      protected T extends LoadBalancingProfile profile
      The parameters of this load-balancing algorithm.
  • Constructor Details

    • AbstractBundler

      public AbstractBundler(T profile)
      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:
      feedback in interface Bundler<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:
      getTimestamp in interface Bundler<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:
      setup in interface Bundler<T extends LoadBalancingProfile>
    • dispose

      public void dispose()
      Release the resources used by this bundler.
      Specified by:
      dispose in interface Bundler<T extends LoadBalancingProfile>
    • getProfile

      public T getProfile()
      Get the parameters of this load-balancing algorithm.
      Specified by:
      getProfile in interface Bundler<T extends LoadBalancingProfile>
      Returns:
      an instance of an implementation of LoadBalancingProfile.
    • getJPPFContext

      public JPPFContext getJPPFContext()
      Description copied from interface: ContextAwareness
      Get the corresponding node's context information.
      Specified by:
      getJPPFContext in interface ContextAwareness
      Returns:
      the JPPF context for this bundler.
    • setJPPFContext

      public void setJPPFContext(JPPFContext context)
      Description copied from interface: ContextAwareness
      Set the corresponding node's context information. This method is called before Bundler.setup() with context instance. And with null after Bundler.dispose().
      Specified by:
      setJPPFContext in interface ContextAwareness
      Parameters:
      context - the JPPF context for this bundler.