@Override public void close() { getCounters().close(); }
@Override public boolean lruLimitExceeded(EvictionCounters counters, DiskRegionView diskRegionView) { return counters.getCounter() > counters.getLimit(); }
public long getEvictionDestroys() { long result = 0; EvictionController evictionController = getEvictionController(); if (evictionController != null) { EvictionCounters es = evictionController.getCounters(); if (es != null) { result = es.getDestroys(); } } return result; }
removalEntry.getKey(), getTotalEntrySize(), bytesToEvict); stats.incEvictions(); if (_isOwnerALocalRegion()) { _getOwner().incBucketEvictions(); logger.trace(LogMarker.LRU_VERBOSE, "evictions={}", stats.getEvictions()); removalEntry.getKey(), getTotalEntrySize(), bytesToEvict); stats.incEvictions(); if (_isOwnerALocalRegion()) { _getOwner().incBucketEvictions(); logger.trace(LogMarker.LRU_VERBOSE, "evictions={}", stats.getEvictions()); getEvictionController().getCounters().getCounter());
@Override public void clear(RegionVersionVector regionVersionVector, BucketRegion bucketRegion) { if (regionVersionVector != null) { return; // when concurrency checks are enabled the clear operation removes entries iteratively } synchronized (this) { if (bucketRegion != null) { getStatistics().decrementCounter(bucketRegion.getCounter()); bucketRegion.resetCounter(); } else { getStatistics().resetCounter(); } initEmptyList(); } }
/** * Filling up the region with keys and values */ public static void main5(String[] args) throws Exception { DistributedSystem system = DistributedSystem.connect(new java.util.Properties()); Cache cache = CacheFactory.create(system); AttributesFactory factory = new AttributesFactory(); factory.setEvictionAttributes(EvictionAttributes.createLRUMemoryAttributes(2, (ObjectSizer) null, EvictionAction.OVERFLOW_TO_DISK)); LocalRegion region = (LocalRegion) cache.createRegion("TestDiskRegion", factory.create()); // DiskRegion dr = region.getDiskRegion(); // DiskRegionStats diskStats = dr.getStats(); EvictionCounters lruStats = getLRUStats(region); for (int i = 0; i < 10000; i++) { int[] array = new int[1000]; array[0] = i; try { region.put(array, new Integer(i)); } catch (IllegalStateException ex) { System.out.println("Ran out of space: " + ex); return; } } String s = "Limit is " + lruStats.getLimit() + " evictions are " + lruStats.getEvictions(); throw new RuntimeException(s); }
Assert.assertTrue(lruStats.getEvictions() == 0); for (total = 0; lruStats.getEvictions() <= 0; total++) { System.out.println("total puts " + total + ", evictions " + lruStats.getEvictions() + ", total entry size " + lruStats.getCounter()); int[] array = new int[250]; array[0] = total; Assert.assertTrue(lruStats.getEvictions() == 1); Assert.assertTrue(lruStats.getEvictions() == 2, String.valueOf(lruStats.getEvictions())); System.out.println("total gets " + i + ", evictions " + lruStats.getEvictions() + ", total entry size " + lruStats.getCounter()); long startEvictions = lruStats.getEvictions(); for (int i = 0; i < 10; i++) { region.put(new Integer(i), new int[251]); long expected = startEvictions + 1 + i; long actual = lruStats.getEvictions(); Assert.assertTrue(expected == actual, "For " + i + " expected " + expected + ", got " + actual);
/** * Return the Entry that is considered most recently used and available to be evicted to overflow. * Note that this implementation basically just returns the most recent thing added to the list. * So, unlike the parent class, is does no scanning based on the recentlyUsed bit. This is a * perfect implementation for our queues (gateway, client subscription) as long as they never * update something already in the queue. Since updates simply set the recentlyUsed bit then the * most recent node may be the one that was just updated and not moved to the tail of the list. */ @Override public EvictableEntry getEvictableEntry() { long evaluations = 0; EvictionNode evictionNode; // search for entry to return from list for (;;) { evictionNode = unlinkTailEntry(); // end of Lifo list stop searching if (evictionNode == null) { break; } evaluations++; synchronized (evictionNode) { // if entry NOT used by transaction and NOT evicted return entry if (!evictionNode.isInUseByTransaction() && !evictionNode.isEvicted()) { break; } } } getStatistics().incEvaluations(evaluations); return (EvictableEntry) evictionNode; }
getStatistics().incEvaluations(numEvals); return null; logger.trace(LogMarker.LRU_CLOCK_VERBOSE, "greedily picking an available entry"); getStatistics().incGreedyReturns(1); getStatistics().incEvaluations(numEvals); return (EvictableEntry) aNode;
if (evictedBytes != 0) { _getOwner().incBucketEvictions(); stats.incEvictions(); if (isDebugEnabled_LRU) { logger.debug("evictions={}", stats.getEvictions());
@Override public long limit() { return getCounters().getLimit(); }
int size = entry.getEntrySize(); if (region.evictDestroy(entry)) { stats.incDestroys(); return size; } else { BucketRegion bucketRegion = (BucketRegion) _getOwner(); bucketRegion.updateCounter(change); stats.updateCounter(change); } else { stats.updateCounter(change);
@Override public void closeBucket(BucketRegion bucketRegion) { getCounters().decrementCounter(bucketRegion.getCounter()); }
@Override public synchronized void destroyEntry(EvictionNode evictionNode) { if (logger.isTraceEnabled(LogMarker.LRU_CLOCK_VERBOSE)) { logger.trace(LogMarker.LRU_CLOCK_VERBOSE, "destroyEntry called for {}", evictionNode); } if (removeEntry(evictionNode)) { getStatistics().incDestroys(); } }
@Override public long getEvictionCounter() { long result = 0L; EvictionController evictionController = getEvictionController(); if (evictionController != null) { EvictionCounters es = evictionController.getCounters(); if (es != null) { result = es.getCounter(); } } return result; }
@Override public long getEvictions() { return this.getEvictionController().getCounters().getEvictions(); }
@Test public void clearWithoutBucketRegionResetsStats() throws Exception { TestEvictionList noBucketRegionEvictionList = new TestEvictionList(controller); noBucketRegionEvictionList.appendEntry(new LinkableEvictionNode()); assertThat(noBucketRegionEvictionList.size()).isEqualTo(1); noBucketRegionEvictionList.clear(null, null); verify(stats).resetCounter(); assertThat(noBucketRegionEvictionList.size()).isZero(); }
@Override public Statistics getEvictionStatistics() { Statistics result = null; EvictionController evictionController = getEvictionController(); if (evictionController != null) { EvictionCounters es = evictionController.getCounters(); if (es != null) { result = es.getStatistics(); } } return result; }
@Test public void evictingFromNonEmptyListTest() throws Exception { LIFOList list = new LIFOList(controller); EvictionNode node = mock(EvictableEntry.class); list.appendEntry(node); assertThat(list.size()).isEqualTo(1); when(node.next()).thenReturn(list.tail); when(node.previous()).thenReturn(list.head); assertThat(list.getEvictableEntry()).isSameAs(node); verify(stats).incEvaluations(anyLong()); assertThat(list.size()).isZero(); }
public long getEvictionLimit() { long result = 0L; EvictionController evictionController = getEvictionController(); if (evictionController != null) { EvictionCounters es = evictionController.getCounters(); if (es != null) { result = es.getLimit(); } } return result; }