private void handleConnectionFailure(int curRetries, int maxRetries, IOException ioe)
    throws IOException {
    closeSocket();

    // throw the exception if the maximum number of retries is reached
    if (curRetries >= maxRetries || ExceptionUtil.isInterrupt(ioe)) {
      throw ioe;
    }

    // otherwise back off and retry
    try {
      Thread.sleep(this.rpcClient.failureSleep);
    } catch (InterruptedException ie) {
      ExceptionUtil.rethrowIfInterrupt(ie);
    }

    if (LOG.isInfoEnabled()) {
      LOG.info("Retrying connect to server: " + remoteId.getAddress() + " after sleeping "
        + this.rpcClient.failureSleep + "ms. Already tried " + curRetries + " time(s).");
    }
  }
Handle connection failures If the current number of retries is equal to the max number of
retries, stop retrying and throw the exception; Otherwise backoff N seconds and try connecting
again. This Method is only called from inside setupIOstreams(), which is synchronized. Hence
the sleep is synchronized; the locks will be retained.
@param curRetries current number of retries
@param maxRetries max number of retries allowed
@param ioe        failure reason
@throws IOException if max number of retries is reached
hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/BlockingRpcConnection.java