Search in sources :

Example 6 with TimerStats

use of org.apache.jackrabbit.oak.stats.TimerStats in project jackrabbit-oak by apache.

the class MetricImplTest method timerContext.

@Test
public void timerContext() throws Exception {
    VirtualClock clock = new VirtualClock();
    Timer time = new Timer(new ExponentiallyDecayingReservoir(), clock);
    TimerStats timerStats = new TimerImpl(time);
    TimerStats.Context context = timerStats.time();
    clock.tick = TimeUnit.SECONDS.toNanos(314);
    context.close();
    assertEquals(1, time.getCount());
    assertEquals(TimeUnit.SECONDS.toNanos(314), time.getSnapshot().getMax());
}
Also used : ExponentiallyDecayingReservoir(com.codahale.metrics.ExponentiallyDecayingReservoir) Timer(com.codahale.metrics.Timer) TimerStats(org.apache.jackrabbit.oak.stats.TimerStats) Test(org.junit.Test)

Example 7 with TimerStats

use of org.apache.jackrabbit.oak.stats.TimerStats in project jackrabbit-oak by apache.

the class MetricStatisticsProviderTest method timer.

@Test
public void timer() throws Exception {
    TimerStats timerStats = statsProvider.getTimer("test", StatsOptions.DEFAULT);
    assertNotNull(timerStats);
    assertNotNull(statsProvider.getRegistry().getTimers().containsKey("test"));
    assertTrue(((CompositeStats) timerStats).isTimer());
}
Also used : TimerStats(org.apache.jackrabbit.oak.stats.TimerStats) Test(org.junit.Test)

Aggregations

TimerStats (org.apache.jackrabbit.oak.stats.TimerStats)7 Test (org.junit.Test)4 ExponentiallyDecayingReservoir (com.codahale.metrics.ExponentiallyDecayingReservoir)2 Timer (com.codahale.metrics.Timer)2 Stopwatch (com.google.common.base.Stopwatch)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 ObjectName (javax.management.ObjectName)1 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)1 AbstractDocumentNodeState (org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState)1 ApplyDiff (org.apache.jackrabbit.oak.spi.state.ApplyDiff)1 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)1 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)1