Class ProcessingUnitProxy
- java.lang.Object
-
- com.github.toolarium.processing.unit.runtime.runnable.ProcessingUnitProxy
-
- All Implemented Interfaces:
IProcessingUnitProxy
public final class ProcessingUnitProxy extends java.lang.Object implements IProcessingUnitProxy
Implements theIProcessingUnitProxy.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetDuration()Get the duration in millisecondsjava.lang.StringgetId()Get the runnable idjava.lang.LonggetMaxNumberOfProcessingUnitCallsPerSecond()Get the max number of processing unit calls per secondsjava.lang.StringgetName()Get the runnable name or nulljava.util.List<ParameterDefinition>getParameterDefinition()Gets the parameter definition list of the processing.java.util.List<Parameter>getParameterList()Get the processing parameter list.ProcessingRuntimeStatusgetProcessingRuntimeStatus()Get the processing runtime statusIProcessingUnitgetProcessingUnit()Get the processing unit.java.lang.Class<? extends IProcessingUnit>getProcessingUnitClass()Get the processing unit class.IProcessingUnitContextgetProcessingUnitContext()Get the processing unit contextIProcessStatusgetProcessStatus()Gets the last process statusjava.time.InstantgetStartTimestamp()Get the start time stampjava.util.List<java.lang.String>getStatusMessageList()Get the status message liststatic ProcessingUnitProxyinit(java.lang.String id, java.lang.String name, java.lang.Class<? extends IProcessingUnit> processingUnitClass, java.util.List<Parameter> parameterList, IProcessingUnitContext processingUnitContext)Initialize aIProcessingUnit: Initialize the processing unit class Validate the input parameters against the parameter definition Calls on theIProcessingUnitinstance initialize methodbooleanprocessUnit()Process unit: This method will be called until theIProcessStatus.hasNext()returns false or an exception occurs: RuntimeException will abort; ValidationException or ProcessingException depends on the value returned by the method abortProcessing.voidreleaseResource()Release resources will be called to release all internal referenced resources after a processing success, error or by asuspendProcessing(see method below).static ProcessingUnitProxyresume(byte[] persisted)Resume aIProcessingUnit: Initialize the processing unit class Validate the input parameters against the parameter definition Calls on theIProcessingUnitinstance resumeProcessing methodvoidsetMaxNumberOfProcessingUnitCallsPerSecond(java.lang.Long maxNumberOfProcessingUnitCallsPerSecond)Set the max number of processing unit calls per secondsbyte[]suspendProcessing()Suspends the processing: The processing is able to persist its state with the help of theIProcessingPersistenceobject.java.lang.StringtoString()
-
-
-
Method Detail
-
init
public static ProcessingUnitProxy init(java.lang.String id, java.lang.String name, java.lang.Class<? extends IProcessingUnit> processingUnitClass, java.util.List<Parameter> parameterList, IProcessingUnitContext processingUnitContext) throws ValidationException, ProcessingException
Initialize aIProcessingUnit:- Initialize the processing unit class
- Validate the input parameters against the parameter definition
- Calls on the
IProcessingUnitinstance initialize method- Parameters:
id- the unique id of the processingname- the name of the processingprocessingUnitClass- the processing unit classparameterList- the parameter listprocessingUnitContext- the processing unit context- Returns:
- the
IProcessingUnitProxy - Throws:
ValidationException- This will be throw in case the consistency check failures.ProcessingException- Throws this exception in case of initialization failures.
-
resume
public static ProcessingUnitProxy resume(byte[] persisted) throws ValidationException, ProcessingException
Resume aIProcessingUnit:- Initialize the processing unit class
- Validate the input parameters against the parameter definition
- Calls on the
IProcessingUnitinstance resumeProcessing method- Parameters:
persisted- the persisted processing unit to resume- Returns:
- the
IProcessingUnitProxy - Throws:
ValidationException- This will be throw in case the consistency check failures.ProcessingException- Throws this exception in case of initialization failures.
-
getId
public java.lang.String getId()
Description copied from interface:IProcessingUnitProxyGet the runnable id- Specified by:
getIdin interfaceIProcessingUnitProxy- Returns:
- the runnable id
- See Also:
IProcessingUnitProxy.getId()
-
getName
public java.lang.String getName()
Description copied from interface:IProcessingUnitProxyGet the runnable name or null- Specified by:
getNamein interfaceIProcessingUnitProxy- Returns:
- the name or null
- See Also:
IProcessingUnitProxy.getName()
-
getParameterDefinition
public java.util.List<ParameterDefinition> getParameterDefinition()
Description copied from interface:IProcessingUnitProxyGets the parameter definition list of the processing.- Specified by:
getParameterDefinitionin interfaceIProcessingUnitProxy- Returns:
- the parameter definition list or null in case of no parameters
- See Also:
IProcessingUnitProxy.getParameterDefinition()
-
processUnit
public boolean processUnit()
Description copied from interface:IProcessingUnitProxyProcess unit: This method will be called until theIProcessStatus.hasNext()returns false or an exception occurs: RuntimeException will abort; ValidationException or ProcessingException depends on the value returned by the method abortProcessing. Important: this method have to process the sequential or in a small block size.- Specified by:
processUnitin interfaceIProcessingUnitProxy- Returns:
- true to continue the processing; otherwise false
- See Also:
IProcessingUnitProxy.processUnit()
-
suspendProcessing
public byte[] suspendProcessing() throws ProcessingExceptionDescription copied from interface:IProcessingUnitProxySuspends the processing: The processing is able to persist its state with the help of theIProcessingPersistenceobject. On a resume this instance of theIProcessingPersistencewill be returned (see method below).- Specified by:
suspendProcessingin interfaceIProcessingUnitProxy- 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:
IProcessingUnitProxy.suspendProcessing()
-
releaseResource
public void releaseResource() throws ProcessingExceptionDescription copied from interface:IProcessingUnitProxyRelease 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 interfaceIProcessingUnitProxy- Throws:
ProcessingException- Throws this exception in case of releasing failure.- See Also:
IProcessingUnitProxy.releaseResource()
-
getProcessStatus
public IProcessStatus getProcessStatus()
Description copied from interface:IProcessingUnitProxyGets the last process status- Specified by:
getProcessStatusin interfaceIProcessingUnitProxy- Returns:
- the last process status
- See Also:
IProcessingUnitProxy.getProcessStatus()
-
getProcessingRuntimeStatus
public ProcessingRuntimeStatus getProcessingRuntimeStatus()
Get the processing runtime status- Returns:
- the processing runtime status
-
getStatusMessageList
public java.util.List<java.lang.String> getStatusMessageList()
Get the status message list- Returns:
- the status message list
-
getStartTimestamp
public java.time.Instant getStartTimestamp()
Get the start time stamp- Returns:
- the start time stamp
-
getDuration
public long getDuration()
Get the duration in milliseconds- Returns:
- the duration in milliseconds
-
getMaxNumberOfProcessingUnitCallsPerSecond
public java.lang.Long getMaxNumberOfProcessingUnitCallsPerSecond()
Description copied from interface:IProcessingUnitProxyGet the max number of processing unit calls per seconds- Specified by:
getMaxNumberOfProcessingUnitCallsPerSecondin interfaceIProcessingUnitProxy- Returns:
- The max number of processing unit calls per seconds
- See Also:
IProcessingUnitProxy.getMaxNumberOfProcessingUnitCallsPerSecond()
-
setMaxNumberOfProcessingUnitCallsPerSecond
public void setMaxNumberOfProcessingUnitCallsPerSecond(java.lang.Long maxNumberOfProcessingUnitCallsPerSecond)
Set the max number of processing unit calls per seconds- Parameters:
maxNumberOfProcessingUnitCallsPerSecond- The max number of processing unit calls per seconds
-
getProcessingUnitClass
public java.lang.Class<? extends IProcessingUnit> getProcessingUnitClass()
Get the processing unit class.- Returns:
- the processing unit class
- Throws:
ProcessingException- Throws this exception in case of initialization failures.
-
getProcessingUnit
public IProcessingUnit getProcessingUnit()
Get the processing unit.- Returns:
- the processing unit
- Throws:
ProcessingException- Throws this exception in case of initialization failures.
-
getParameterList
public java.util.List<Parameter> getParameterList()
Get the processing parameter list.- Returns:
- the processing parameter list
-
getProcessingUnitContext
public IProcessingUnitContext getProcessingUnitContext()
Get the processing unit context- Returns:
- the processing unit context
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- See Also:
Object.toString()
-
-