/** {@inheritDoc} */ @Override public boolean backup() { assert impl != null; return impl.backup(); }
/** {@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(); } }
@Override public boolean apply(GridCacheEntry<?, ?> entry) { return !(entry.getKey() instanceof GridCacheInternal); } };
Node<GridCacheEntry<K, V>> node = entry.meta(meta); node = queue.offerLastx(entry); if (entry.putMetaIfAbsent(meta, node) != null) { if (!entry.isCached()) { else if (!entry.removeMeta(meta, node)) return false;
/** * 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); } } }
/** {@inheritDoc} */ @Override public void onEntryAccessed(boolean rmv, GridCacheEntry<K, V> entry) { if (!rmv) { if (!entry.isCached()) return; if (touch(entry)) shrink(); } else { Node<GridCacheEntry<K, V>> node = entry.removeMeta(meta); if (node != null) queue.unlinkx(node); } }
/** * @return Future. */ @SuppressWarnings("unchecked") public GridFuture<?> cancelAll() { Collection<GridFuture<?>> futs = new ArrayList<>(); for (GridCacheEntry<Object, Object> e : cache.entrySetx()) { if (!(e.getKey() instanceof GridServiceDeploymentKey)) continue; GridServiceDeployment dep = (GridServiceDeployment)e.getValue(); // Cancel each service separately. futs.add(cancel(dep.configuration().getName())); } return futs.isEmpty() ? new GridFinishedFuture<>(ctx) : new GridCompoundFuture(ctx, null, futs); }
@SuppressWarnings({"unchecked"}) @Override public boolean apply(Object o) { return ((GridCacheEntry)o).peek() != null; }
/** * 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); } } }
/** {@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 boolean primary() { assert impl != null; return impl.primary(); }
/** {@inheritDoc} */ @Nullable @Override public <V> V putMetaIfAbsent(String name, Callable<V> c) { assert impl != null; return impl.putMetaIfAbsent(name, c); }
/** {@inheritDoc} */ @Override public <V> V removeMeta(String name) { assert impl != null; return impl.removeMeta(name); }
/** {@inheritDoc} */ @Override public <V> boolean replaceMeta(String name, V curVal, V newVal) { assert impl != null; return impl.replaceMeta(name, curVal, newVal); }
/** {@inheritDoc} */ @Override public boolean isCached() { assert impl != null; return impl.isCached(); }
/** {@inheritDoc} */ @Override public <V> V meta(String name) { assert impl != null; return impl.meta(name); }
Node<GridCacheEntry<K, V>> node = entry.meta(meta); node = queue.offerLastx(entry); if (entry.putMetaIfAbsent(meta, node) != null) { if (!entry.isCached()) { else if (!entry.removeMeta(meta, node)) return false; if (!entry.replaceMeta(meta, node, newNode))
/** * 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); } } }