public static long getRandomWaitTime(long baseWindow, int failures, Random r) {
    return (long) (
          baseWindow * failures +     // grace period for the last round of attempt
          baseWindow * (failures + 1) * r.nextDouble()); // expanding time window for each failure
  }
Introducing a random factor to the wait time before another retry.
The wait time is dependent on # of failures and a random factor.
At the first time of getting an exception , the wait time
is a random number between 0..baseWindow msec. If the first retry
still fails, we will wait baseWindow msec grace period before the 2nd retry.
Also at the second retry, the waiting window is expanded to 2*baseWindow msec
alleviating the request rate from the server. Similarly the 3rd retry
will wait 2*baseWindow msec. grace period before retry and the waiting window is
expanded to 3*baseWindow msec and so on.
@param baseWindow the base waiting window.
@param failures number of failures so far.
@param r a random generator.
@return number of milliseconds for the next wait time.
ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java