Package adams.multiprocess
Class SerializingJobRunner
-
- All Implemented Interfaces:
CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,MultiAttemptSupporter
,MultiAttemptWithWaitSupporter
,OptionHandler
,Pausable
,QuickInfoSupporter
,SizeOfHandler
,JobRunner
,Serializable
public class SerializingJobRunner extends AbstractMetaJobRunner implements MultiAttemptWithWaitSupporter
Wraps another jobrunner and serializes it to the specified export file and then waits for the specified import file (containing the serialized, executed jobs) to appear.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-job-runner <adams.multiprocess.JobRunner> (property: jobRunner) The base jobrunner to use. default: adams.multiprocess.LocalJobRunner
-export <adams.core.io.PlaceholderFile> (property: export) The file to serialize the un-executed jobs to. default: ${CWD}
-import <adams.core.io.PlaceholderFile> (property: import) The file to deserialize the executed jobs from. default: ${CWD}
-max-attempts <int> (property: numAttempts) The maximum number of intervals to wait. default: 10 minimum: 1
-attempt-nterval <int> (property: attemptInterval) The interval in milli-seconds to wait before continuing with the execution. default: 100 minimum: 1
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected int
m_AttemptInterval
the interval in milli-seconds to wait.protected PlaceholderFile
m_Export
the file to serialize the unexecuted jobs to.protected PlaceholderFile
m_Import
the file to deserialize the finished jobs from.protected int
m_NumAttempts
the maximum number of interval to wait.-
Fields inherited from class adams.multiprocess.AbstractMetaJobRunner
m_ActualJobRunner, m_JobCompleteListeners, m_JobRunner, m_Jobs
-
Fields inherited from class adams.multiprocess.AbstractJobRunner
m_FlowContext, m_Paused, m_Running
-
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 SerializingJobRunner()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
attemptIntervalTipText()
Returns the tip text for this property.void
complete(Job j, JobResult jr)
Ignored.void
defineOptions()
Adds options to the internal list of options.protected String
doStart()
Serializes the jobs to the specified export file.protected String
doStop()
Waits for the import file to appear.protected String
doTerminate(boolean wait)
Has no influence on the actual execution of the jobs.String
exportTipText()
Returns the tip text for this property.int
getAttemptInterval()
Returns the interval to wait in milli-seconds.protected PlaceholderFile
getDefaultExport()
Returns the default export file.protected PlaceholderFile
getDefaultImport()
Returns the default import file.PlaceholderFile
getExport()
Returns the file to export the un-executed jobs to.PlaceholderFile
getImport()
Returns the file to import the executed jobs from.int
getNumAttempts()
Returns the maximum number of intervals to wait.String
getQuickInfo()
Returns a quick info about the object, which can be displayed in the GUI.String
globalInfo()
Returns a string describing the object.String
importTipText()
Returns the tip text for this property.String
numAttemptsTipText()
Returns the tip text for this property.void
setAttemptInterval(int value)
Sets the interval in milli-seconds to wait.void
setExport(PlaceholderFile value)
Sets the file to export the un-executed jobs to.void
setImport(PlaceholderFile value)
Sets the file to import the executed jobs from.void
setNumAttempts(int value)
Sets the maximum number of intervals to wait.-
Methods inherited from class adams.multiprocess.AbstractMetaJobRunner
add, add, addJobCompleteListener, cleanUp, clear, getDefaultJobRunner, getJobRunner, getJobs, getTransferJobCompleteListeners, initialize, jobRunnerTipText, newActualJobRunner, preStart, removeJobCompleteListener, setJobRunner
-
Methods inherited from class adams.multiprocess.AbstractJobRunner
getFlowContext, isPaused, isRunning, pauseExecution, postStart, postStop, postTerminate, preStop, preTerminate, resumeExecution, setFlowContext, start, stop, terminate, terminate
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, 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.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
-
-
-
Field Detail
-
m_Export
protected PlaceholderFile m_Export
the file to serialize the unexecuted jobs to.
-
m_Import
protected PlaceholderFile m_Import
the file to deserialize the finished jobs from.
-
m_NumAttempts
protected int m_NumAttempts
the maximum number of interval to wait.
-
m_AttemptInterval
protected int m_AttemptInterval
the interval in milli-seconds to wait.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractMetaJobRunner
-
getDefaultExport
protected PlaceholderFile getDefaultExport()
Returns the default export file.- Returns:
- the export file
-
setExport
public void setExport(PlaceholderFile value)
Sets the file to export the un-executed jobs to.- Parameters:
value
- the export file
-
getExport
public PlaceholderFile getExport()
Returns the file to export the un-executed jobs to.- Returns:
- the export file
-
exportTipText
public String exportTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getDefaultImport
protected PlaceholderFile getDefaultImport()
Returns the default import file.- Returns:
- the import file
-
setImport
public void setImport(PlaceholderFile value)
Sets the file to import the executed jobs from.- Parameters:
value
- the import file
-
getImport
public PlaceholderFile getImport()
Returns the file to import the executed jobs from.- Returns:
- the import file
-
importTipText
public String importTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setNumAttempts
public void setNumAttempts(int value)
Sets the maximum number of intervals to wait.- Specified by:
setNumAttempts
in interfaceMultiAttemptSupporter
- Parameters:
value
- the maximum
-
getNumAttempts
public int getNumAttempts()
Returns the maximum number of intervals to wait.- Specified by:
getNumAttempts
in interfaceMultiAttemptSupporter
- Returns:
- the maximum
-
numAttemptsTipText
public String numAttemptsTipText()
Returns the tip text for this property.- Specified by:
numAttemptsTipText
in interfaceMultiAttemptSupporter
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setAttemptInterval
public void setAttemptInterval(int value)
Sets the interval in milli-seconds to wait.- Specified by:
setAttemptInterval
in interfaceMultiAttemptWithWaitSupporter
- Parameters:
value
- the interval
-
getAttemptInterval
public int getAttemptInterval()
Returns the interval to wait in milli-seconds.- Specified by:
getAttemptInterval
in interfaceMultiAttemptWithWaitSupporter
- Returns:
- the interval
-
attemptIntervalTipText
public String attemptIntervalTipText()
Returns the tip text for this property.- Specified by:
attemptIntervalTipText
in interfaceMultiAttemptWithWaitSupporter
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the object, which can be displayed in the GUI.- Specified by:
getQuickInfo
in interfaceQuickInfoSupporter
- Overrides:
getQuickInfo
in classAbstractMetaJobRunner
- Returns:
- null if no info available, otherwise short string
-
doStart
protected String doStart()
Serializes the jobs to the specified export file.- Specified by:
doStart
in classAbstractJobRunner
- Returns:
- null if successful, otherwise error message
- See Also:
AbstractJobRunner.preStart()
-
doStop
protected String doStop()
Waits for the import file to appear.- Specified by:
doStop
in classAbstractJobRunner
- Returns:
- null if successful, otherwise error message
-
doTerminate
protected String doTerminate(boolean wait)
Has no influence on the actual execution of the jobs.- Specified by:
doTerminate
in classAbstractJobRunner
- Parameters:
wait
- whether to wait for the jobs to finish- Returns:
- always null
-
-