private void waitHandshakeFinished(final AtomicBoolean isHandshakeFinished) {
    try {
      final long startTime = System.currentTimeMillis();
      while (!isHandshakeFinished.get()) {
        if (isClosed
            || System.currentTimeMillis() - startTime
                > PipeConfig.getInstance().getPipeConnectorHandshakeTimeoutMs() * 2L) {
          throw new PipeConnectionException("Timed out when waiting for client handshake finish.");
        }
        Thread.sleep(10);
      }
    } catch (final InterruptedException e) {
      Thread.currentThread().interrupt();
      throw new PipeException("Interrupted while waiting for handshake response.", e);
    }
  }
Handshake with the target if necessary.

@param client client to handshake
@return {@code true} if the handshake is already finished, {@code false} if the handshake is
    not finished yet and finished in this method
@throws Exception if an error occurs.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/connector/client/IoTDBDataNodeAsyncClientManager.java