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 millisecondsIEmptyProcessingUnitHandlergetEmptyProcessingUnitHandler()Get the empty processing unit handlerjava.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 contextIProcessingUnitProgressgetProcessingUnitProgress()Gets the processing unit progressjava.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 methodvoidonAborting()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.booleanprocessUnit()Process unit: This method will be called until theIProcessingUnitStatus.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 methodvoidsetEmptyProcessingUnitHandler(IEmptyProcessingUnitHandler emptyProcessingUnitHandler)Set the empty processing unit handlerbooleansetMaxNumberOfProcessingUnitCallsPerSecond(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 theIProcessingUnitPersistenceobject.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()
-
getEmptyProcessingUnitHandler
public IEmptyProcessingUnitHandler getEmptyProcessingUnitHandler()
Get the empty processing unit handler- Returns:
- the empty processing unit handler
-
setEmptyProcessingUnitHandler
public void setEmptyProcessingUnitHandler(IEmptyProcessingUnitHandler emptyProcessingUnitHandler)
Set the empty processing unit handler- Parameters:
emptyProcessingUnitHandler- the empty processing unit handler
-
processUnit
public boolean processUnit()
Description copied from interface:IProcessingUnitProxyProcess unit: This method will be called until theIProcessingUnitStatus.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()
-
onEnding
public void onEnding()
Description copied from interface:IProcessingUnitProxyThis method is called on ending after a successful end (status ending) before the resources are released.- Specified by:
onEndingin interfaceIProcessingUnitProxy- See Also:
IProcessingUnitProxy.onEnding()
-
onAborting
public void onAborting()
Description copied from interface:IProcessingUnitProxyThis method is called in case of an abort (status aborting) before the resources are released.- Specified by:
onAbortingin interfaceIProcessingUnitProxy- See Also:
IProcessingUnitProxy.onAborting()
-
suspendProcessing
public byte[] suspendProcessing() throws ProcessingExceptionDescription copied from interface:IProcessingUnitProxySuspends 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 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 afterIProcessingUnitProxy.onEnding()orIProcessingUnitProxy.onAborting().- Specified by:
releaseResourcein interfaceIProcessingUnitProxy- Throws:
ProcessingException- Throws this exception in case of releasing failure.- See Also:
IProcessingUnitProxy.releaseResource()
-
getProcessingUnitProgress
public IProcessingUnitProgress getProcessingUnitProgress()
Description copied from interface:IProcessingUnitProxyGets the processing unit progress- Specified by:
getProcessingUnitProgressin interfaceIProcessingUnitProxy- Returns:
- the processing unit progress
- See Also:
IProcessingUnitProxy.getProcessingUnitProgress()
-
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 boolean 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- Returns:
- true if the underlining
IProcessingUnitimplements it own throttling mechanism; otherwise false
-
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()
-
-