use of org.apache.jackrabbit.oak.stats.MeterStats in project jackrabbit-oak by apache.
the class MetricStatisticsProviderTest method concurrentAccess.
@Test
public void concurrentAccess() throws Exception {
//Queue is used to collect instances with minimal overhead in concurrent scenario
final Queue<MeterStats> statsQueue = new ConcurrentLinkedDeque<MeterStats>();
List<Thread> threads = Lists.newArrayList();
int numWorker = 5;
final CountDownLatch latch = new CountDownLatch(1);
for (int i = 0; i < numWorker; i++) {
threads.add(new Thread(new Runnable() {
@Override
public void run() {
Uninterruptibles.awaitUninterruptibly(latch);
statsQueue.add(statsProvider.getMeter("foo", StatsOptions.DEFAULT));
}
}));
}
for (Thread t : threads) {
t.start();
}
latch.countDown();
for (Thread t : threads) {
t.join();
}
//Assert that we get same reference for every call
Set<MeterStats> statsSet = Sets.newIdentityHashSet();
for (MeterStats m : statsQueue) {
statsSet.add(m);
}
assertEquals(1, statsSet.size());
}
use of org.apache.jackrabbit.oak.stats.MeterStats in project jackrabbit-oak by apache.
the class MetricStatisticsProviderTest method meter.
@Test
public void meter() throws Exception {
MeterStats meterStats = statsProvider.getMeter("test", StatsOptions.DEFAULT);
assertNotNull(meterStats);
assertNotNull(statsProvider.getRegistry().getMeters().containsKey("test"));
assertTrue(((CompositeStats) meterStats).isMeter());
}
use of org.apache.jackrabbit.oak.stats.MeterStats in project jackrabbit-oak by apache.
the class MetricStatisticsProviderTest method timeSeriesIntegration.
@Test
public void timeSeriesIntegration() throws Exception {
MeterStats meterStats = statsProvider.getMeter(Type.SESSION_COUNT.name(), StatsOptions.DEFAULT);
meterStats.mark(5);
assertEquals(5, statsProvider.getRepoStats().getCounter(Type.SESSION_COUNT).get());
}
Aggregations