private <T> RetryResult<T> callWithReconnect(TFunction<T> supplier)
      throws IoTDBConnectionException {
    T ret;
    try {
      ret = supplier.run();
      return new RetryResult<>(ret, null, 0);
    } catch (TException e) {
      if (reconnect()) {
        try {
          ret = supplier.run();
          return new RetryResult<>(ret, null, 1);
        } catch (TException tException) {
          throw new IoTDBConnectionException(tException);
        }
      } else {
        throw new IoTDBConnectionException(logForReconnectionFailure());
      }
    }
  }
reconnect if the remote datanode is unreachable retry if the status is set to needRetry
iotdb-client/session/src/main/java/org/apache/iotdb/session/SessionConnection.java