/** * Peeks into the cache's internals to verify that its eviction queue is consistent. Verifies that * the prev/next links are correct, and that all items in each segment are also in that segment's * eviction (recency) queue. */ static void checkEviction(Cache<?, ?> cache) { if (hasLocalCache(cache)) { checkEviction(toLocalCache(cache)); } }
static void checkValidState(LocalCache<?, ?> cchm) { for (Segment<?, ?> segment : cchm.segments) { segment.cleanUp(); assertFalse(segment.isLocked()); Map<?, ?> table = segmentTable(segment); // cleanup and then check count after we have a strong reference to all entries segment.cleanUp(); // under high memory pressure keys/values may be nulled out but not yet enqueued assertThat(table.size()).isAtMost(segment.count); for (Entry<?, ?> entry : table.entrySet()) { assertNotNull(entry.getKey()); assertNotNull(entry.getValue()); assertSame(entry.getValue(), cchm.get(entry.getKey())); } } checkEviction(cchm); checkExpiration(cchm); }
/** * Peeks into the cache's internals to verify that its eviction queue is consistent. Verifies * that the prev/next links are correct, and that all items in each segment are also in that * segment's eviction (recency) queue. */ static void checkEviction(Cache<?, ?> cache) { if (hasLocalCache(cache)) { checkEviction(toLocalCache(cache)); } }
static void checkValidState(LocalCache<?, ?> cchm) { for (Segment<?, ?> segment : cchm.segments) { segment.cleanUp(); assertFalse(segment.isLocked()); Map<?, ?> table = segmentTable(segment); // cleanup and then check count after we have a strong reference to all entries segment.cleanUp(); // under high memory pressure keys/values may be nulled out but not yet enqueued assertThat(table.size()).isAtMost(segment.count); for (Entry<?, ?> entry : table.entrySet()) { assertNotNull(entry.getKey()); assertNotNull(entry.getValue()); assertSame(entry.getValue(), cchm.get(entry.getKey())); } } checkEviction(cchm); checkExpiration(cchm); }