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());
}
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")));
}
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);
}
}
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());
}
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());
}
Aggregations