Search in sources :

Example 1 with TimerStats

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

the class CompositeStatsTest method timerContext.

@Test
public void timerContext() throws Exception {
    AtomicLong counter = new AtomicLong();
    VirtualClock clock = new VirtualClock();
    Timer time = new Timer(new ExponentiallyDecayingReservoir(), clock);
    TimerStats timerStats = new CompositeStats(counter, time);
    TimerStats.Context context = timerStats.time();
    clock.tick = TimeUnit.SECONDS.toNanos(314);
    context.close();
    assertEquals(1, time.getCount());
    assertEquals(TimeUnit.SECONDS.toMillis(314), counter.get());
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) ExponentiallyDecayingReservoir(com.codahale.metrics.ExponentiallyDecayingReservoir) Timer(com.codahale.metrics.Timer) TimerStats(org.apache.jackrabbit.oak.stats.TimerStats) Test(org.junit.Test)

Example 2 with TimerStats

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

the class MetricStatisticsProviderTest method jmxNaming.

@Test
public void jmxNaming() throws Exception {
    TimerStats timerStats = statsProvider.getTimer("hello", StatsOptions.DEFAULT);
    assertNotNull(server.getObjectInstance(new ObjectName("org.apache.jackrabbit.oak:type=Metrics,name=hello")));
}
Also used : TimerStats(org.apache.jackrabbit.oak.stats.TimerStats) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 3 with TimerStats

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

the class SecondaryStoreObserver method contentChanged.

@Override
public void contentChanged(@Nonnull NodeState root, @Nonnull CommitInfo info) {
    // diffManyChildren might pose problem for e.g. data under uuid index
    if (!firstEventProcessed) {
        log.info("Starting initial sync");
    }
    Stopwatch w = Stopwatch.createStarted();
    AbstractDocumentNodeState target = (AbstractDocumentNodeState) root;
    NodeState secondaryRoot = nodeStore.getRoot();
    NodeState base = DelegatingDocumentNodeState.wrapIfPossible(secondaryRoot, differ);
    NodeBuilder builder = secondaryRoot.builder();
    ApplyDiff diff = new PathFilteringDiff(builder, pathFilter, metaPropNames, target);
    // Copy the root node meta properties
    PathFilteringDiff.copyMetaProperties(target, builder, metaPropNames);
    // Apply the rest of properties
    target.compareAgainstBaseState(base, diff);
    try {
        NodeState updatedSecondaryRoot = nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
        secondaryObserver.contentChanged(DelegatingDocumentNodeState.wrap(updatedSecondaryRoot, differ));
        TimerStats timer = info.isExternal() ? external : local;
        timer.update(w.elapsed(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);
        if (!firstEventProcessed) {
            log.info("Time taken for initial sync {}", w);
            firstEventProcessed = true;
        }
    } catch (CommitFailedException e) {
        // TODO
        log.warn("Commit to secondary store failed", e);
    }
}
Also used : ApplyDiff(org.apache.jackrabbit.oak.spi.state.ApplyDiff) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) AbstractDocumentNodeState(org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState) Stopwatch(com.google.common.base.Stopwatch) AbstractDocumentNodeState(org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState) TimerStats(org.apache.jackrabbit.oak.stats.TimerStats) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) CommitFailedException(org.apache.jackrabbit.oak.api.CommitFailedException)

Example 4 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 5 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