private long evictOrPurge(boolean isPurge) {
      long evictedBytes = 0;
      Iterator<LlapCacheableBuffer> it = buffers.iterator();
      while (it.hasNext()) {
        LlapCacheableBuffer buffer = it.next();
        if (isPurge || (!isPurge && buffer.isMarkedForEviction())) {
          if (INVALIDATE_OK == buffer.invalidate()) {
            evictedBytes += buffer.getMemoryUsage();
            if (!isPurge) {
              evictionListener.notifyProactivelyEvicted(buffer);
            } else {
              evictionListener.notifyEvicted(buffer);
            }
            it.remove();
          }
        }
      }
      return evictedBytes;
    }
Test cases for proactive LLAP cache eviction.
llap-server/src/test/org/apache/hadoop/hive/llap/cache/TestProactiveEviction.java