@Override public Long getValue() { return cache.getStatistics().getSize(); } });
public Map<String, Object> getCacheRuntimeInformationAsJson(Cache cache) { LinkedHashMap<String, Object> json = new LinkedHashMap<>(); StatisticsGateway statistics = cache.getStatistics(); json.put("Get Time in milliseconds", getStatisticsFrom(statistics.cacheGetOperation())); json.put("Put Time in milliseconds", getStatisticsFrom(statistics.cachePutOperation())); json.put("Remove Time in milliseconds", getStatisticsFrom(statistics.cacheRemoveOperation())); json.put("Cache Size", statistics.getSize()); LinkedHashMap<String, Long> cacheCount = new LinkedHashMap<>(); cacheCount.put("Hits", statistics.cacheHitCount()); cacheCount.put("Miss", statistics.cacheMissCount()); cacheCount.put("Expired", statistics.cacheExpiredCount()); cacheCount.put("Eviction", statistics.cacheEvictedCount()); cacheCount.put("Put", statistics.cachePutCount()); cacheCount.put("Remove", statistics.cacheRemoveCount()); json.put("Cache Counts", cacheCount); json.put("Cache Size (Disk)", statistics.getLocalDiskSize()); json.put("Cache Count (Disk)", statistics.localDiskHitCount()); return json; }
/** * @return the number of elements in the ehcache, with a varying degree of accuracy, depending on accuracy setting. */ public long getObjectCount() { return statistics.getSize(); }
/** * @return the number of elements in the ehcache, with a varying degree of accuracy, depending on accuracy setting. */ public long getObjectCount() { return statistics.getSize(); }
/** * {@inheritDoc} */ @Override public long getSize() { if (cache.getCacheConfiguration().isTerracottaClustered()) { return getRemoteSizeSample().getMostRecentSample().getCounterValue(); } CacheTransactionHelper.beginTransactionIfNeeded(cache); try { return cache.getStatistics().getSize(); } catch (RuntimeException e) { throw Utils.newPlainException(e); } finally { try { CacheTransactionHelper.commitTransactionIfNeeded(cache); } catch (RuntimeException re) { throw Utils.newPlainException(re); } } }
return statistics.getSize();
@Override public Long getValue() { return cache.getStatistics().getSize(); } });
cacheStats.put("CacheSize", statisticsGateway.getSize()); cacheStats.put("HitCount", statisticsGateway.cacheHitCount()); cacheStats.put("MissCount", statisticsGateway.cacheMissCount());
(Gauge<Long>) () -> cache.getStatistics().getSize());
/** * {@inheritDoc} */ @Override public long getSize() { if (cache.getCacheConfiguration().isTerracottaClustered()) { return getRemoteSizeSample().getMostRecentSample().getCounterValue(); } CacheTransactionHelper.beginTransactionIfNeeded(cache); try { return cache.getStatistics().getSize(); } catch (RuntimeException e) { throw Utils.newPlainException(e); } finally { try { CacheTransactionHelper.commitTransactionIfNeeded(cache); } catch (RuntimeException re) { throw Utils.newPlainException(re); } } }
/** * {@inheritDoc} */ @Override public long getSize() { if (cache.getCacheConfiguration().isTerracottaClustered()) { return getRemoteSizeSample().getMostRecentSample().getCounterValue(); } CacheTransactionHelper.beginTransactionIfNeeded(cache); try { return cache.getStatistics().getSize(); } catch (RuntimeException e) { throw Utils.newPlainException(e); } finally { try { CacheTransactionHelper.commitTransactionIfNeeded(cache); } catch (RuntimeException re) { throw Utils.newPlainException(re); } } }
public static SortedMap<CacheStatisticsKey, Supplier<Long>> toStatistics(final StatisticsGateway stats) { // Note: While most of these statistics we can reasonably expect to be cheap and just memoize, the // heap size in bytes is very likely to be expensive. To make it possible to opt out of retrieving // it, we hide it behind a Supplier, here. final Supplier<Long> heapSize = new Supplier<Long>() { @Override public Long get() { return stats.getLocalHeapSizeInBytes(); } }; return ImmutableSortedMap.<CacheStatisticsKey,Supplier<Long>>orderedBy(CacheStatisticsKey.SORT_BY_LABEL) .put(SIZE, memoize(stats.getSize())) .put(HEAP_SIZE, heapSize) .put(HIT_COUNT, memoize(stats.cacheHitCount())) .put(PUT_COUNT, memoize(stats.cachePutCount())) .put(REMOVE_COUNT, memoize(stats.cacheRemoveCount())) .put(MISS_COUNT, memoize(stats.cacheMissCount())) .put(EVICTION_COUNT, memoize(stats.cacheEvictedCount())) .build(); } }