private void allocateNewBuffer() {
    if (this.curBuf != null) {
      this.curBuf.flip();// On the current buf set limit = pos and pos = 0.
    }
    // Get an initial ByteBuffer from the allocator.
    SingleByteBuff sbb = allocator.allocateOneBuffer();
    this.curBuf = sbb.nioByteBuffers()[0];
    this.allBufs.add(sbb);
  }
An OutputStream which writes data into ByteBuffers. It will try to get ByteBuffer, as and when
needed, from the passed pool. When pool is not giving a ByteBuffer it will create one on heap.
Make sure to call {@link #releaseResources()} method once the Stream usage is over and data is
transferred to the wanted destination. Not thread safe!
hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBufferListOutputStream.java