org.apache.commons.pipeline.driver
Class DedicatedThreadStageDriver

java.lang.Object
  extended by org.apache.commons.pipeline.driver.AbstractStageDriver
      extended by org.apache.commons.pipeline.driver.DedicatedThreadStageDriver
All Implemented Interfaces:
StageDriver

public class DedicatedThreadStageDriver
extends AbstractStageDriver

This is a very simple implementation of a AbstractStageDriver which spawns a single thread to process a stage.


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
DedicatedThreadStageDriver(Stage stage, StageContext context, BlockingQueue queue, long timeout, FaultTolerance faultTolerance)
          Creates a new DedicatedThreadStageDriver with the specified thread wait timeout and fault tolerance values.
 
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 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

DedicatedThreadStageDriver

public DedicatedThreadStageDriver(Stage stage,
                                  StageContext context,
                                  BlockingQueue queue,
                                  long timeout,
                                  FaultTolerance faultTolerance)
Creates a new DedicatedThreadStageDriver with the specified thread wait timeout and fault tolerance values.

Parameters:
stage - The stage that the driver will run
context - the context in which to run the stage
queue - 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.)
Method Detail

getFeeder

public Feeder getFeeder()
Return the Feeder used to feed data to the queue of objects to be processed.

Specified by:
getFeeder in interface StageDriver
Specified by:
getFeeder in class AbstractStageDriver
Returns:
The feeder for objects processed by this driver's stage.

start

public void start()
           throws StageException
Start the processing of the stage.

Specified by:
start in interface StageDriver
Specified by:
start in class AbstractStageDriver
Throws:
StageException - Thrown if the driver is in an illegal state during startup

finish

public void finish()
            throws StageException
Causes processing to shut down gracefully.

Specified by:
finish in interface StageDriver
Specified by:
finish in class AbstractStageDriver
Throws:
StageException - Thrown if the driver is in an illegal state for shutdown.

getQueueSize

public int getQueueSize()
Get the size of the queue used by this StageDriver.

Returns:
the queue capacity

getTimeout

public long getTimeout()
Get the timeout value (in milliseconds) used by this StageDriver on thread termination.

Returns:
the timeout setting in milliseconds


Copyright © 2004-2009 The Apache Software Foundation. All Rights Reserved.