@Override
  public int invalidate() {
    while (true) {
      long oldValue = state.get();
      if (State.getRefCount(oldValue) != 0) return INVALIDATE_FAILED;
      if (State.hasFlags(oldValue, State.FLAG_EVICTED)) return INVALIDATE_ALREADY_INVALID;
      long newValue = State.setFlag(oldValue, State.FLAG_EVICTED | State.FLAG_MEM_RELEASED);
      if (state.compareAndSet(oldValue, newValue)) break;
    }
    if (LlapIoImpl.LOCKING_LOGGER.isTraceEnabled()) {
      LlapIoImpl.LOCKING_LOGGER.trace("Invalidated {} due to eviction", this);
    }
    return INVALIDATE_OK;
  }
Invalidates the cached buffer. The memory allocation in memory manager is managed by the
caller, and therefore we mark the buffer as having released the memory too.
@return Whether the we can invalidate; false if locked or already evicted.
llap-server/src/java/org/apache/hadoop/hive/llap/cache/LlapAllocatorBuffer.java