@Override
  public Object invoke(Object o, Method method, Object[] args) throws Throwable {
    int attempts = 0;

    while (true) {
      attempts++;
      InvocationResult invokeResult = invokeInternal(method, args);
      if (invokeResult.success) {
        return invokeResult.result;
      }

      // Error because of thrift client, we have to recreate base object
      connectWithRetry(conf.getIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_CLIENT_CONNECTION_RETRY_LIMIT));

      if (attempts >=  retryLimit) {
        LOG.error(method.getName() + " failed after " + attempts + " retries.",  invokeResult.exception);
        throw invokeResult.exception;
      }

      LOG.warn("Last call ThriftCLIServiceClient." + method.getName() + " failed, attempts = " + attempts,
        invokeResult.exception);
      Thread.sleep(retryDelaySeconds * 1000);
    }
  }
RetryingThriftCLIServiceClient. Creates a proxy for a CLIServiceClient
implementation and retries calls to it on failure.
service/src/java/org/apache/hive/service/cli/thrift/RetryingThriftCLIServiceClient.java