Class TestProcessingUnitRunner<T extends IProcessingUnit>

  • All Implemented Interfaces:
    java.io.Serializable

    public class TestProcessingUnitRunner<T extends IProcessingUnit>
    extends java.lang.Object
    implements java.io.Serializable
    Implements a simple processing unit runner. It's made to use in unit tests.
    See Also:
    Serialized Form
    • Constructor Detail

      • TestProcessingUnitRunner

        protected TestProcessingUnitRunner()
        Constructor
    • Method Detail

      • runAndAbort

        public long runAndAbort​(java.lang.Class<? extends IProcessingUnit> processingUnitClass,
                                java.util.List<Parameter> parameterList,
                                java.lang.Integer numberOfCyclesBeforeStop)
                         throws ValidationException,
                                ProcessingException
        Run processing unit and abort after some cycles
        Parameters:
        processingUnitClass - the processing unit class
        parameterList - the parameter list
        numberOfCyclesBeforeStop - the number of cycles before stop
        Returns:
        the number of cycles
        Throws:
        ValidationException - In case the processing can not be initilized
        ProcessingException - In case of an error in a processing
      • runWithThrottling

        public long runWithThrottling​(java.lang.Class<? extends IProcessingUnit> processingUnitClass,
                                      java.util.List<Parameter> parameterList,
                                      java.lang.Long maxNumberOfProcessingUnitCallsPerSecond)
                               throws ValidationException,
                                      ProcessingException
        Run processing unit and abort after some cycles
        Parameters:
        processingUnitClass - the processing unit class
        parameterList - the parameter list
        maxNumberOfProcessingUnitCallsPerSecond - the max number of calls per second of the processing unit
        Returns:
        the number of cycles
        Throws:
        ValidationException - In case the processing can not be initilized
        ProcessingException - In case of an error in a processing
      • runWithSuspendAndResume

        public long runWithSuspendAndResume​(java.lang.Class<? extends IProcessingUnit> processingUnitClass,
                                            java.util.List<Parameter> parameterList,
                                            long suspendAfterCycles,
                                            long suspendSleepTime,
                                            int maxNumberOfSuspends)
                                     throws ValidationException,
                                            ProcessingException
        Run processing unit
        Parameters:
        processingUnitClass - the processing unit class
        parameterList - the parameter list
        suspendAfterCycles - after the number of cycles it will suspended
        suspendSleepTime - the sleep time after suspending or null
        maxNumberOfSuspends - the max number of suspends
        Returns:
        the number of cycles
        Throws:
        ValidationException - In case the processing can not be initilized
        ProcessingException - In case of an error in a processing
      • runWithSuspendAndResume

        public long runWithSuspendAndResume​(java.lang.Class<? extends IProcessingUnit> processingUnitClass,
                                            java.util.List<Parameter> parameterList,
                                            long suspendAfterCycles,
                                            long suspendSleepTime,
                                            int maxNumberOfSuspends,
                                            java.lang.Long maxNumberOfProcessingUnitCallsPerSecond)
                                     throws ValidationException,
                                            ProcessingException
        Run processing unit
        Parameters:
        processingUnitClass - the processing unit class
        parameterList - the parameter list
        suspendAfterCycles - after the number of cycles it will suspended
        suspendSleepTime - the sleep time after suspending or null
        maxNumberOfSuspends - the max number of suspends
        maxNumberOfProcessingUnitCallsPerSecond - the max number of calls per second of the processing unit
        Returns:
        the number of cycles
        Throws:
        ValidationException - In case the processing can not be initilized
        ProcessingException - In case of an error in a processing
      • getSuspendCounter

        public int getSuspendCounter()
        Gets the suspend counter
        Returns:
        the suspend counter
      • getId

        public java.lang.String getId()
        Get the runnable id
        Returns:
        the runnable id
      • getName

        public java.lang.String getName()
        Get the runnable name or null
        Returns:
        the name or null
      • getProcessingActionStatus

        public ProcessingActionStatus getProcessingActionStatus()
        Get the processing action status
        Returns:
        the processing action status
      • getProcessStatus

        public IProcessStatus getProcessStatus()
        Gets the last process status
        Returns:
        the last process status
      • 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
      • getStopTimestamp

        public java.time.Instant getStopTimestamp()
        Get the stop time stamp
        Returns:
        the stop time stamp
      • getDuration

        public long getDuration()
        Get the duration in milliseconds
        Returns:
        the duration
      • getProcesingUnit

        public T getProcesingUnit()
        Get the processing unit. IMPORTANT: Only to verify some results
        Returns:
        the processing unit
      • getParameterList

        public java.util.List<Parameter> getParameterList()
        Get the processing parameter list.
        Returns:
        the processing parameter list
      • getProcessingUnitThrottling

        public com.github.toolarium.common.bandwidth.IBandwidthThrottling getProcessingUnitThrottling()
        Get the processing unit throttling
        Returns:
        the processing unit throttling
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()