Search in sources :

Example 1 with MetricStatisticsProvider

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();
    }
}
Also used : MetricFilter(com.codahale.metrics.MetricFilter) MetricRegistry(com.codahale.metrics.MetricRegistry) MetricStatisticsProvider(org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider) Metric(com.codahale.metrics.Metric) Counting(com.codahale.metrics.Counting)

Example 2 with MetricStatisticsProvider

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);
}
Also used : MetricRegistry(com.codahale.metrics.MetricRegistry) MetricRateEstimator(org.apache.jackrabbit.oak.plugins.index.progress.MetricRateEstimator) MetricStatisticsProvider(org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider) MetricStatisticsProvider(org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider) NodeCounterMBeanEstimator(org.apache.jackrabbit.oak.plugins.index.progress.NodeCounterMBeanEstimator)

Example 3 with MetricStatisticsProvider

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);
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ListeningScheduledExecutorService(com.google.common.util.concurrent.ListeningScheduledExecutorService) SegmentGCOptions(org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions) MetricsIOMonitor(org.apache.jackrabbit.oak.segment.file.MetricsIOMonitor) ObjectName(javax.management.ObjectName) RevisionGC(org.apache.jackrabbit.oak.spi.state.RevisionGC) SegmentRevisionGC(org.apache.jackrabbit.oak.segment.compaction.SegmentRevisionGC) SegmentRevisionGCMBean(org.apache.jackrabbit.oak.segment.compaction.SegmentRevisionGCMBean) FileStoreBuilder(org.apache.jackrabbit.oak.segment.file.FileStoreBuilder) CompositeRegistration(org.apache.jackrabbit.oak.spi.whiteboard.CompositeRegistration) Registration(org.apache.jackrabbit.oak.spi.whiteboard.Registration) CacheStatsMBean(org.apache.jackrabbit.oak.api.jmx.CacheStatsMBean) MetricStatisticsProvider(org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider) Supplier(com.google.common.base.Supplier) CompositeRegistration(org.apache.jackrabbit.oak.spi.whiteboard.CompositeRegistration) Before(org.junit.Before)

Example 4 with MetricStatisticsProvider

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);
}
Also used : MetricRegistry(com.codahale.metrics.MetricRegistry) MetricRateEstimator(org.apache.jackrabbit.oak.plugins.index.progress.MetricRateEstimator) MetricStatisticsProvider(org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider) NodeCounterMBeanEstimator(org.apache.jackrabbit.oak.plugins.index.progress.NodeCounterMBeanEstimator)

Example 5 with MetricStatisticsProvider

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;
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) MetricStatisticsProvider(org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider)

Aggregations

MetricStatisticsProvider (org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider)5 MetricRegistry (com.codahale.metrics.MetricRegistry)3 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 MetricRateEstimator (org.apache.jackrabbit.oak.plugins.index.progress.MetricRateEstimator)2 NodeCounterMBeanEstimator (org.apache.jackrabbit.oak.plugins.index.progress.NodeCounterMBeanEstimator)2 Counting (com.codahale.metrics.Counting)1 Metric (com.codahale.metrics.Metric)1 MetricFilter (com.codahale.metrics.MetricFilter)1 Supplier (com.google.common.base.Supplier)1 ListeningScheduledExecutorService (com.google.common.util.concurrent.ListeningScheduledExecutorService)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 ObjectName (javax.management.ObjectName)1 CacheStatsMBean (org.apache.jackrabbit.oak.api.jmx.CacheStatsMBean)1 SegmentGCOptions (org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions)1 SegmentRevisionGC (org.apache.jackrabbit.oak.segment.compaction.SegmentRevisionGC)1 SegmentRevisionGCMBean (org.apache.jackrabbit.oak.segment.compaction.SegmentRevisionGCMBean)1 FileStoreBuilder (org.apache.jackrabbit.oak.segment.file.FileStoreBuilder)1 MetricsIOMonitor (org.apache.jackrabbit.oak.segment.file.MetricsIOMonitor)1 RevisionGC (org.apache.jackrabbit.oak.spi.state.RevisionGC)1 CompositeRegistration (org.apache.jackrabbit.oak.spi.whiteboard.CompositeRegistration)1