protected <T> T invokeWithRetry(Callable<T> func) throws SemanticException {
    long startTime = System.currentTimeMillis();
    long delay = this.initialDelayInSeconds;
    while (true) {
      try {
        LOG.debug("Retrying method: {}", func.getClass().getName(), null);
        return func.call();
      } catch (Exception e) {
        if (processImportExportLockException(e, delay)) {
          //retry case. compute next sleep time
          delay = getNextDelay(delay);
          if (elapsedTimeInSeconds(startTime) + delay > this.totalDurationInSeconds) {
            throw new SemanticException(ErrorMsg.REPL_RETRY_EXHAUSTED.format(), e);
          }
          continue;
        }
        if (processInvalidParameterException(e)) {
          LOG.info("There is nothing to export/import.");
          return null;
        }
        LOG.error(func.getClass().getName(), e);
        throw new SemanticException(ErrorMsg.REPL_RETRY_EXHAUSTED.format(), e);
      }
    }
  }
Implement retry logic for service calls.
ql/src/java/org/apache/hadoop/hive/ql/exec/repl/atlas/RetryingClientTimeBased.java