int getClassCacheSize() { return getterCache.size(); }
int getClassCacheSize() { return getterCache.size(); }
int getGetterPerClassCacheSize(Class clazz) { SampleableConcurrentHashMap cacheForClass = getterCache.get(clazz); return cacheForClass != null ? cacheForClass.size() : -1; }
int getGetterPerClassCacheSize(Class clazz) { SampleableConcurrentHashMap cacheForClass = getterCache.get(clazz); return cacheForClass != null ? cacheForClass.size() : -1; }
/** * Gets and returns samples as <code>sampleCount</code>. * * @param sampleCount Count of samples * @return the sampled {@link SamplingEntry} list */ public <E extends SamplingEntry> Iterable<E> getRandomSamples(int sampleCount) { if (sampleCount < 0) { throw new IllegalArgumentException("Sample count cannot be a negative value."); } if (sampleCount == 0 || size() == 0) { return Collections.EMPTY_LIST; } return new LazySamplingEntryIterableIterator<E>(sampleCount); }
/** * Gets and returns samples as <code>sampleCount</code>. * * @param sampleCount Count of samples * @return the sampled {@link SamplingEntry} list */ public <E extends SamplingEntry> Iterable<E> getRandomSamples(int sampleCount) { if (sampleCount < 0) { throw new IllegalArgumentException("Sample count cannot be a negative value."); } if (sampleCount == 0 || size() == 0) { return Collections.EMPTY_LIST; } return new LazySamplingEntryIterableIterator<E>(sampleCount); }
/** * It works on best effort basis. If multi-threaded calls involved it may evict all elements, but it's unlikely. */ private void evictMap(SampleableConcurrentHashMap<?, ?> map, int triggeringEvictionSize, int afterEvictionSize) { map.purgeStaleEntries(); int mapSize = map.size(); if (mapSize - triggeringEvictionSize >= 0) { for (SampleableConcurrentHashMap.SamplingEntry entry : map.getRandomSamples(mapSize - afterEvictionSize)) { map.remove(entry.getEntryKey()); } } }
/** * It works on best effort basis. If multi-threaded calls involved it may evict all elements, but it's unlikely. */ private void evictMap(SampleableConcurrentHashMap<?, ?> map, int triggeringEvictionSize, int afterEvictionSize) { map.purgeStaleEntries(); int mapSize = map.size(); if (mapSize - triggeringEvictionSize >= 0) { for (SampleableConcurrentHashMap.SamplingEntry entry : map.getRandomSamples(mapSize - afterEvictionSize)) { map.remove(entry.getEntryKey()); } } }