Class BatchTaskProgressReporter

java.lang.Object
ubic.gemma.cli.batch.BatchTaskProgressReporter
All Implemented Interfaces:
AutoCloseable

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

    • BatchTaskProgressReporter

      public BatchTaskProgressReporter(BatchTaskSummaryWriter summaryWriter, @Nullable Console console)
      Parameters:
      summaryWriter - a writer to report batch task results, results are emitted as they are added and BatchTaskSummaryWriter.close() is invoked when the reporter is closed to provide an opportunity to write a summary
      console - a console capable of receiving ANSI escape codes
  • Method Details

    • 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
    • addSuccessObject

      public void addSuccessObject(Serializable successObject)
      See Also:
    • addWarningObject

      public void addWarningObject(@Nullable Serializable warningObject, String message)
    • addWarningObject

      public void addWarningObject(@Nullable Serializable warningObject, String message, Throwable throwable)
    • 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
    • addErrorObject

      public void addErrorObject(@Nullable Serializable errorObject, String message)
      Add an error object without a cause stacktrace.
      See Also:
    • addErrorObject

      public void addErrorObject(@Nullable Serializable errorObject, Exception exception)
      Add an error object based on an exception.
      See Also:
    • 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