Class AbstractProcessingUnitImpl
- java.lang.Object
-
- com.github.toolarium.processing.unit.base.AbstractProcessingUnitImpl
-
- All Implemented Interfaces:
IProcessingUnit
- Direct Known Subclasses:
AbstractProcessingUnitPersistenceImpl
public abstract class AbstractProcessingUnitImpl extends java.lang.Object implements IProcessingUnit
Abstract base implementation of theIProcessingUnit.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractProcessingUnitImpl()Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract longestimateNumberOfUnitsToProcess(IProcessingUnitContext processingUnitContext)Estimate the number of units to process.java.util.List<ParameterDefinition>getParameterDefinition()Gets the parameter definition list of the processing.protected IParameterRuntimegetParameterRuntime()Get the parameter runtime information.voidinitialize(java.util.List<Parameter> parameterList, IProcessingUnitContext processingUnitContext)Initializes the processing unit.protected voidinitializeParameterDefinition()Initialize the parameter definition: This method is used to register the parameter definition of this processing unit.voidonStop()This method will be called in case on a stop before.voidonSuccess()This method will be called after a success end.abstract IProcessingUnitStatusprocessUnit(IProcessingUnitProgress processingProgress, IProcessingUnitContext processingUnitContext)Process unit: This method will be called until theIProcessingUnitStatus.hasNext()returns false.voidreleaseResource()Release resources will be called to release all internal referenced resources after a processing success, error or by asuspendProcessing(see method below).voidresumeProcessing(IProcessingUnitPersistence processingPersistence, IProcessingUnitContext processingUnitContext)After suspending a processing unit can be resumed.IProcessingUnitPersistencesuspendProcessing()Suspends the processing: The processing is able to persist its state with the help of theIProcessingUnitPersistenceobject.voidvalidateParameterList(java.util.List<Parameter> parameterList)Validate the parameter list consistency of this class with the parameters.
-
-
-
Method Detail
-
initializeParameterDefinition
protected void initializeParameterDefinition()
Initialize the parameter definition: This method is used to register the parameter definition of this processing unit. The methodaddParameterDefinitioncan be used for convenience.In case of inheritance the
super.initializeParameterDefinition()must be called before or after the
-
getParameterDefinition
public java.util.List<ParameterDefinition> getParameterDefinition()
Description copied from interface:IProcessingUnitGets the parameter definition list of the processing.- Specified by:
getParameterDefinitionin interfaceIProcessingUnit- Returns:
- the parameter definition list or null in case of no parameters
- See Also:
IProcessingUnit.getParameterDefinition()
-
validateParameterList
public void validateParameterList(java.util.List<Parameter> parameterList) throws ValidationException
Description copied from interface:IProcessingUnitValidate the parameter list consistency of this class with the parameters. Typical it will be called during the initialization. It can be used to verify if the parameter of this processing are well defined.- Specified by:
validateParameterListin interfaceIProcessingUnit- Parameters:
parameterList- the parameter list.- Throws:
ValidationException- This will be throw in case the consistency check failures.- See Also:
IProcessingUnit.validateParameterList(java.util.List)
-
initialize
public void initialize(java.util.List<Parameter> parameterList, IProcessingUnitContext processingUnitContext) throws ValidationException, ProcessingException
Description copied from interface:IProcessingUnitInitializes the processing unit. This will called as first to initialize the processing unit.- Specified by:
initializein interfaceIProcessingUnit- Parameters:
parameterList- the parameter list to run the processing.processingUnitContext- the processing context.- Throws:
ValidationException- This will be throw in case the consistency check failures.ProcessingException- Throws this exception in case of initialization failures.- See Also:
IProcessingUnit.initialize(java.util.List, com.github.toolarium.processing.unit.IProcessingUnitContext)
-
processUnit
public abstract IProcessingUnitStatus processUnit(IProcessingUnitProgress processingProgress, IProcessingUnitContext processingUnitContext) throws ProcessingException
Description copied from interface:IProcessingUnitProcess unit: This method will be called until theIProcessingUnitStatus.hasNext()returns false. Important: this method have to process the sequential or in a small block size.- Specified by:
processUnitin interfaceIProcessingUnit- Parameters:
processingProgress- the processing progressprocessingUnitContext- the processing unit context.- Returns:
- the process status
- Throws:
ProcessingException- In case of any failures occurs.- See Also:
IProcessingUnit.processUnit(com.github.toolarium.processing.unit.IProcessingUnitProgress, com.github.toolarium.processing.unit.IProcessingUnitContext)
-
onSuccess
public void onSuccess()
Description copied from interface:IProcessingUnitThis method will be called after a success end.- Specified by:
onSuccessin interfaceIProcessingUnit- See Also:
IProcessingUnit.onSuccess()
-
onStop
public void onStop()
Description copied from interface:IProcessingUnitThis method will be called in case on a stop before.- Specified by:
onStopin interfaceIProcessingUnit- See Also:
IProcessingUnit.onStop()
-
releaseResource
public void releaseResource() throws ProcessingExceptionDescription copied from interface:IProcessingUnitRelease resources will be called to release all internal referenced resources after a processing success, error or by asuspendProcessing(see method below). It will be called afteronSuccessoronStop.- Specified by:
releaseResourcein interfaceIProcessingUnit- Throws:
ProcessingException- Throws this exception in case of releasing failure.- See Also:
IProcessingUnit.releaseResource()
-
suspendProcessing
public IProcessingUnitPersistence suspendProcessing() throws ProcessingException
Description copied from interface:IProcessingUnitSuspends the processing: The processing is able to persist its state with the help of theIProcessingUnitPersistenceobject. On a resume this instance of theIProcessingUnitPersistencewill be returned (see method below).- Specified by:
suspendProcessingin interfaceIProcessingUnit- Returns:
- the processing persistence which contains all information to resume processing later (see resumeProcessing).
- Throws:
ProcessingException- Throws this exception in case of while suspend the processing any failures occurs.- See Also:
IProcessingUnit.suspendProcessing()
-
resumeProcessing
public void resumeProcessing(IProcessingUnitPersistence processingPersistence, IProcessingUnitContext processingUnitContext) throws ProcessingException
Description copied from interface:IProcessingUnitAfter suspending a processing unit can be resumed. The parameter list of the initialization is passed as well theIProcessingUnitPersistencewhich was returned by the suspendProcessing method.- Specified by:
resumeProcessingin interfaceIProcessingUnit- Parameters:
processingPersistence- the processing persistence to resume after suspending.processingUnitContext- the processing unit context- Throws:
ProcessingException- Throws this exception in case of while resume the processing any failures occurs.- See Also:
IProcessingUnit.resumeProcessing(com.github.toolarium.processing.unit.IProcessingUnitPersistence, com.github.toolarium.processing.unit.IProcessingUnitContext)
-
estimateNumberOfUnitsToProcess
public abstract long estimateNumberOfUnitsToProcess(IProcessingUnitContext processingUnitContext) throws ProcessingException
Estimate the number of units to process. It will be called once in the process of initialization.- Specified by:
estimateNumberOfUnitsToProcessin interfaceIProcessingUnit- Parameters:
processingUnitContext- the processing context.- Returns:
- returns the number of units to process
- Throws:
ProcessingException- Throws this exception in case of initialization failures.
-
getParameterRuntime
protected IParameterRuntime getParameterRuntime()
Get the parameter runtime information.- Returns:
- the parameter runtime information.
-
-