Search in sources :

Example 16 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 17 with StatisticsProvider

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

the class CacheAccessTrackerTest method setup.

@Before
public void setup() {
    ScheduledExecutorService scheduler = newScheduledThreadPool(1);
    StatisticsProvider statistics = new DefaultStatisticsProvider(scheduler);
    cache = new CacheAccessTracker<String, RecordId>("foo", statistics, newRecordCache(100));
    closer = new ExecutorCloser(scheduler);
    accessStats = statistics.getMeter("foo.access-count", StatsOptions.DEFAULT);
    missStats = statistics.getMeter("foo.miss-count", StatsOptions.DEFAULT);
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider) ExecutorCloser(org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser) Before(org.junit.Before)

Example 18 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)

Example 19 with StatisticsProvider

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

the class LockBasedSchedulerCheckpointTest method testLongWait.

/**
 * OAK-3587 test simulates a wait less than configured
 * {@code SegmentNodeStore#setCheckpointsLockWaitTime(int)} value so the
 * checkpoint call must return a valid value
 */
@Test
public void testLongWait() throws Exception {
    final int blockTime = 1;
    MemoryStore ms = new MemoryStore();
    System.setProperty("oak.checkpoints.lockWaitTime", "2");
    StatisticsProvider statsProvider = StatisticsProvider.NOOP;
    SegmentNodeStoreStats stats = new SegmentNodeStoreStats(statsProvider);
    final LockBasedScheduler scheduler = LockBasedScheduler.builder(ms.getRevisions(), ms.getReader(), stats).build();
    final Semaphore semaphore = new Semaphore(0);
    final Callable<Boolean> block = new Callable<Boolean>() {

        @Override
        public Boolean call() {
            try {
                semaphore.release();
                SECONDS.sleep(blockTime);
            } catch (InterruptedException e) {
            // 
            }
            return true;
        }
    };
    Thread background = new Thread() {

        @Override
        public void run() {
            try {
                Commit commit = createBlockingCommit(scheduler, "foo", "bar", block);
                scheduler.schedule(commit);
            } catch (Exception e) {
            // 
            }
        }
    };
    background.start();
    semaphore.acquire();
    String cp0 = scheduler.checkpoint(10, Collections.<String, String>emptyMap());
    assertNotNull(retrieveCheckpoint(scheduler, cp0));
}
Also used : SegmentNodeStoreStats(org.apache.jackrabbit.oak.segment.SegmentNodeStoreStats) Semaphore(java.util.concurrent.Semaphore) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider) Callable(java.util.concurrent.Callable) MemoryStore(org.apache.jackrabbit.oak.segment.memory.MemoryStore) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Test(org.junit.Test)

Example 20 with StatisticsProvider

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

the class S3DataStoreFactory method create.

@Override
public BlobStore create(Closer closer) throws IOException {
    S3DataStore delegate = createDS(directory, props);
    // Initialize a default stats provider
    final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
    StatisticsProvider statsProvider = new DefaultStatisticsProvider(executor);
    delegate.setStatisticsProvider(statsProvider);
    // Reduce staging purge interval to 60 seconds
    delegate.setStagingPurgeInterval(60);
    try {
        delegate.init(tempHomeDir.getPath());
    } catch (RepositoryException e) {
        throw new IOException(e);
    }
    closer.register(asCloseable(delegate));
    closer.register(new Closeable() {

        @Override
        public void close() throws IOException {
            executor.shutdown();
            try {
                if (!executor.awaitTermination(30, TimeUnit.SECONDS)) {
                    throw new IOException("Can't shut down the executor");
                }
            } catch (InterruptedException e) {
                throw new IOException(e);
            }
        }
    });
    if (ignoreMissingBlobs) {
        return new SafeDataStoreBlobStore(delegate);
    } else {
        return new DataStoreBlobStore(delegate);
    }
}
Also used : S3DataStore(org.apache.jackrabbit.oak.blob.cloud.s3.S3DataStore) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Closeable(java.io.Closeable) DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) RepositoryException(javax.jcr.RepositoryException) IOException(java.io.IOException) DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)

Aggregations

StatisticsProvider (org.apache.jackrabbit.oak.stats.StatisticsProvider)25 DefaultStatisticsProvider (org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider)9 Test (org.junit.Test)8 File (java.io.File)6 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)6 Callable (java.util.concurrent.Callable)5 Oak (org.apache.jackrabbit.oak.Oak)5 ExecutorCloser (org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser)5 MetricStatisticsProvider (org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider)4 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)4 ExecutorService (java.util.concurrent.ExecutorService)3 Future (java.util.concurrent.Future)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Repository (javax.jcr.Repository)3 Jcr (org.apache.jackrabbit.oak.jcr.Jcr)3 DocumentNodeStore (org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore)3 LuceneIndexProvider (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider)3 SegmentNodeStoreStats (org.apache.jackrabbit.oak.segment.SegmentNodeStoreStats)3 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)3 MetricRegistry (com.codahale.metrics.MetricRegistry)2