private void failWaitingAckQueue(Channel channel, Supplier<Throwable> errorSupplier) {
    Throwable error = errorSupplier.get();
    for (Iterator<Callback> iter = waitingAckQueue.iterator(); iter.hasNext();) {
      Callback c = iter.next();
      // find the first sync request which we have not acked yet and fail all the request after it.
      if (!c.unfinishedReplicas.contains(channel.id())) {
        continue;
      }
      for (;;) {
        c.future.completeExceptionally(error);
        if (!iter.hasNext()) {
          break;
        }
        c = iter.next();
      }
      break;
    }
  }
An asynchronous HDFS output stream implementation which fans out data to datanode and only
supports writing file with only one block.
<p>
Use the createOutput method in {@link FanOutOneBlockAsyncDFSOutputHelper} to create. The main
usage of this class is implementing WAL, so we only expose a little HDFS configurations in the
method. And we place it here under io package because we want to make it independent of WAL
implementation thus easier to move it to HDFS project finally.
<p>
Note that, although we support pipelined flush, i.e, write new data and then flush before the
previous flush succeeds, the implementation is not thread safe, so you should not call its
methods concurrently.
<p>
Advantages compare to DFSOutputStream:
<ol>
<li>The fan out mechanism. This will reduce the latency.</li>
<li>Fail-fast when connection to datanode error. The WAL implementation could open new writer
ASAP.</li>
<li>We could benefit from netty's ByteBuf management mechanism.</li>
</ol>
hbase-asyncfs/src/main/java/org/apache/hadoop/hbase/io/asyncfs/FanOutOneBlockAsyncDFSOutput.java