Class BatchTaskProgressReporter

  • All Implemented Interfaces:
    AutoCloseable

    public class BatchTaskProgressReporter
    extends Object
    implements AutoCloseable
    Report progress on batch tasks.
    Author:
    poirigui
    • Constructor Detail

    • Method Detail

      • setReportFrequencyMillis

        public void setReportFrequencyMillis​(int reportFrequencyMillis)
        Set the frequency at which to report progress in milliseconds.

        Repeated calls to reportProgress() will be ignored until at least this amount of time has passed.

        The default is to report task progress every 30 seconds.

      • hasErrorObjects

        public boolean hasErrorObjects()
        Indicate if error objects have been reported.
      • getCompletedTasks

        public int getCompletedTasks()
        Obtain the number of completed tasks (either with a success or failure result).
      • setEstimatedMaxTasks

        public void setEstimatedMaxTasks​(int estimatedMaxTasks)
        Set the maximum number of tasks that are expected to be run.
      • addSuccessObject

        public void addSuccessObject​(Serializable successObject,
                                     String message)
        Add a success object to indicate success in a batch processing.
        Parameters:
        successObject - object that was processed
        message - success message
      • addErrorObject

        public void addErrorObject​(@Nullable
                                   Serializable errorObject,
                                   String message,
                                   Throwable throwable)
        Add an error object with a stacktrace to indicate failure in a batch processing.

        This is intended to be used when an Exception is caught.

        Parameters:
        errorObject - object that was processed
        message - error message
        throwable - throwable to produce a stacktrace
      • reportProgress

        public void reportProgress()
      • close

        public void close()
                   throws IOException
        Print out a summary of what the program did. Useful when analyzing lists of experiments etc. Use the 'successObjects' and 'errorObjects'
        Specified by:
        close in interface AutoCloseable
        Throws:
        IOException