Package edu.jas.util

Class DistThreadPool

java.lang.Object
edu.jas.util.DistThreadPool

public class DistThreadPool extends Object
Distributed thread pool. Using stack / list work-pile and Executable Channels and Servers.
  • Field Details

    • mfile

      private final String mfile
      machine file to use.
    • DEFAULT_MFILE

      private static final String DEFAULT_MFILE
      default machine file for test.
      See Also:
    • threads

      protected final int threads
      Number of threads to use.
    • DEFAULT_SIZE

      static final int DEFAULT_SIZE
      Default number of threads to use.
      See Also:
    • ec

      Channels to remote executable servers.
    • workers

      protected DistPoolThread[] workers
      Array of workers.
    • idleworkers

      protected int idleworkers
      Number of idle workers.
    • jobstack

      protected LinkedList<Runnable> jobstack
      Work queue / stack.
    • strategy

      protected StrategyEnumeration strategy
    • logger

      private static final org.apache.logging.log4j.Logger logger
    • debug

      private static final boolean debug
      See Also:
  • Constructor Details

    • DistThreadPool

      public DistThreadPool()
      Constructs a new DistThreadPool with strategy StrategyEnumeration.FIFO and size DEFAULT_SIZE.
    • DistThreadPool

      public DistThreadPool(StrategyEnumeration strategy)
      Constructs a new DistThreadPool with size DEFAULT_SIZE.
      Parameters:
      strategy - for job processing.
    • DistThreadPool

      public DistThreadPool(int size)
      Constructs a new DistThreadPool with strategy StrategyEnumeration.FIFO.
      Parameters:
      size - of the pool.
    • DistThreadPool

      public DistThreadPool(int size, String mfile)
      Constructs a new DistThreadPool with strategy StrategyEnumeration.FIFO.
      Parameters:
      size - of the pool.
      mfile - machine file.
    • DistThreadPool

      public DistThreadPool(StrategyEnumeration strategy, int size, String mfile)
      Constructs a new DistThreadPool.
      Parameters:
      strategy - for job processing.
      size - of the pool.
      mfile - machine file.
  • Method Details

    • toString

      public String toString()
      String representation.
      Overrides:
      toString in class Object
    • init

      public void init()
      thread initialization and start.
    • getNumber

      public int getNumber()
      number of worker threads.
    • getStrategy

      public StrategyEnumeration getStrategy()
      get used strategy.
    • getEC

      public ExecutableChannels getEC()
      the used executable channel.
    • terminate

      public void terminate(boolean shutDown)
      Terminates the threads.
      Parameters:
      shutDown - true, if shut-down of the remote executable servers is requested, false, if remote executable servers stay alive.
    • terminate

      public void terminate()
      Terminates the threads.
    • addJob

      public void addJob(Runnable job)
      adds a job to the workpile.
      Parameters:
      job -
    • getJob

      protected Runnable getJob() throws InterruptedException
      get a job for processing.
      Throws:
      InterruptedException
    • hasJobs

      public boolean hasJobs()
      check if there are jobs for processing.
    • hasJobs

      public boolean hasJobs(int n)
      check if there are more than n jobs for processing.
      Parameters:
      n - Integer
      Returns:
      true, if there are possibly more than n jobs.