org.apache.lucene.util
Class ProgressTracker

Object
  extended by ProgressTracker
All Implemented Interfaces:
Cloneable

public abstract class ProgressTracker
extends Object
implements Cloneable

Convenient class for reporting progress on a long, possibly complex multi-phase, process.

Author:
Martin Haye

Nested Class Summary
private  class ProgressTracker.IntHolder
           
private  class ProgressTracker.LongHolder
           
private  class ProgressTracker.StringHolder
           
 
Field Summary
private  float hiPct
           
private  float loPct
           
private  int minInterval
           
private  ProgressTracker.StringHolder prevDescrip
           
private  ProgressTracker.IntHolder prevPctDone
           
private  ProgressTracker.LongHolder prevTime
           
 
Constructor Summary
ProgressTracker()
          Initialize a 0..100% tracker
ProgressTracker(float loPct, float hiPct)
          Initialize a tracker for some other percentage range
 
Method Summary
 Object clone()
          Clone this tracker
 void progress(long workDone, long totalWork, String descrip)
          To be called periodically by code that does work.
 void progress(long workDone, long totalWork, String descrip, boolean force)
          To be called periodically by code that does work.
abstract  void report(int pctDone, String descrip)
          Supply this method to actually print out the progress
 void setMinInterval(int millisecs)
          Override the default update interval of 30 seconds
 ProgressTracker[] split(long[] works)
          Split this tracker into an arbitrary number of sub-trackers, based on how much work each sub-tracker needs to do.
 ProgressTracker[] split(long work1, long work2)
          Split this tracker into two sub-trackers, based on how much work each sub-tracker needs to do.
 ProgressTracker[] split(long work1, long work2, long work3)
          Split this tracker into three sub-trackers, based on how much work each sub-tracker needs to do.
 ProgressTracker[] split(long work1, long work2, long work3, long work4)
          Split this tracker into four sub-trackers, based on how much work each sub-tracker needs to do.
 
Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loPct

private float loPct

hiPct

private float hiPct

minInterval

private int minInterval

prevPctDone

private ProgressTracker.IntHolder prevPctDone

prevTime

private ProgressTracker.LongHolder prevTime

prevDescrip

private ProgressTracker.StringHolder prevDescrip
Constructor Detail

ProgressTracker

public ProgressTracker()
Initialize a 0..100% tracker


ProgressTracker

public ProgressTracker(float loPct,
                       float hiPct)
Initialize a tracker for some other percentage range

Method Detail

setMinInterval

public void setMinInterval(int millisecs)
Override the default update interval of 30 seconds

Parameters:
millisecs - how many milliseconds between updates (minimum)

split

public ProgressTracker[] split(long work1,
                               long work2)
Split this tracker into two sub-trackers, based on how much work each sub-tracker needs to do.


split

public ProgressTracker[] split(long work1,
                               long work2,
                               long work3)
Split this tracker into three sub-trackers, based on how much work each sub-tracker needs to do.


split

public ProgressTracker[] split(long work1,
                               long work2,
                               long work3,
                               long work4)
Split this tracker into four sub-trackers, based on how much work each sub-tracker needs to do.


split

public ProgressTracker[] split(long[] works)
Split this tracker into an arbitrary number of sub-trackers, based on how much work each sub-tracker needs to do. This is useful for multi- phase processes.


clone

public Object clone()
Clone this tracker

Overrides:
clone in class Object

progress

public void progress(long workDone,
                     long totalWork,
                     String descrip)
To be called periodically by code that does work.


progress

public void progress(long workDone,
                     long totalWork,
                     String descrip,
                     boolean force)
To be called periodically by code that does work.


report

public abstract void report(int pctDone,
                            String descrip)
Supply this method to actually print out the progress