private ByteBuffer getBuffer() {
    ByteBuffer bb = buffers.poll();
    if (bb != null) {
      // To reset the limit to capacity and position to 0, must clear here.
      bb.clear();
      poolAllocationBytes.add(bufSize);
      return bb;
    }
    while (true) {
      int c = this.usedBufCount.intValue();
      if (c >= this.maxBufCount) {
        if (!maxPoolSizeInfoLevelLogged) {
          LOG.info("Pool already reached its max capacity : {} and no free buffers now. Consider "
            + "increasing the value for '{}' ?", maxBufCount, MAX_BUFFER_COUNT_KEY);
          maxPoolSizeInfoLevelLogged = true;
        }
        return null;
      }
      if (!this.usedBufCount.compareAndSet(c, c + 1)) {
        continue;
      }
      poolAllocationBytes.add(bufSize);
      return ByteBuffer.allocateDirect(bufSize);
    }
  }
@return One free DirectByteBuffer from the pool. If no free ByteBuffer and we have not reached
        the maximum pool size, it will create a new one and return. In case of max pool size
        also reached, will return null. When pool returned a ByteBuffer, make sure to return it
        back to pool after use.
hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java