Package ubic.gemma.cli.batch
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 Summary
Constructors Constructor Description BatchTaskProgressReporter(BatchTaskSummaryWriter summaryWriter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addErrorObject(Serializable errorObject, Exception exception)
Add an error object based on an exception.void
addErrorObject(Serializable errorObject, String message)
Add an error object without a cause stacktrace.void
addErrorObject(Serializable errorObject, String message, Throwable throwable)
Add an error object with a stacktrace to indicate failure in a batch processing.void
addSuccessObject(Serializable successObject)
void
addSuccessObject(Serializable successObject, String message)
Add a success object to indicate success in a batch processing.void
addWarningObject(Serializable warningObject, String message)
void
addWarningObject(Serializable warningObject, String message, Throwable throwable)
void
close()
Print out a summary of what the program did.int
getCompletedTasks()
Obtain the number of completed tasks (either with a success or failure result).boolean
hasErrorObjects()
Indicate if error objects have been reported.void
reportProgress()
void
setEstimatedMaxTasks(int estimatedMaxTasks)
Set the maximum number of tasks that are expected to be run.void
setReportFrequencyMillis(int reportFrequencyMillis)
Set the frequency at which to report progress in milliseconds.
-
-
-
Constructor Detail
-
BatchTaskProgressReporter
public BatchTaskProgressReporter(BatchTaskSummaryWriter summaryWriter)
-
-
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 processedmessage
- success message
-
addSuccessObject
public void addSuccessObject(Serializable successObject)
- See Also:
addSuccessObject(Serializable, String)
-
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 processedmessage
- error messagethrowable
- 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(Serializable, String)
-
addErrorObject
public void addErrorObject(@Nullable Serializable errorObject, Exception exception)
Add an error object based on an exception.
-
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 interfaceAutoCloseable
- Throws:
IOException
-
-