private static <T> void sendRequestsToSecondaryReplicas(
    Function<Integer, CompletableFuture<T>> requestReplica, RegionLocations locs,
    CompletableFuture<T> future, Optional<MetricsConnection> metrics) {
    if (future.isDone()) {
      // do not send requests to secondary replicas if the future is done, i.e, the primary request
      // has already been finished.
      return;
    }
    for (int replicaId = 1, n = locs.size(); replicaId < n; replicaId++) {
      CompletableFuture<T> secondaryFuture = requestReplica.apply(replicaId);
      metrics.ifPresent(MetricsConnection::incrHedgedReadOps);
      connect(secondaryFuture, future, metrics);
    }
  }
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