/** {@inheritDoc} */ @Override protected Map<String, GridBiTuple<Integer, Integer>> run(Set<String> names) throws GridException { Map<String, GridBiTuple<Integer, Integer>> total = new HashMap<>(); for (GridCache c: g.cachesx()) { String cacheName = c.name(); if (names.contains(cacheName)) { Set<GridCacheEntry> entries = c.entrySet(); int before = entries.size(), after = before; for (GridCacheEntry entry: entries) { if (entry.backup() && entry.evict()) after--; } total.put(cacheName, new GridBiTuple<>(before, after)); } } return total; }
/** {@inheritDoc} */ @Override public void onEntryAccessed(boolean rmv, GridCacheEntry<K, V> entry) { if (!entry.isCached()) return; GridCache<K, V> cache = entry.projection().cache(); int size = cache.size(); for (int i = max; i < size; i++) { GridCacheEntry<K, V> e = cache.randomEntry(); if (e != null) e.evict(); } }
/** * Shrinks queue to maximum allowed size. */ private void shrink() { int max = this.max; int startSize = queue.sizex(); for (int i = 0; i < startSize && queue.sizex() > max; i++) { GridCacheEntry<K, V> entry = queue.poll(); if (entry == null) break; if (!entry.evict()) { entry.removeMeta(meta); touch(entry); } } }
/** * Shrinks FIFO queue to maximum allowed size. */ private void shrink() { int max = this.max; int startSize = queue.sizex(); for (int i = 0; i < startSize && queue.sizex() > max; i++) { GridCacheEntry<K, V> entry = queue.poll(); if (entry == null) break; if (!entry.evict()) { entry.removeMeta(meta); touch(entry); } } }
/** * 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); } } }
/** * 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); } } }