@edu.umd.cs.findbugs.annotations.SuppressWarnings(
      value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE",
      justification = "head can not be null as cacheSize is greater than maxSize,"
        + " which means we have something in the queue")
  public void add(Map.Entry<BlockCacheKey, BucketEntry> entry) {
    if (cacheSize < maxSize) {
      queue.add(entry);
      cacheSize += entry.getValue().getLength();
    } else {
      BucketEntry head = queue.peek().getValue();
      if (BucketEntry.COMPARATOR.compare(entry.getValue(), head) > 0) {
        cacheSize += entry.getValue().getLength();
        cacheSize -= head.getLength();
        if (cacheSize > maxSize) {
          queue.poll();
        } else {
          cacheSize += head.getLength();
        }
        queue.add(entry);
      }
    }
  }
Attempt to add the specified entry to this queue.
<p>
If the queue is smaller than the max size, or if the specified element is ordered after the
smallest element in the queue, the element will be added to the queue. Otherwise, there is no
side effect of this call.
@param entry a bucket entry with key to try to add to the queue
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/CachedEntryQueue.java