|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.pipeline.driver.AbstractStageDriver org.apache.commons.pipeline.driver.ThreadPoolStageDriver
public class ThreadPoolStageDriver
This StageDriver
implementation uses a pool of threads
to process objects from an input queue.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.apache.commons.pipeline.StageDriver |
---|
StageDriver.State |
Field Summary |
---|
Fields inherited from class org.apache.commons.pipeline.driver.AbstractStageDriver |
---|
context, currentState, errors, faultTolerance, processingExceptions, stage |
Constructor Summary | |
---|---|
ThreadPoolStageDriver(Stage stage,
StageContext context,
BlockingQueue queue,
long timeout,
FaultTolerance faultTolerance,
int numThreads)
Creates a new ThreadPoolStageDriver. |
Method Summary | |
---|---|
void |
finish()
Causes processing to shut down gracefully. |
Feeder |
getFeeder()
Return the Feeder used to feed data to the queue of objects to be processed. |
int |
getNumThreads()
Returns the number of threads allocated to the thread pool. |
int |
getQueueSize()
Get the size of the queue used by this StageDriver. |
long |
getTimeout()
Get the timeout value (in milliseconds) used by this StageDriver on thread termination. |
void |
start()
Start the processing of the stage. |
Methods inherited from class org.apache.commons.pipeline.driver.AbstractStageDriver |
---|
getFatalErrors, getFaultTolerance, getProcessingExceptions, getStage, getState, isInState, recordFatalError, recordProcessingException, setFaultTolerance, setState, testAndSetState |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ThreadPoolStageDriver(Stage stage, StageContext context, BlockingQueue queue, long timeout, FaultTolerance faultTolerance, int numThreads)
stage
- The stage that the driver will runcontext
- the context in which to run the stagequeue
- The object queue to use for storing objects prior to processing. The
default is LinkedBlockingQueue
timeout
- The amount of time, in milliseconds, that the worker thread
will wait before checking the processing state if no objects are available
in the thread's queue.faultTolerance
- Flag determining the behavior of the driver when
an error is encountered in execution of Stage.process(Object)
.
If this is set to false, any exception thrown during Stage.process(Object)
will cause the worker thread to halt without executing Stage.postprocess()
(Stage.release()
will be called.)numThreads
- Number of threads that will be simultaneously reading from queueMethod Detail |
---|
public Feeder getFeeder()
getFeeder
in interface StageDriver
getFeeder
in class AbstractStageDriver
public void start() throws StageException
start
in interface StageDriver
start
in class AbstractStageDriver
StageException
- Thrown if the driver is in an illegal state during startuppublic void finish() throws StageException
finish
in interface StageDriver
finish
in class AbstractStageDriver
StageException
- Thrown if the driver is in an illegal state for shutdown.public int getQueueSize()
public long getTimeout()
public int getNumThreads()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |