Search in sources :

Example 11 with StatisticsProvider

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

the class FileStoreStatsTest method testJournalWriteStats.

@Test
public void testJournalWriteStats() throws Exception {
    StatisticsProvider statsProvider = new DefaultStatisticsProvider(executor);
    FileStore fileStore = fileStoreBuilder(segmentFolder.newFolder()).withStatisticsProvider(statsProvider).build();
    FileStoreStats stats = new FileStoreStats(statsProvider, fileStore, 0);
    SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
    for (int i = 0; i < 10; i++) {
        NodeBuilder root = nodeStore.getRoot().builder();
        root.setProperty("count", i);
        nodeStore.merge(root, EmptyHook.INSTANCE, CommitInfo.EMPTY);
        fileStore.flush();
    }
    assertEquals(10, stats.getJournalWriteStatsAsCount());
}
Also used : DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider) Test(org.junit.Test)

Example 12 with StatisticsProvider

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

the class NodeStoreFixtureProvider method create.

public static NodeStoreFixture create(Options options, boolean readOnly) throws Exception {
    CommonOptions commonOpts = options.getOptionBean(CommonOptions.class);
    Whiteboard wb = options.getWhiteboard();
    Closer closer = Closer.create();
    BlobStoreFixture blobFixture = BlobStoreFixtureProvider.create(options);
    BlobStore blobStore = null;
    if (blobFixture != null) {
        blobStore = blobFixture.getBlobStore();
        closer.register(blobFixture);
    }
    StatisticsProvider statisticsProvider = createStatsProvider(options, wb, closer);
    wb.register(StatisticsProvider.class, statisticsProvider, Collections.emptyMap());
    NodeStore store;
    if (commonOpts.isMongo() || commonOpts.isRDB()) {
        store = configureDocumentMk(options, blobStore, statisticsProvider, closer, wb, readOnly);
    } else {
        store = configureSegment(options, blobStore, statisticsProvider, closer, readOnly);
    }
    return new SimpleNodeStoreFixture(store, blobStore, wb, closer);
}
Also used : Closer(com.google.common.io.Closer) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MetricStatisticsProvider(org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) BlobStore(org.apache.jackrabbit.oak.spi.blob.BlobStore)

Example 13 with StatisticsProvider

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

the class JsonIndexCommand method createLuceneIndexEditorProvider.

private static LuceneIndexEditorProvider createLuceneIndexEditorProvider() {
    LuceneIndexEditorProvider ep = new LuceneIndexEditorProvider();
    ScheduledExecutorService executorService = MoreExecutors.getExitingScheduledExecutorService((ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(5));
    StatisticsProvider statsProvider = StatisticsProvider.NOOP;
    int queueSize = Integer.getInteger("queueSize", 1000);
    IndexTracker tracker = new IndexTracker();
    DocumentQueue queue = new DocumentQueue(queueSize, tracker, executorService, statsProvider);
    ep.setIndexingQueue(queue);
    return ep;
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) IndexTracker(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker) DocumentQueue(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.DocumentQueue) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider)

Example 14 with StatisticsProvider

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

the class CompactionAndCleanupIT method concurrentWritesCleanupZeroReclaimedSize.

@Test
public void concurrentWritesCleanupZeroReclaimedSize() throws Exception {
    ScheduledExecutorService scheduler = newSingleThreadScheduledExecutor();
    StatisticsProvider statsProvider = new DefaultStatisticsProvider(scheduler);
    final FileStoreGCMonitor fileStoreGCMonitor = new FileStoreGCMonitor(Clock.SIMPLE);
    final FileStore fileStore = fileStoreBuilder(getFileStoreFolder()).withGCOptions(defaultGCOptions().setRetainedGenerations(2)).withGCMonitor(fileStoreGCMonitor).withStatisticsProvider(statsProvider).withMaxFileSize(1).withMemoryMapping(false).build();
    final SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
    ExecutorService executorService = newFixedThreadPool(100);
    final AtomicInteger counter = new AtomicInteger();
    try {
        Callable<Void> concurrentWriteTask = new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                NodeBuilder builder = nodeStore.getRoot().builder();
                builder.setProperty("blob-" + counter.getAndIncrement(), createBlob(nodeStore, 25 * 25));
                nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
                fileStore.flush();
                return null;
            }
        };
        List<Future<?>> results = newArrayList();
        for (int i = 0; i < 100; i++) {
            results.add(executorService.submit(concurrentWriteTask));
        }
        Thread.sleep(100);
        fileStore.cleanup();
        for (Future<?> result : results) {
            assertNull(result.get());
        }
        long reclaimedSize = fileStoreGCMonitor.getLastReclaimedSize();
        assertEquals("Reclaimed size expected is 0, but instead was: " + reclaimedSize, 0, reclaimedSize);
    } finally {
        new ExecutorCloser(executorService).close();
        fileStore.close();
        new ExecutorCloser(scheduler).close();
    }
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) FileStoreGCMonitor(org.apache.jackrabbit.oak.segment.file.FileStoreGCMonitor) DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider) Callable(java.util.concurrent.Callable) FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ExecutorService(java.util.concurrent.ExecutorService) Future(java.util.concurrent.Future) ExecutorCloser(org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser) Test(org.junit.Test)

Aggregations

StatisticsProvider (org.apache.jackrabbit.oak.stats.StatisticsProvider)14 DefaultStatisticsProvider (org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider)6 File (java.io.File)4 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)4 Test (org.junit.Test)4 Oak (org.apache.jackrabbit.oak.Oak)3 ExecutorCloser (org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser)3 MetricStatisticsProvider (org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider)3 Closer (com.google.common.io.Closer)2 Callable (java.util.concurrent.Callable)2 ExecutorService (java.util.concurrent.ExecutorService)2 Future (java.util.concurrent.Future)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 OptionParser (joptsimple.OptionParser)2 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 PrintStream (java.io.PrintStream)1 UnknownHostException (java.net.UnknownHostException)1 UUID (java.util.UUID)1 CountDownLatch (java.util.concurrent.CountDownLatch)1