dk.netarkivet.common.utils
Class TimeUtils

java.lang.Object
  extended by dk.netarkivet.common.utils.TimeUtils

public class TimeUtils
extends java.lang.Object

Various utilities for waiting some time.


Constructor Summary
TimeUtils()
           
 
Method Summary
static void exponentialBackoffSleep(int attempt)
          Sleep for an exponentially backing off amount of time, in milliseconds.
static void exponentialBackoffSleep(int attempt, int timeunit)
          Sleep for an exponentially backing off amount of time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeUtils

public TimeUtils()
Method Detail

exponentialBackoffSleep

public static void exponentialBackoffSleep(int attempt)
Sleep for an exponentially backing off amount of time, in milliseconds. Thus the first attempt will sleep for 1 ms, the second for 2, the third for 4, etc.

Parameters:
attempt - The attempt number, which is the log2 of the number of milliseconds spent asleep.

exponentialBackoffSleep

public static void exponentialBackoffSleep(int attempt,
                                           int timeunit)
Sleep for an exponentially backing off amount of time. The mode describes the unit of time as defined by @see java.util.Calendar

Parameters:
attempt - The attempt number, which is the log2 of the number of timeunits spent asleep.
timeunit - the specified timeunit in miliseconds
Throws:
ArgumentNotValid - if timeunit is unsupported.