public void init() {
    assert nextFreeOffset.get() == UNINITIALIZED;
    try {
      allocateDataBuffer();
    } catch (OutOfMemoryError e) {
      boolean failInit = nextFreeOffset.compareAndSet(UNINITIALIZED, OOM);
      assert failInit; // should be true.
      throw e;
    }
    // Mark that it's ready for use
    // Move 4 bytes since the first 4 bytes are having the chunkid in it
    boolean initted = nextFreeOffset.compareAndSet(UNINITIALIZED, Bytes.SIZEOF_INT);
    // We should always succeed the above CAS since only one thread
    // calls init()!
    Preconditions.checkState(initted, "Multiple threads tried to init same chunk");
  }
Actually claim the memory for this chunk. This should only be called from the thread that
constructed the chunk. It is thread-safe against other threads calling alloc(), who will block
until the allocation is complete.
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/Chunk.java