Search in sources :

Example 1 with ManagedMetric

use of org.springframework.jmx.export.annotation.ManagedMetric 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);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) CacheStats(com.google.common.cache.CacheStats) ManagedMetric(org.springframework.jmx.export.annotation.ManagedMetric)

Aggregations

CacheStats (com.google.common.cache.CacheStats)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 ManagedMetric (org.springframework.jmx.export.annotation.ManagedMetric)1