Package com.google.gerrit.server.git
Class MultiProgressMonitor
- java.lang.Object
- 
- com.google.gerrit.server.git.MultiProgressMonitor
 
- 
 public class MultiProgressMonitor extends Object Progress reporting interface that multiplexes multiple sub-tasks.Output is of the format: Task: subA: 1, subB: 75% (3/4) (-)\r Task: subA: 2, subB: 75% (3/4), subC: 1 (\)\r Task: subA: 2, subB: 100% (4/4), subC: 1 (|)\r Task: subA: 4, subB: 100% (4/4), subC: 4, done \n Callers should try to keep task and sub-task descriptions short, since the output should fit on one terminal line. (Note that git clients do not accept terminal control characters, so true multi-line progress messages would be impossible.) 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description classMultiProgressMonitor.TaskHandle for a sub-task.
 - 
Field SummaryFields Modifier and Type Field Description static intUNKNOWNConstant indicating the total work units cannot be predicted.
 - 
Constructor SummaryConstructors Constructor Description MultiProgressMonitor(OutputStream out, String taskName)Create a new progress monitor for multiple sub-tasks.MultiProgressMonitor(OutputStream out, String taskName, long maxIntervalTime, TimeUnit maxIntervalUnit)Create a new progress monitor for multiple sub-tasks.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description MultiProgressMonitor.TaskbeginSubTask(String subTask, int subTaskWork)Begin a sub-task.voidend()End the overall task.<T> TwaitFor(Future<T> workerFuture)Wait for a task managed by aFuture, with no timeout.<T> TwaitFor(Future<T> workerFuture, long timeoutTime, TimeUnit timeoutUnit)Wait for a task managed by aFuture.
 
- 
- 
- 
Field Detail- 
UNKNOWNpublic static final int UNKNOWN Constant indicating the total work units cannot be predicted.- See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
MultiProgressMonitorpublic MultiProgressMonitor(OutputStream out, String taskName) Create a new progress monitor for multiple sub-tasks.- Parameters:
- out- stream for writing progress messages.
- taskName- name of the overall task.
 
 - 
MultiProgressMonitorpublic MultiProgressMonitor(OutputStream out, String taskName, long maxIntervalTime, TimeUnit maxIntervalUnit) Create a new progress monitor for multiple sub-tasks.- Parameters:
- out- stream for writing progress messages.
- taskName- name of the overall task.
- maxIntervalTime- maximum interval between progress messages.
- maxIntervalUnit- time unit for progress interval.
 
 
- 
 - 
Method Detail- 
waitForpublic <T> T waitFor(Future<T> workerFuture) Wait for a task managed by aFuture, with no timeout.- See Also:
- waitFor(Future, long, TimeUnit)
 
 - 
waitForpublic <T> T waitFor(Future<T> workerFuture, long timeoutTime, TimeUnit timeoutUnit) throws TimeoutException Wait for a task managed by aFuture.Must be called from the main thread, not a worker thread. Once a worker thread calls end(), the future has an additionalmaxIntervalto finish before it is forcefully cancelled andExecutionExceptionis thrown.- Parameters:
- workerFuture- a future that returns when worker threads are finished.
- timeoutTime- overall timeout for the task; the future is forcefully cancelled if the task exceeds the timeout. Non-positive values indicate no timeout.
- timeoutUnit- unit for overall task timeout.
- Throws:
- TimeoutException- if this thread or a worker thread was interrupted, the worker was cancelled, or timed out waiting for a worker to call- end().
 
 - 
beginSubTaskpublic MultiProgressMonitor.Task beginSubTask(String subTask, int subTaskWork) Begin a sub-task.- Parameters:
- subTask- sub-task name.
- subTaskWork- total work units in sub-task, or- UNKNOWN.
- Returns:
- sub-task handle.
 
 - 
endpublic void end() End the overall task.Must be called from a worker thread. 
 
- 
 
-