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 longestimateNumberOfUnitsToProcess()Estimate the number of units to process.com.github.toolarium.common.object.IObjectLockManagergetObjectLockManager()Gets the object lock managerjava.util.List<ParameterDefinition>getParameterDefinition()Gets the parameter definition list of the processing.protected IParameterRuntimegetParameterRuntime()Get the parameter runtime information.protected IProcessingUnitContextgetProcessingUnitContext()Get the process contextprotected IProcessingUnitUpdateProgressgetProcessingUnitProgress()Get the processing unit progressvoidinitialize(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.voidonAborting()This method is called in case of an abort (status aborting) before the resources are released.voidonEnding()This method is called on ending after a successful end (status ending) before the resources are released.IProcessingUnitStatusprocessUnit()Process unit: This method will be called until theIProcessingUnitStatus.hasNext()returns false.abstract IProcessingUnitStatusprocessUnit(ProcessingUnitStatusBuilder processingUnitStatusBuilder)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(IProcessingUnitProgress processingUnitProgress, IProcessingUnitPersistence processingPersistence)After suspending a processing unit can be resumed.voidsetObjectLockManager(com.github.toolarium.common.object.IObjectLockManager objectLockManager)Sets the object lock managerIProcessingUnitPersistencesuspendProcessing()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. It is also used when processing is interrupted and resumed.- 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)
-
estimateNumberOfUnitsToProcess
public long estimateNumberOfUnitsToProcess() throws ProcessingExceptionDescription copied from interface:IProcessingUnitEstimate the number of units to process. It will be called once afterIProcessingUnit.initialize(List, IProcessingUnitContext). It set the the number of units to process in the objectIProcessingUnitProgress. In case there are more elements to process than estimated, the progress will adapted. In case of aIProcessingUnit.resumeProcessing(IProcessingUnitProgress, IProcessingUnitPersistence)it will not be called again.- Specified by:
estimateNumberOfUnitsToProcessin interfaceIProcessingUnit- Returns:
- returns the number of units to process
- Throws:
ProcessingException- Throws this exception in case of initialization failures.- See Also:
IProcessingUnit.estimateNumberOfUnitsToProcess()
-
processUnit
public IProcessingUnitStatus processUnit() 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- Returns:
- the process unit status
- Throws:
ProcessingException- In case of any failures occurs.- See Also:
IProcessingUnit.processUnit()
-
processUnit
public abstract IProcessingUnitStatus processUnit(ProcessingUnitStatusBuilder processingUnitStatusBuilder) throws ProcessingException
Process 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.- Parameters:
processingUnitStatusBuilder- the processing unit status builder- Returns:
- the process unit status
- Throws:
ProcessingException- In case of any failures occurs.
-
onEnding
public void onEnding()
Description copied from interface:IProcessingUnitThis method is called on ending after a successful end (status ending) before the resources are released.- Specified by:
onEndingin interfaceIProcessingUnit- See Also:
IProcessingUnit.onEnding()
-
onAborting
public void onAborting()
Description copied from interface:IProcessingUnitThis method is called in case of an abort (status aborting) before the resources are released.- Specified by:
onAbortingin interfaceIProcessingUnit- See Also:
IProcessingUnit.onAborting()
-
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 afterIProcessingUnit.onEnding()orIProcessingUnit.onAborting().- 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). TheIProcessingUnitPersistencedon't need to contain any parameters or additional statuses. They are covered by the framework.- 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(IProcessingUnitProgress processingUnitProgress, IProcessingUnitPersistence processingPersistence) 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. The main purpose of this call is to set the processing persistence.- Specified by:
resumeProcessingin interfaceIProcessingUnit- Parameters:
processingUnitProgress- the processing unit progress of the processing unit before suspending.processingPersistence- the processing persistence to resume after suspending.- Throws:
ProcessingException- Throws this exception in case of while resume the processing any failures occurs.- See Also:
IProcessingUnit.resumeProcessing(com.github.toolarium.processing.unit.IProcessingUnitProgress, com.github.toolarium.processing.unit.IProcessingUnitPersistence)
-
getObjectLockManager
public com.github.toolarium.common.object.IObjectLockManager getObjectLockManager()
Gets the object lock manager- Returns:
- the object lock manager
-
setObjectLockManager
public void setObjectLockManager(com.github.toolarium.common.object.IObjectLockManager objectLockManager)
Sets the object lock manager- Parameters:
objectLockManager- the object lock manager
-
getParameterRuntime
protected IParameterRuntime getParameterRuntime()
Get the parameter runtime information.- Returns:
- the parameter runtime information.
-
getProcessingUnitContext
protected IProcessingUnitContext getProcessingUnitContext()
Get the process context- Returns:
- the process context
-
getProcessingUnitProgress
protected IProcessingUnitUpdateProgress getProcessingUnitProgress()
Get the processing unit progress- Returns:
- the processing unit progress
-
-