Package adams.multiprocess
Class AbstractJob
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.multiprocess.AbstractJob
-
- All Implemented Interfaces:
CleanUpHandler,LoggingLevelHandler,LoggingSupporter,SizeOfHandler,Stoppable,StoppableWithFeedback,Job,Serializable
- Direct Known Subclasses:
AbstractBaselineCorrection.BaselineCorrectionJob,AbstractDenoiser.DenoiserJob,AbstractExperiment.AbstractExperimentJob,AbstractFilter.FilterJob,AbstractGeneticAlgorithm.GeneticAlgorithmJob,AbstractOutlierDetector.DetectorJob,AbstractSmoother.SmootherJob,ArrayProcess.ArrayElementJob,GeneticAlgorithm.GAJob,LaunchTee.LaunchJob,LaunchTrigger.LaunchJob,SpreadSheetFilter.FilterJob,WekaClassifierRanker.RankingJob,WekaCrossValidationJob,WekaFilter.BatchFilterJob,WekaTestSetEvaluator.EvaluateJob,WekaTrainAssociator.TrainJob,WekaTrainClassifier.BatchTrainJob,WekaTrainClusterer.BatchTrainJob,WekaTrainTestSetEvaluator.EvaluateJob
public abstract class AbstractJob extends CustomLoggingLevelObject implements Job
A job is a unit of execution.- Author:
- dale
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanm_CompleteHas this job completed processing?protected Stringm_ExecutionErrorwhether an error occurred in the execution.protected JobCompleteListenerm_JobCompleteListenerObject to call once job has been completed.protected Stringm_JobInfoidentifying name of job.protected Stringm_ProgressInfooptional progress info (output before/after execute).protected booleanm_Stoppedwhether the job has been stopped.-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractJob()Job constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcleanUp()Cleans up data structures, frees up memory.JobResultexecute()Override to do computation.protected StringgetAdditionalErrorInformation()Returns additional information to be added to the error message.StringgetExecutionError()Returns the execution error, if any.JobCompleteListenergetJobCompleteListener()Returns the listener that gets notified when the job got finished.StringgetJobInfo()Returns the job info/identifier.StringgetProgressInfo()Returns the progress info (if any) to output before/after the job execution.booleanhasExecutionError()Checks whether there was a problem with the job execution.booleanisComplete()Whether the job has been finished.booleanisStopped()Whether the execution has been stopped.voidjobCompleted(Job j, JobResult jr)Called once a job has completed execution.protected abstract StringpostProcessCheck()Checks whether all post-conditions have been met.protected abstract StringpreProcessCheck()Checks whether all pre-conditions have been met.protected abstract voidprocess()Does the actual execution of the job.voidsetJobCompleteListener(JobCompleteListener l)Sets the listener that gets notified when the job got finished.voidsetJobInfo(String value)Sets the job info/identifier.voidsetProgressInfo(String value)Sets the progress info to output before/after the job execution.voidstopExecution()Stops the execution.abstract StringtoString()Returns a string representation of this job.-
Methods inherited from class adams.core.logging.CustomLoggingLevelObject
setLoggingLevel
-
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.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.logging.LoggingSupporter
getLogger, isLoggingEnabled
-
-
-
-
Field Detail
-
m_JobInfo
protected String m_JobInfo
identifying name of job.
-
m_Complete
protected boolean m_Complete
Has this job completed processing?
-
m_JobCompleteListener
protected JobCompleteListener m_JobCompleteListener
Object to call once job has been completed.
-
m_ExecutionError
protected String m_ExecutionError
whether an error occurred in the execution.
-
m_Stopped
protected boolean m_Stopped
whether the job has been stopped.
-
m_ProgressInfo
protected String m_ProgressInfo
optional progress info (output before/after execute).
-
-
Method Detail
-
setJobInfo
public void setJobInfo(String value)
Sets the job info/identifier.- Parameters:
value- the info
-
getJobInfo
public String getJobInfo()
Returns the job info/identifier.- Specified by:
getJobInfoin interfaceJob- Returns:
- the info
-
jobCompleted
public void jobCompleted(Job j, JobResult jr)
Called once a job has completed execution.- Specified by:
jobCompletedin interfaceJob- Parameters:
j- Jobjr- Result of Job
-
setJobCompleteListener
public void setJobCompleteListener(JobCompleteListener l)
Sets the listener that gets notified when the job got finished.- Specified by:
setJobCompleteListenerin interfaceJob- Parameters:
l- the listener
-
getJobCompleteListener
public JobCompleteListener getJobCompleteListener()
Returns the listener that gets notified when the job got finished.- Specified by:
getJobCompleteListenerin interfaceJob- Returns:
- the listener, can be null
-
isComplete
public boolean isComplete()
Whether the job has been finished.- Specified by:
isCompletein interfaceJob- Returns:
- true if the job has finished, false otherwise
-
setProgressInfo
public void setProgressInfo(String value)
Sets the progress info to output before/after the job execution.- Parameters:
value- the info, null to suppress
-
getProgressInfo
public String getProgressInfo()
Returns the progress info (if any) to output before/after the job execution.- Returns:
- the info, null if none set
-
preProcessCheck
protected abstract String preProcessCheck()
Checks whether all pre-conditions have been met.- Returns:
- null if everything is OK, otherwise an error message
-
process
protected abstract void process() throws ExceptionDoes the actual execution of the job.- Throws:
Exception- if fails to execute job
-
postProcessCheck
protected abstract String postProcessCheck()
Checks whether all post-conditions have been met.- Returns:
- null if everything is OK, otherwise an error message
-
getAdditionalErrorInformation
protected String getAdditionalErrorInformation()
Returns additional information to be added to the error message. Default returns an empty string.- Returns:
- the additional information
-
execute
public JobResult execute()
Override to do computation.
-
hasExecutionError
public boolean hasExecutionError()
Checks whether there was a problem with the job execution.- Specified by:
hasExecutionErrorin interfaceJob- Returns:
- true if an error occurred
-
getExecutionError
public String getExecutionError()
Returns the execution error, if any.- Specified by:
getExecutionErrorin interfaceJob- Returns:
- the error, null if none occurred
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory. Removes dependencies and job parameters.- Specified by:
cleanUpin interfaceCleanUpHandler- Specified by:
cleanUpin interfaceJob
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecutionin interfaceStoppable
-
isStopped
public boolean isStopped()
Whether the execution has been stopped.- Specified by:
isStoppedin interfaceStoppableWithFeedback- Returns:
- true if stopped
-
-