コード例 #1
0
  /** Shrinks queue to maximum allowed size. */
  private void shrink() {
    long maxSize = this.maxSize;
    int maxBlocks = this.maxBlocks;

    int cnt = queue.sizex();

    for (int i = 0;
        i < cnt
            && (maxBlocks > 0 && queue.sizex() > maxBlocks
                || maxSize > 0 && curSize.longValue() > maxSize);
        i++) {
      GridCacheEntry<GridGgfsBlockKey, byte[]> entry = queue.poll();

      if (entry == null) break; // Queue is empty.

      byte[] val = entry.peek();

      if (val != null)
        changeSize(-val.length); // Change current size as we polled entry from the queue.

      if (!entry.evict()) {
        // Reorder entries which we failed to evict.
        entry.removeMeta(META_NODE);

        touch(entry);
      }
    }
  }
コード例 #2
0
 /** {@inheritDoc} */
 @Override
 public long getCurrentSize() {
   return curSize.longValue();
 }
コード例 #3
0
 /**
  * Change current size.
  *
  * @param delta Delta in bytes.
  */
 private void changeSize(int delta) {
   if (delta != 0) curSize.add(delta);
 }