private static boolean incRefIfNotEvicted(LlapAllocatorBuffer buf, boolean mustExist) {
    int rc = buf.tryIncRef();
    if (rc == LlapAllocatorBuffer.INCREF_FAILED) {
      fail("Failed to incref (bad state) " + buf);
    }
    if (rc <= 0 && mustExist) {
      fail("Failed to incref (evicted) " + buf);
    }
    return rc > 0; // We expect evicted, but not failed.
  }
This relies on allocations basically being sequential, no internal reordering. Rather,
the specific paths it takes do; all the scenarios should work regardless of allocation.
llap-server/src/test/org/apache/hadoop/hive/llap/cache/TestBuddyAllocatorForceEvict.java