Search in sources :

Example 6 with StatisticsProvider

use of org.apache.jackrabbit.oak.stats.StatisticsProvider 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 7 with StatisticsProvider

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

the class CompactionAndCleanupIT method concurrentWritesCleanupNoNewGen.

/**
     * Test asserting OAK-4669: No new generation of tar should be created when the segments are the same 
     * and when various indices are created. 
     */
@Test
public void concurrentWritesCleanupNoNewGen() throws Exception {
    ScheduledExecutorService scheduler = newSingleThreadScheduledExecutor();
    StatisticsProvider statsProvider = new DefaultStatisticsProvider(scheduler);
    final FileStoreGCMonitor fileStoreGCMonitor = new FileStoreGCMonitor(Clock.SIMPLE);
    File fileStoreFolder = getFileStoreFolder();
    final FileStore fileStore = fileStoreBuilder(fileStoreFolder).withGCOptions(defaultGCOptions().setRetainedGenerations(2)).withGCMonitor(fileStoreGCMonitor).withStatisticsProvider(statsProvider).withMaxFileSize(1).withMemoryMapping(false).build();
    final SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
    ExecutorService executorService = newFixedThreadPool(5);
    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, 512 * 512));
                nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
                fileStore.flush();
                return null;
            }
        };
        List<Future<?>> results = newArrayList();
        for (int i = 0; i < 5; i++) {
            results.add(executorService.submit(concurrentWriteTask));
        }
        for (Future<?> result : results) {
            assertNull(result.get());
        }
        fileStore.cleanup();
        for (String fileName : fileStoreFolder.list()) {
            if (fileName.endsWith(".tar")) {
                int pos = fileName.length() - "a.tar".length();
                char generation = fileName.charAt(pos);
                assertTrue("Expected generation is 'a', but instead was: '" + generation + "' for file " + fileName, generation == 'a');
            }
        }
    } 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) File(java.io.File) ExecutorCloser(org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser) Test(org.junit.Test)

Example 8 with StatisticsProvider

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

the class OakFixture method getMemory.

public static OakFixture getMemory(String name, final long cacheSize) {
    return new OakFixture(name) {

        @Override
        public Oak getOak(int clusterId) throws Exception {
            Oak oak;
            oak = newOak(new MemoryNodeStore());
            return oak;
        }

        @Override
        public Oak[] setUpCluster(int n, StatisticsProvider statsProvider) throws Exception {
            Oak[] cluster = new Oak[n];
            for (int i = 0; i < cluster.length; i++) {
                Oak oak;
                oak = newOak(new MemoryNodeStore());
                cluster[i] = oak;
            }
            return cluster;
        }

        @Override
        public void tearDownCluster() {
        // nothing to do
        }
    };
}
Also used : MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) Oak(org.apache.jackrabbit.oak.Oak) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider)

Example 9 with StatisticsProvider

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

the class FileStoreStatsTest method tarWriterIntegration.

@Test
public void tarWriterIntegration() throws Exception {
    StatisticsProvider statsProvider = new DefaultStatisticsProvider(executor);
    File directory = segmentFolder.newFolder();
    FileStore store = fileStoreBuilder(directory).withStatisticsProvider(statsProvider).build();
    FileStoreStats stats = new FileStoreStats(statsProvider, store, 0);
    try {
        long initialSize = stats.getApproximateSize();
        UUID id = UUID.randomUUID();
        long msb = id.getMostSignificantBits();
        // OAK-1672
        long lsb = id.getLeastSignificantBits() & (-1 >>> 4);
        byte[] data = "Hello, World!".getBytes(UTF_8);
        try (TarWriter writer = new TarWriter(directory, stats, 0, new IOMonitorAdapter())) {
            writer.writeEntry(msb, lsb, data, 0, data.length, 0);
            assertEquals(stats.getApproximateSize() - initialSize, writer.fileLength());
        }
    } finally {
        store.close();
    }
    assertEquals(1, stats.getJournalWriteStatsAsCount());
}
Also used : DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) UUID(java.util.UUID) DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider) File(java.io.File) Test(org.junit.Test)

Example 10 with StatisticsProvider

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

the class FileStoreStatsTest method initCall.

@Test
public void initCall() throws Exception {
    FileStore store = mock(FileStore.class);
    StatisticsProvider statsProvider = new DefaultStatisticsProvider(executor);
    FileStoreStats stats = new FileStoreStats(statsProvider, store, 1000);
    assertEquals(1000, stats.getApproximateSize());
    stats.written(500);
    assertEquals(1500, stats.getApproximateSize());
    stats.reclaimed(250);
    assertEquals(1250, stats.getApproximateSize());
    assertEquals(1, stats.getTarFileCount());
}
Also used : DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider) 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