Package adams.multiprocess
Class AbstractJobRunner<T extends Job>
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.multiprocess.AbstractJobRunner<T>
-
- Type Parameters:
T- the type of job to handle
- All Implemented Interfaces:
CleanUpHandler,Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,Pausable,QuickInfoSupporter,SizeOfHandler,JobRunner<T>,Serializable
- Direct Known Subclasses:
AbstractMetaJobRunner,LocalJobRunner
public abstract class AbstractJobRunner<T extends Job> extends AbstractOptionHandler implements JobRunner<T>
Ancestor for jobrunner classes.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Actorm_FlowContextthe flow context.protected booleanm_Pausedwhether the execution is paused.protected booleanm_Runningwhether the jobs are being executed.protected booleanm_Terminatingwhether termination is under way.-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractJobRunner()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcleanUp()Cleans up data structures, frees up memory.protected abstract StringdoStart()Performing actual start up.protected abstract StringdoStop()Performing actual stop.protected abstract StringdoTerminate(boolean wait)Performing actual terminate up.ActorgetFlowContext()Return the flow context, if any.protected voidinitialize()Initializes the members.booleanisPaused()Returns whether the object is currently paused.booleanisRunning()Returns whether the job are being executed.voidpauseExecution()Pauses the execution.protected StringpostStart()After actual start up.protected StringpostStop()After actual stop.protected StringpostTerminate()After actual terminate up.protected StringpreStart()Before actual start up.protected StringpreStop()Before actual stop.protected StringpreTerminate()Before actual terminate up.voidresumeExecution()Resumes the execution.voidsetFlowContext(Actor value)Sets the flow context, if any.voidstart()Starts the execution of jobs.voidstop()Stops the execution after all currently queued jobs have been executed.voidterminate()Stops the execution immediately.voidterminate(boolean wait)Stops the execution immediately.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, defineOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.Destroyable
destroy
-
Methods inherited from interface adams.multiprocess.JobRunner
add, add, addJobCompleteListener, clear, complete, getJobs, removeJobCompleteListener
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, defineOptions, getOptionManager, toCommandLine
-
Methods inherited from interface adams.core.QuickInfoSupporter
getQuickInfo
-
-
-
-
Field Detail
-
m_Running
protected boolean m_Running
whether the jobs are being executed.
-
m_Paused
protected boolean m_Paused
whether the execution is paused.
-
m_Terminating
protected boolean m_Terminating
whether termination is under way.
-
m_FlowContext
protected transient Actor m_FlowContext
the flow context.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classAbstractOptionHandler
-
setFlowContext
public void setFlowContext(Actor value)
Sets the flow context, if any.- Specified by:
setFlowContextin interfaceJobRunner<T extends Job>- Parameters:
value- the context
-
getFlowContext
public Actor getFlowContext()
Return the flow context, if any.- Specified by:
getFlowContextin interfaceJobRunner<T extends Job>- Returns:
- the context, null if none available
-
preStart
protected String preStart()
Before actual start up.
Default implementation does nothing.- Returns:
- null if successful, otherwise error message
-
doStart
protected abstract String doStart()
Performing actual start up. Only gets executed ifpreStart()was successful.- Returns:
- null if successful, otherwise error message
- See Also:
preStart()
-
postStart
protected String postStart()
After actual start up. Only gets executed ifpreStart()was successful.
Default implementation does nothing.- Returns:
- null if successful, otherwise error message
-
start
public void start()
Starts the execution of jobs.
-
preStop
protected String preStop()
Before actual stop.
Default implementation does nothing- Returns:
- null if successful, otherwise error message
-
doStop
protected abstract String doStop()
Performing actual stop.- Returns:
- null if successful, otherwise error message
-
postStop
protected String postStop()
After actual stop.- Returns:
- null if successful, otherwise error message
-
stop
public void stop()
Stops the execution after all currently queued jobs have been executed.
-
preTerminate
protected String preTerminate()
Before actual terminate up.
Default implementation does nothing- Returns:
- null if successful, otherwise error message
-
doTerminate
protected abstract String doTerminate(boolean wait)
Performing actual terminate up.- Parameters:
wait- whether to wait for the jobs to finish- Returns:
- null if successful, otherwise error message
-
postTerminate
protected String postTerminate()
After actual terminate up.- Returns:
- null if successful, otherwise error message
-
terminate
public void terminate()
Stops the execution immediately. Waits for the jobs to finish.
-
terminate
public void terminate(boolean wait)
Stops the execution immediately.
-
isRunning
public boolean isRunning()
Returns whether the job are being executed.
-
pauseExecution
public void pauseExecution()
Pauses the execution.- Specified by:
pauseExecutionin interfaceJobRunner<T extends Job>- Specified by:
pauseExecutionin interfacePausable
-
isPaused
public boolean isPaused()
Returns whether the object is currently paused.
-
resumeExecution
public void resumeExecution()
Resumes the execution.- Specified by:
resumeExecutionin interfaceJobRunner<T extends Job>- Specified by:
resumeExecutionin interfacePausable
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.
Default implementation does nothing.- Specified by:
cleanUpin interfaceCleanUpHandler
-
-