use of com.google.common.cache.CacheStats in project jackrabbit-oak by apache.
the class CacheLIRS method stats.
@Override
public CacheStats stats() {
long hitCount = 0;
long missCount = 0;
long loadSuccessCount = 0;
long loadExceptionCount = 0;
long totalLoadTime = 0;
long evictionCount = 0;
for (Segment<K, V> s : segments) {
hitCount += s.hitCount;
missCount += s.missCount;
loadSuccessCount += s.loadSuccessCount;
loadExceptionCount += s.loadExceptionCount;
totalLoadTime += s.totalLoadTime;
evictionCount += s.evictionCount;
}
CacheStats stats = new CacheStats(hitCount, missCount, loadSuccessCount, loadExceptionCount, totalLoadTime, evictionCount);
return stats;
}
use of com.google.common.cache.CacheStats in project bazel by bazelbuild.
the class CacheFileDigestsModule method afterCommand.
@Override
public void afterCommand() {
super.afterCommand();
if (stats != null) {
CacheStats newStats = DigestUtils.getCacheStats();
Preconditions.checkNotNull(newStats, "The cache is enabled so we must get some stats back");
logStats("Accumulated cache stats after command", newStats);
logStats("Cache stats for finished command", newStats.minus(stats));
// Silence stats until next command that uses the executor.
stats = null;
}
}
use of com.google.common.cache.CacheStats in project acs-aem-commons by Adobe-Consulting-Services.
the class AbstractGuavaCacheMBean method getCacheStats.
@Override
@SuppressWarnings("squid:S1192")
public final TabularData getCacheStats() throws OpenDataException {
// Exposing all google guava stats.
final CompositeType cacheEntryType = new CompositeType(JMX_PN_CACHESTATS, JMX_PN_CACHESTATS, new String[] { JMX_PN_STAT, JMX_PN_VALUE }, new String[] { JMX_PN_STAT, JMX_PN_VALUE }, new OpenType[] { SimpleType.STRING, SimpleType.STRING });
final TabularDataSupport tabularData = new TabularDataSupport(new TabularType(JMX_PN_CACHESTATS, JMX_PN_CACHESTATS, cacheEntryType, new String[] { JMX_PN_STAT }));
CacheStats cacheStats = getCache().stats();
final Map<String, Object> row = new HashMap<String, Object>();
row.put(JMX_PN_STAT, "Request Count");
row.put(JMX_PN_VALUE, String.valueOf(cacheStats.requestCount()));
tabularData.put(new CompositeDataSupport(cacheEntryType, row));
row.put(JMX_PN_STAT, "Hit Count");
row.put(JMX_PN_VALUE, String.valueOf(cacheStats.hitCount()));
tabularData.put(new CompositeDataSupport(cacheEntryType, row));
row.put(JMX_PN_STAT, "Hit Rate");
row.put(JMX_PN_VALUE, String.format("%.0f%%", cacheStats.hitRate() * 100));
tabularData.put(new CompositeDataSupport(cacheEntryType, row));
row.put(JMX_PN_STAT, "Miss Count");
row.put(JMX_PN_VALUE, String.valueOf(cacheStats.missCount()));
tabularData.put(new CompositeDataSupport(cacheEntryType, row));
row.put(JMX_PN_STAT, "Miss Rate");
row.put(JMX_PN_VALUE, String.format("%.0f%%", cacheStats.missRate() * 100));
tabularData.put(new CompositeDataSupport(cacheEntryType, row));
row.put(JMX_PN_STAT, "Eviction Count");
row.put(JMX_PN_VALUE, String.valueOf(cacheStats.evictionCount()));
tabularData.put(new CompositeDataSupport(cacheEntryType, row));
row.put(JMX_PN_STAT, "Load Count");
row.put(JMX_PN_VALUE, String.valueOf(cacheStats.loadCount()));
tabularData.put(new CompositeDataSupport(cacheEntryType, row));
row.put(JMX_PN_STAT, "Load Exception Count");
row.put(JMX_PN_VALUE, String.valueOf(cacheStats.loadExceptionCount()));
tabularData.put(new CompositeDataSupport(cacheEntryType, row));
row.put(JMX_PN_STAT, "Load Exception Rate");
row.put(JMX_PN_VALUE, String.format("%.0f%%", cacheStats.loadExceptionRate() * 100));
tabularData.put(new CompositeDataSupport(cacheEntryType, row));
row.put(JMX_PN_STAT, "Load Success Count");
row.put(JMX_PN_VALUE, String.valueOf(cacheStats.loadSuccessCount()));
tabularData.put(new CompositeDataSupport(cacheEntryType, row));
row.put(JMX_PN_STAT, "Average Load Penalty");
row.put(JMX_PN_VALUE, String.valueOf(cacheStats.averageLoadPenalty()));
tabularData.put(new CompositeDataSupport(cacheEntryType, row));
row.put(JMX_PN_STAT, "Total Load Time");
row.put(JMX_PN_VALUE, String.valueOf(cacheStats.totalLoadTime()));
tabularData.put(new CompositeDataSupport(cacheEntryType, row));
return tabularData;
}
use of com.google.common.cache.CacheStats in project spring-integration by spring-projects.
the class StoredProcExecutorTests method testSetJdbcCallOperationsCacheSize.
@Test
public void testSetJdbcCallOperationsCacheSize() throws Exception {
final DataSource datasource = mock(DataSource.class);
final StoredProcExecutor storedProcExecutor = new StoredProcExecutor(datasource);
storedProcExecutor.setJdbcCallOperationsCacheSize(0);
final ExpressionFactoryBean efb = new ExpressionFactoryBean("headers['stored_procedure_name']");
efb.afterPropertiesSet();
final Expression expression = efb.getObject();
storedProcExecutor.setStoredProcedureNameExpression(expression);
storedProcExecutor.setBeanFactory(mock(BeanFactory.class));
storedProcExecutor.afterPropertiesSet();
this.mockTheOperationsCache(storedProcExecutor);
for (int i = 1; i <= 10; i++) {
storedProcExecutor.executeStoredProcedure(MessageBuilder.withPayload("test").setHeader("stored_procedure_name", "123").build());
}
final CacheStats stats = (CacheStats) storedProcExecutor.getJdbcCallOperationsCacheStatistics();
LOGGER.info(stats);
assertEquals("Expected a cache misscount of 10", 10, stats.missCount());
}
use of com.google.common.cache.CacheStats in project spring-integration by spring-projects.
the class StoredProcExecutor method getJdbcCallOperationsCacheStatisticsAsMap.
/**
* Allows for the retrieval of metrics ({@link CacheStats}) for the
* {@link GuavaCacheWrapper#jdbcCallOperationsCache}.
*
* Provides the properties of {@link CacheStats} as a {@link Map}. This allows
* for exposing the those properties easily via JMX.
*
* @return Map containing metrics of the JdbcCallOperationsCache
*
* @see StoredProcExecutor#getJdbcCallOperationsCacheStatistics()
*/
@ManagedMetric
public Map<String, Object> getJdbcCallOperationsCacheStatisticsAsMap() {
if (!guavaPresent) {
throw new UnsupportedOperationException("The Google Guava library isn't present in the classpath.");
}
final CacheStats cacheStats = (CacheStats) getJdbcCallOperationsCacheStatistics();
final Map<String, Object> cacheStatistics = new HashMap<String, Object>(11);
cacheStatistics.put("averageLoadPenalty", cacheStats.averageLoadPenalty());
cacheStatistics.put("evictionCount", cacheStats.evictionCount());
cacheStatistics.put("hitCount", cacheStats.hitCount());
cacheStatistics.put("hitRate", cacheStats.hitRate());
cacheStatistics.put("loadCount", cacheStats.loadCount());
cacheStatistics.put("loadExceptionCount", cacheStats.loadExceptionCount());
cacheStatistics.put("loadExceptionRate", cacheStats.loadExceptionRate());
cacheStatistics.put("loadSuccessCount", cacheStats.loadSuccessCount());
cacheStatistics.put("missCount", cacheStats.missCount());
cacheStatistics.put("missRate", cacheStats.missRate());
cacheStatistics.put("totalLoadTime", cacheStats.totalLoadTime());
return Collections.unmodifiableMap(cacheStatistics);
}
Aggregations