Package edu.jas.util
Class DistThreadPool
java.lang.Object
edu.jas.util.DistThreadPool
Distributed thread pool. Using stack / list work-pile and Executable Channels
and Servers.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final boolean
private static final String
default machine file for test.(package private) static final int
Default number of threads to use.(package private) final ExecutableChannels
Channels to remote executable servers.protected int
Number of idle workers.protected LinkedList
<Runnable> Work queue / stack.private static final org.apache.logging.log4j.Logger
private final String
machine file to use.protected StrategyEnumeration
protected final int
Number of threads to use.protected DistPoolThread[]
Array of workers. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new DistThreadPool with strategy StrategyEnumeration.FIFO and size DEFAULT_SIZE.DistThreadPool
(int size) Constructs a new DistThreadPool with strategy StrategyEnumeration.FIFO.DistThreadPool
(int size, String mfile) Constructs a new DistThreadPool with strategy StrategyEnumeration.FIFO.DistThreadPool
(StrategyEnumeration strategy) Constructs a new DistThreadPool with size DEFAULT_SIZE.DistThreadPool
(StrategyEnumeration strategy, int size, String mfile) Constructs a new DistThreadPool. -
Method Summary
Modifier and TypeMethodDescriptionvoid
adds a job to the workpile.getEC()
the used executable channel.protected Runnable
getJob()
get a job for processing.int
number of worker threads.get used strategy.boolean
hasJobs()
check if there are jobs for processing.boolean
hasJobs
(int n) check if there are more than n jobs for processing.void
init()
thread initialization and start.void
Terminates the threads.void
terminate
(boolean shutDown) Terminates the threads.toString()
String representation.
-
Field Details
-
mfile
machine file to use. -
DEFAULT_MFILE
default machine file for test.- See Also:
-
threads
protected final int threadsNumber of threads to use. -
DEFAULT_SIZE
static final int DEFAULT_SIZEDefault number of threads to use.- See Also:
-
ec
Channels to remote executable servers. -
workers
Array of workers. -
idleworkers
protected int idleworkersNumber of idle workers. -
jobstack
Work queue / stack. -
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
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
Constructs a new DistThreadPool with strategy StrategyEnumeration.FIFO.- Parameters:
size
- of the pool.mfile
- machine file.
-
DistThreadPool
Constructs a new DistThreadPool.- Parameters:
strategy
- for job processing.size
- of the pool.mfile
- machine file.
-
-
Method Details
-
toString
String representation. -
init
public void init()thread initialization and start. -
getNumber
public int getNumber()number of worker threads. -
getStrategy
get used strategy. -
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
adds a job to the workpile.- Parameters:
job
-
-
getJob
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.
-