Package adams.multiprocess
Class AbstractJob
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.multiprocess.AbstractJob
-
- All Implemented Interfaces:
CleanUpHandler
,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
,SpreadSheetFilter.FilterJob
,WekaClassifierRanker.RankingJob
,WekaCrossValidationJob
,WekaFilter.BatchFilterJob
,WekaTestSetEvaluator.EvaluateJob
,WekaTrainAssociator.TrainJob
,WekaTrainClassifier.BatchTrainJob
,WekaTrainClusterer.BatchTrainJob
,WekaTrainTestSetEvaluator.EvaluateJob
public abstract class AbstractJob extends LoggingObject implements Job
A job is a unit of execution.- Version:
- $Revision$
- Author:
- dale
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_Complete
Has this job completed processing?protected String
m_ExecutionError
whether an error occurred in the execution.protected JobCompleteListener
m_JobCompleteListener
Object to call once job has been completed.protected String
m_JobInfo
identifying name of job.protected boolean
m_Stopped
whether 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 void
cleanUp()
Cleans up data structures, frees up memory.JobResult
execute()
Override to do computation.protected String
getAdditionalErrorInformation()
Returns additional information to be added to the error message.String
getExecutionError()
Returns the execution error, if any.JobCompleteListener
getJobCompleteListener()
Returns the listener that gets notified when the job got finished.String
getJobInfo()
Returns the job info/identifier.boolean
hasExecutionError()
Checks whether there was a problem with the job execution.boolean
isComplete()
Whether the job has been finished.boolean
isStopped()
Whether the execution has been stopped.void
jobCompleted(Job j, JobResult jr)
Called once a job has completed execution.protected abstract String
postProcessCheck()
Checks whether all post-conditions have been met.protected abstract String
preProcessCheck()
Checks whether all pre-conditions have been met.protected abstract void
process()
Does the actual execution of the job.void
setJobCompleteListener(JobCompleteListener l)
Sets the listener that gets notified when the job got finished.void
setJobInfo(String value)
Sets the job info/identifier.void
stopExecution()
Stops the execution.abstract String
toString()
Returns a string representation of this job.-
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.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.
-
-
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:
getJobInfo
in interfaceJob
- Returns:
- the info
-
jobCompleted
public void jobCompleted(Job j, JobResult jr)
Called once a job has completed execution.- Specified by:
jobCompleted
in 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:
setJobCompleteListener
in interfaceJob
- Parameters:
l
- the listener
-
getJobCompleteListener
public JobCompleteListener getJobCompleteListener()
Returns the listener that gets notified when the job got finished.- Specified by:
getJobCompleteListener
in interfaceJob
- Returns:
- the listener, can be null
-
isComplete
public boolean isComplete()
Whether the job has been finished.- Specified by:
isComplete
in interfaceJob
- Returns:
- true if the job has finished, false otherwise
-
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 Exception
Does 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:
hasExecutionError
in interfaceJob
- Returns:
- true if an error occurred
-
getExecutionError
public String getExecutionError()
Returns the execution error, if any.- Specified by:
getExecutionError
in 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:
cleanUp
in interfaceCleanUpHandler
- Specified by:
cleanUp
in interfaceJob
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecution
in interfaceStoppable
-
isStopped
public boolean isStopped()
Whether the execution has been stopped.- Specified by:
isStopped
in interfaceStoppableWithFeedback
- Returns:
- true if stopped
-
-