Search in sources :

Example 1 with StatisticsGateway

use of net.sf.ehcache.statistics.StatisticsGateway in project spring-boot by spring-projects.

the class EhCacheStatisticsProvider method getCacheStatistics.

@Override
public CacheStatistics getCacheStatistics(CacheManager cacheManager, EhCacheCache cache) {
    DefaultCacheStatistics statistics = new DefaultCacheStatistics();
    StatisticsGateway ehCacheStatistics = cache.getNativeCache().getStatistics();
    statistics.setSize(ehCacheStatistics.getSize());
    double hitRatio = cacheHitRatio(ehCacheStatistics);
    if (!Double.isNaN(hitRatio)) {
        // ratio is calculated 'racily' and can drift marginally above unity,
        // so we cap it here
        double sanitizedHitRatio = (hitRatio > 1 ? 1 : hitRatio);
        statistics.setHitRatio(sanitizedHitRatio);
        statistics.setMissRatio(1 - sanitizedHitRatio);
    }
    return statistics;
}
Also used : StatisticsGateway(net.sf.ehcache.statistics.StatisticsGateway)

Example 2 with StatisticsGateway

use of net.sf.ehcache.statistics.StatisticsGateway in project micrometer by micrometer-metrics.

the class EhCache2Metrics method rollbackTransactionMetrics.

private void rollbackTransactionMetrics(MeterRegistry registry) {
    StatisticsGateway stats = getStats();
    FunctionCounter.builder("cache.xa.rollbacks", stats, StatisticsGateway::xaRollbackExceptionCount).tags(getTagsWithCacheName()).tags("result", "exception").description("Transaction rollbacks that failed").register(registry);
    FunctionCounter.builder("cache.xa.rollbacks", stats, StatisticsGateway::xaRollbackSuccessCount).tags(getTagsWithCacheName()).tags("result", "success").description("Transaction rollbacks that failed").register(registry);
}
Also used : StatisticsGateway(net.sf.ehcache.statistics.StatisticsGateway)

Example 3 with StatisticsGateway

use of net.sf.ehcache.statistics.StatisticsGateway in project micrometer by micrometer-metrics.

the class EhCache2Metrics method recoveryTransactionMetrics.

private void recoveryTransactionMetrics(MeterRegistry registry) {
    StatisticsGateway stats = getStats();
    FunctionCounter.builder("cache.xa.recoveries", stats, StatisticsGateway::xaRecoveryNothingCount).tags(getTagsWithCacheName()).tags("result", "nothing").description("Recovery transactions that recovered nothing").register(registry);
    FunctionCounter.builder("cache.xa.recoveries", stats, StatisticsGateway::xaRecoveryRecoveredCount).tags(getTagsWithCacheName()).tags("result", "success").description("Successful recovery transaction").register(registry);
}
Also used : StatisticsGateway(net.sf.ehcache.statistics.StatisticsGateway)

Example 4 with StatisticsGateway

use of net.sf.ehcache.statistics.StatisticsGateway in project micrometer by micrometer-metrics.

the class EhCache2MetricsTest method returnCacheSize.

@Test
void returnCacheSize() {
    StatisticsGateway stats = cache.getStatistics();
    assertThat(metrics.size()).isEqualTo(stats.getSize());
}
Also used : StatisticsGateway(net.sf.ehcache.statistics.StatisticsGateway) Test(org.junit.jupiter.api.Test) AbstractCacheMetricsTest(io.micrometer.core.instrument.binder.cache.AbstractCacheMetricsTest)

Example 5 with StatisticsGateway

use of net.sf.ehcache.statistics.StatisticsGateway in project micrometer by micrometer-metrics.

the class EhCache2MetricsTest method returnHitCount.

@Test
void returnHitCount() {
    StatisticsGateway stats = cache.getStatistics();
    assertThat(metrics.hitCount()).isEqualTo(stats.cacheHitCount());
}
Also used : StatisticsGateway(net.sf.ehcache.statistics.StatisticsGateway) Test(org.junit.jupiter.api.Test) AbstractCacheMetricsTest(io.micrometer.core.instrument.binder.cache.AbstractCacheMetricsTest)

Aggregations

StatisticsGateway (net.sf.ehcache.statistics.StatisticsGateway)30 Test (org.junit.jupiter.api.Test)12 AbstractCacheMetricsTest (io.micrometer.core.instrument.binder.cache.AbstractCacheMetricsTest)6 FunctionCounter (io.micrometer.core.instrument.FunctionCounter)2 Gauge (io.micrometer.core.instrument.Gauge)2 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)2 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)2 Random (java.util.Random)2 Ehcache (net.sf.ehcache.Ehcache)2 BeforeAll (org.junit.jupiter.api.BeforeAll)2 DecimalFormat (java.text.DecimalFormat)1 LinkedHashMap (java.util.LinkedHashMap)1 CacheManager (net.sf.ehcache.CacheManager)1 MetricsInitializer (nl.nn.adapterframework.statistics.MetricsInitializer)1 Cache (org.jahia.services.cache.Cache)1 CacheInfo (org.jahia.services.cache.ehcache.CacheInfo)1 EhCacheImpl (org.jahia.services.cache.ehcache.EhCacheImpl)1 SettingsBean (org.jahia.settings.SettingsBean)1 ThreadMonitor (org.jahia.tools.jvm.ThreadMonitor)1 RequestLoadAverage (org.jahia.utils.RequestLoadAverage)1