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.- Version:
- $Revision$
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Actor
m_FlowContext
the flow context.protected boolean
m_Paused
whether the execution is paused.protected boolean
m_Running
whether the jobs are being executed.-
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 void
cleanUp()
Cleans up data structures, frees up memory.protected abstract String
doStart()
Performing actual start up.protected abstract String
doStop()
Performing actual stop.protected abstract String
doTerminate(boolean wait)
Performing actual terminate up.Actor
getFlowContext()
Return the flow context, if any.protected void
initialize()
Initializes the members.boolean
isPaused()
Returns whether the object is currently paused.boolean
isRunning()
Returns whether the job are being executed.void
pauseExecution()
Pauses the execution.protected String
postStart()
After actual start up.protected String
postStop()
After actual stop.protected String
postTerminate()
After actual terminate up.protected String
preStart()
Before actual start up.protected String
preStop()
Before actual stop.protected String
preTerminate()
Before actual terminate up.void
resumeExecution()
Resumes the execution.void
setFlowContext(Actor value)
Sets the flow context, if any.void
start()
Starts the execution of jobs.void
stop()
Stops the execution after all currently queued jobs have been executed.void
terminate()
Stops the execution immediately.void
terminate(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_FlowContext
protected transient Actor m_FlowContext
the flow context.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractOptionHandler
-
setFlowContext
public void setFlowContext(Actor value)
Sets the flow context, if any.- Specified by:
setFlowContext
in interfaceJobRunner<T extends Job>
- Parameters:
value
- the context
-
getFlowContext
public Actor getFlowContext()
Return the flow context, if any.- Specified by:
getFlowContext
in 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:
pauseExecution
in interfaceJobRunner<T extends Job>
- Specified by:
pauseExecution
in interfacePausable
-
isPaused
public boolean isPaused()
Returns whether the object is currently paused.
-
resumeExecution
public void resumeExecution()
Resumes the execution.- Specified by:
resumeExecution
in interfaceJobRunner<T extends Job>
- Specified by:
resumeExecution
in interfacePausable
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.
Default implementation does nothing.- Specified by:
cleanUp
in interfaceCleanUpHandler
-
-