private static <T> void connect(CompletableFuture<T> srcFuture, CompletableFuture<T> dstFuture,
    Optional<MetricsConnection> metrics) {
    addListener(srcFuture, (r, e) -> {
      if (e != null) {
        dstFuture.completeExceptionally(e);
      } else {
        if (dstFuture.complete(r)) {
          metrics.ifPresent(MetricsConnection::incrHedgedReadWin);
        }
      }
    });
    // The cancellation may be a dummy one as the dstFuture may be completed by this srcFuture.
    // Notice that this is a bit tricky, as the execution chain maybe 'complete src -> complete dst
    // -> cancel src', for now it seems to be fine, as the will use CAS to set the result first in
    // CompletableFuture. If later this causes problems, we could use whenCompleteAsync to break the
    // tie.
    addListener(dstFuture, (r, e) -> srcFuture.cancel(false));
  }
Connect the two futures, if the src future is done, then mark the dst future as done. And if
the dst future is done, then cancel the src future. This is used for timeline consistent read.
<p/>
Pass empty metrics if you want to link the primary future and the dst future so we will not
increase the hedge read related metrics.
hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java