use of org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider in project jackrabbit-oak by apache.
the class BenchmarkRunner method reportMetrics.
private static void reportMetrics(StatisticsProvider statsProvider) {
if (statsProvider instanceof MetricStatisticsProvider) {
MetricRegistry metricRegistry = ((MetricStatisticsProvider) statsProvider).getRegistry();
ConsoleReporter.forRegistry(metricRegistry).outputTo(System.out).filter(new MetricFilter() {
@Override
public boolean matches(String name, Metric metric) {
if (metric instanceof Counting) {
//Only report non zero metrics
return ((Counting) metric).getCount() > 0;
}
return true;
}
}).build().report();
}
}
use of org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider in project jackrabbit-oak by apache.
the class OutOfBandIndexer method configureEstimators.
private void configureEstimators(IndexUpdate indexUpdate) {
StatisticsProvider statsProvider = indexHelper.getStatisticsProvider();
if (statsProvider instanceof MetricStatisticsProvider) {
MetricRegistry registry = ((MetricStatisticsProvider) statsProvider).getRegistry();
indexUpdate.setTraversalRateEstimator(new MetricRateEstimator(REINDEX_LANE, registry));
}
NodeCounterMBeanEstimator estimator = new NodeCounterMBeanEstimator(indexHelper.getNodeStore());
indexUpdate.setNodeCountEstimator(estimator);
}
use of org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider in project jackrabbit-oak by apache.
the class SegmentCompactionIT method setUp.
@Before
public void setUp() throws Exception {
assumeTrue(ENABLED);
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
MetricStatisticsProvider statisticsProvider = new MetricStatisticsProvider(mBeanServer, executor);
SegmentGCOptions gcOptions = defaultGCOptions().setEstimationDisabled(true).setForceTimeout(3600);
FileStoreBuilder builder = fileStoreBuilder(folder.getRoot());
fileStore = builder.withMemoryMapping(true).withGCMonitor(gcMonitor).withGCOptions(gcOptions).withIOMonitor(new MetricsIOMonitor(statisticsProvider)).withStatisticsProvider(statisticsProvider).build();
nodeStore = SegmentNodeStoreBuilders.builder(fileStore).withStatisticsProvider(statisticsProvider).build();
WriterCacheManager cacheManager = builder.getCacheManager();
Runnable cancelGC = new Runnable() {
@Override
public void run() {
fileStore.cancelGC();
}
};
Supplier<String> status = new Supplier<String>() {
@Override
public String get() {
return fileStoreGCMonitor.getStatus();
}
};
List<Registration> registrations = newArrayList();
registrations.add(registerMBean(segmentCompactionMBean, new ObjectName("IT:TYPE=Segment Compaction")));
registrations.add(registerMBean(new SegmentRevisionGCMBean(fileStore, gcOptions, fileStoreGCMonitor), new ObjectName("IT:TYPE=Segment Revision GC")));
registrations.add(registerMBean(new RevisionGC(fileStore.getGCRunner(), cancelGC, status, executor), new ObjectName("IT:TYPE=Revision GC")));
CacheStatsMBean segmentCacheStats = fileStore.getSegmentCacheStats();
registrations.add(registerMBean(segmentCacheStats, new ObjectName("IT:TYPE=" + segmentCacheStats.getName())));
CacheStatsMBean stringCacheStats = fileStore.getStringCacheStats();
registrations.add(registerMBean(stringCacheStats, new ObjectName("IT:TYPE=" + stringCacheStats.getName())));
CacheStatsMBean templateCacheStats = fileStore.getTemplateCacheStats();
registrations.add(registerMBean(templateCacheStats, new ObjectName("IT:TYPE=" + templateCacheStats.getName())));
CacheStatsMBean stringDeduplicationCacheStats = cacheManager.getStringCacheStats();
assertNotNull(stringDeduplicationCacheStats);
registrations.add(registerMBean(stringDeduplicationCacheStats, new ObjectName("IT:TYPE=" + stringDeduplicationCacheStats.getName())));
CacheStatsMBean templateDeduplicationCacheStats = cacheManager.getTemplateCacheStats();
assertNotNull(templateDeduplicationCacheStats);
registrations.add(registerMBean(templateDeduplicationCacheStats, new ObjectName("IT:TYPE=" + templateDeduplicationCacheStats.getName())));
CacheStatsMBean nodeDeduplicationCacheStats = cacheManager.getNodeCacheStats();
assertNotNull(nodeDeduplicationCacheStats);
registrations.add(registerMBean(nodeDeduplicationCacheStats, new ObjectName("IT:TYPE=" + nodeDeduplicationCacheStats.getName())));
registrations.add(registerMBean(nodeStore.getStats(), new ObjectName("IT:TYPE=" + "SegmentNodeStore statistics")));
mBeanRegistration = new CompositeRegistration(registrations);
}
use of org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider in project jackrabbit-oak by apache.
the class AsyncIndexUpdate method configureRateEstimator.
private void configureRateEstimator(IndexUpdate indexUpdate) {
//As metrics is an optional library guard the access with the check
if (statisticsProvider.getClass().getSimpleName().equals("MetricStatisticsProvider")) {
MetricRegistry registry = ((MetricStatisticsProvider) statisticsProvider).getRegistry();
indexUpdate.setTraversalRateEstimator(new MetricRateEstimator(name, registry));
}
NodeCounterMBeanEstimator estimator = new NodeCounterMBeanEstimator(store);
indexUpdate.setNodeCountEstimator(estimator);
}
use of org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider in project jackrabbit-oak by apache.
the class NodeStoreFixtureProvider method createStatsProvider.
private static StatisticsProvider createStatsProvider(Options options, Whiteboard wb, Closer closer) {
if (options.getCommonOpts().isMetricsEnabled()) {
ScheduledExecutorService executorService = MoreExecutors.getExitingScheduledExecutorService(new ScheduledThreadPoolExecutor(1));
MetricStatisticsProvider statsProvider = new MetricStatisticsProvider(getPlatformMBeanServer(), executorService);
closer.register(statsProvider);
closer.register(() -> reportMetrics(statsProvider));
wb.register(MetricRegistry.class, statsProvider.getRegistry(), Collections.emptyMap());
return statsProvider;
}
return StatisticsProvider.NOOP;
}
Aggregations