private long getNextDelay(long currentDelay, final Exception previousException, final Exception currentException) {
    if (previousException != null && !previousException.getClass().equals(currentException.getClass())) {
      // New exception encountered. Returning initial delay for next retry.
      return this.initialDelayInSeconds;
    }
    if (currentDelay <= 0) { // in case initial delay was set to 0.
      currentDelay = MINIMUM_DELAY_IN_SEC;
    }
    currentDelay *= this.backOff;
    if (this.maxJitterInSeconds > 0) {
      currentDelay += new Random().nextInt(this.maxJitterInSeconds);
    }
    if (currentDelay > this.maxRetryDelayInSeconds) {
      currentDelay = this.maxRetryDelayInSeconds;
    }
    return  currentDelay;
  }
Class to implement any retry logic in case of exceptions.
ql/src/java/org/apache/hadoop/hive/ql/exec/util/Retryable.java