Search in sources :

Example 1 with StatisticsProvider

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

the class JsonIndexCommand method openSession.

public static Session openSession(NodeStore nodeStore) throws RepositoryException {
    if (nodeStore == null) {
        return null;
    }
    StatisticsProvider statisticsProvider = StatisticsProvider.NOOP;
    Oak oak = new Oak(nodeStore).with(ManagementFactory.getPlatformMBeanServer());
    oak.getWhiteboard().register(StatisticsProvider.class, statisticsProvider, Collections.emptyMap());
    LuceneIndexProvider provider = createLuceneIndexProvider();
    oak.with((QueryIndexProvider) provider).with((Observer) provider).with(createLuceneIndexEditorProvider());
    Jcr jcr = new Jcr(oak);
    Repository repository = jcr.createRepository();
    return repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) Repository(javax.jcr.Repository) Observer(org.apache.jackrabbit.oak.spi.commit.Observer) Oak(org.apache.jackrabbit.oak.Oak) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) LuceneIndexProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider)

Example 2 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 3 with StatisticsProvider

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

the class CachingDataStoreTest method init.

private void init(int i, int cacheSize, int uploadSplit) throws Exception {
    LOG.info("Starting init");
    // create executor
    taskLatch = new CountDownLatch(1);
    callbackLatch = new CountDownLatch(1);
    afterExecuteLatch = new CountDownLatch(i);
    TestExecutor listeningExecutor = new TestExecutor(1, taskLatch, callbackLatch, afterExecuteLatch);
    // stats
    ScheduledExecutorService statsExecutor = Executors.newSingleThreadScheduledExecutor();
    closer.register(new ExecutorCloser(statsExecutor, 500, TimeUnit.MILLISECONDS));
    StatisticsProvider statsProvider = new DefaultStatisticsProvider(statsExecutor);
    scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
    closer.register(new ExecutorCloser(scheduledExecutor, 500, TimeUnit.MILLISECONDS));
    final File datastoreRoot = folder.newFolder();
    final TestMemoryBackend testBackend = new TestMemoryBackend(datastoreRoot);
    this.backend = testBackend;
    dataStore = new AbstractSharedCachingDataStore() {

        @Override
        protected AbstractSharedBackend createBackend() {
            return testBackend;
        }

        @Override
        public int getMinRecordLength() {
            return 0;
        }
    };
    dataStore.setStatisticsProvider(statsProvider);
    dataStore.setCacheSize(cacheSize);
    dataStore.setStagingSplitPercentage(uploadSplit);
    dataStore.listeningExecutor = listeningExecutor;
    dataStore.schedulerExecutor = scheduledExecutor;
    dataStore.executor = sameThreadExecutor();
    dataStore.init(root.getAbsolutePath());
    LOG.info("Finished init");
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) CountDownLatch(java.util.concurrent.CountDownLatch) ExecutorCloser(org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser) DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider) File(java.io.File) AbstractSharedBackend(org.apache.jackrabbit.oak.spi.blob.AbstractSharedBackend)

Example 4 with StatisticsProvider

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

the class RepositoryFactory method createRepository.

public Repository createRepository() throws IOException, InvalidFileStoreVersionException {
    createExecutor();
    if (SEGMENT_FILE_TYPE == storeType) {
        fileStore = FileStoreBuilder.fileStoreBuilder(repositoryPath.toFile()).build();
        nodeStore = // 
        SegmentNodeStoreBuilders.builder(fileStore).withStatisticsProvider(// 
        StatisticsProvider.NOOP).build();
    } else if (IN_MEMORY_TYPE == storeType) {
        nodeStore = null;
    } else {
        throw new IllegalArgumentException("Store type " + storeType + " not recognized");
    }
    Oak oak = nodeStore == null ? new Oak() : new Oak(nodeStore);
    oak.with(new RepositoryInitializer() {

        @Override
        public void initialize(@Nonnull NodeBuilder root) {
            log.info("Creating index ");
            NodeBuilder lucene = IndexUtils.getOrCreateOakIndex(root).child("lucene");
            lucene.setProperty(JcrConstants.JCR_PRIMARYTYPE, "oak:QueryIndexDefinition", Type.NAME);
            lucene.setProperty("compatVersion", 2);
            lucene.setProperty("type", "lucene");
            // lucene.setProperty("async", "async");
            lucene.setProperty(INCLUDE_PROPERTY_TYPES, ImmutableSet.of("String"), Type.STRINGS);
            // lucene.setProperty("refresh",true);
            lucene.setProperty("async", ImmutableSet.of("async", "sync"), Type.STRINGS);
            NodeBuilder rules = lucene.child("indexRules").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
            rules.setProperty(":childOrder", // 
            ImmutableSet.of(// 
            "archiva:projectVersion", // 
            "archiva:artifact", // 
            "archiva:facet", // 
            "archiva:namespace", // 
            "archiva:project"), Type.STRINGS);
            NodeBuilder allProps = // 
            rules.child("archiva:projectVersion").child(// 
            "properties").setProperty(JcrConstants.JCR_PRIMARYTYPE, "nt:unstructured", // 
            Type.NAME).setProperty(":childOrder", ImmutableSet.of("allProps"), // 
            Type.STRINGS).setProperty("indexNodeName", // 
            true).child(// 
            "allProps").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
            allProps.setProperty("name", ".*");
            allProps.setProperty("isRegexp", true);
            allProps.setProperty("nodeScopeIndex", true);
            allProps.setProperty("index", true);
            allProps.setProperty("analyzed", true);
            // allProps.setProperty("propertyIndex",true);
            allProps = // 
            rules.child("archiva:artifact").child(// 
            "properties").setProperty(JcrConstants.JCR_PRIMARYTYPE, "nt:unstructured", // 
            Type.NAME).setProperty(":childOrder", ImmutableSet.of("allProps"), // 
            Type.STRINGS).setProperty("indexNodeName", true).child(// 
            "allProps").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
            allProps.setProperty("name", ".*");
            allProps.setProperty("isRegexp", true);
            allProps.setProperty("nodeScopeIndex", true);
            allProps.setProperty("index", true);
            allProps.setProperty("analyzed", true);
            allProps = // 
            rules.child("archiva:facet").child(// 
            "properties").setProperty(JcrConstants.JCR_PRIMARYTYPE, "nt:unstructured", // 
            Type.NAME).setProperty(":childOrder", ImmutableSet.of("allProps"), // 
            Type.STRINGS).setProperty("indexNodeName", // 
            true).child(// 
            "allProps").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
            allProps.setProperty("name", ".*");
            allProps.setProperty("isRegexp", true);
            allProps.setProperty("nodeScopeIndex", true);
            allProps.setProperty("index", true);
            allProps.setProperty("analyzed", true);
            allProps = // 
            rules.child("archiva:namespace").child(// 
            "properties").setProperty(JcrConstants.JCR_PRIMARYTYPE, "nt:unstructured", // 
            Type.NAME).setProperty(":childOrder", ImmutableSet.of("allProps"), // 
            Type.STRINGS).setProperty("indexNodeName", // 
            true).child(// 
            "allProps").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
            allProps.setProperty("name", ".*");
            allProps.setProperty("isRegexp", true);
            allProps.setProperty("nodeScopeIndex", true);
            allProps.setProperty("index", true);
            allProps.setProperty("analyzed", true);
            allProps = // 
            rules.child("archiva:project").child(// 
            "properties").setProperty(JcrConstants.JCR_PRIMARYTYPE, "nt:unstructured", // 
            Type.NAME).setProperty(":childOrder", ImmutableSet.of("allProps"), // 
            Type.STRINGS).setProperty("indexNodeName", // 
            true).child(// 
            "allProps").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
            allProps.setProperty("name", ".*");
            allProps.setProperty("isRegexp", true);
            allProps.setProperty("nodeScopeIndex", true);
            allProps.setProperty("index", true);
            allProps.setProperty("analyzed", true);
            log.info("Index: {} myIndex {}", lucene, lucene.getChildNode("myIndex"));
            log.info("myIndex {}", lucene.getChildNode("myIndex").getProperties());
        // IndexUtils.createIndexDefinition(  )
        }
    });
    StatisticsProvider statsProvider = StatisticsProvider.NOOP;
    int queueSize = Integer.getInteger("queueSize", 10000);
    Path indexDir = Files.createTempDirectory("archiva_index");
    log.info("Queue Index {}", indexDir.toString());
    IndexCopier indexCopier = new IndexCopier(executorService, indexDir.toFile(), true);
    NRTIndexFactory nrtIndexFactory = new NRTIndexFactory(indexCopier, statsProvider);
    MountInfoProvider mountInfoProvider = Mounts.defaultMountInfoProvider();
    IndexTracker tracker = new IndexTracker(new DefaultIndexReaderFactory(mountInfoProvider, indexCopier), nrtIndexFactory);
    DocumentQueue queue = new DocumentQueue(queueSize, tracker, executorService, statsProvider);
    LocalIndexObserver localIndexObserver = new LocalIndexObserver(queue, statsProvider);
    LuceneIndexProvider provider = new LuceneIndexProvider(tracker);
    // ExternalObserverBuilder builder = new ExternalObserverBuilder(queue, tracker, statsProvider,
    // executorService, queueSize);
    // Observer observer = builder.build();
    // builder.getBackgroundObserver();
    // 
    LuceneIndexEditorProvider editorProvider = new // 
    LuceneIndexEditorProvider(// 
    null, // 
    tracker, // 
    new ExtractedTextCache(0, 0), null, mountInfoProvider);
    editorProvider.setIndexingQueue(queue);
    log.info("Oak: {} with nodeStore {}", oak, nodeStore);
    Jcr jcr = // 
    new Jcr(oak).with(editorProvider).with(// 
    (Observer) provider).with(localIndexObserver).with(// 
    (QueryIndexProvider) provider);
    // .withAsyncIndexing( "async", 5 );
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    Repository r = jcr.createRepository();
    stopWatch.stop();
    log.info("time to create jcr repository: {} ms", stopWatch.getTime());
    // }
    return r;
}
Also used : Path(java.nio.file.Path) IndexTracker(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker) DocumentQueue(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.DocumentQueue) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) IndexCopier(org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider) StopWatch(org.apache.commons.lang.time.StopWatch) ExtractedTextCache(org.apache.jackrabbit.oak.plugins.index.lucene.ExtractedTextCache) Repository(javax.jcr.Repository) LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) LocalIndexObserver(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.LocalIndexObserver) Oak(org.apache.jackrabbit.oak.Oak) NRTIndexFactory(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndexFactory) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) DefaultIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory) LuceneIndexProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider) RepositoryInitializer(org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)

Example 5 with StatisticsProvider

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

the class LuceneWritesOnSegmentStatsTest method createBlobStore.

private BlobStore createBlobStore() {
    FileDataStore fds = new OakFileDataStore();
    fdsDir = "target/fds-" + codec + copyOnRW + minRecordLength + mergePolicy;
    fds.setPath(fdsDir);
    if (minRecordLength > 0) {
        fds.setMinRecordLength(minRecordLength);
    }
    fds.init(null);
    dataStoreBlobStore = new DataStoreBlobStore(fds);
    StatisticsProvider sp = new DefaultStatisticsProvider(scheduledExecutorService);
    BlobStatsCollector collector = new BlobStoreStats(sp);
    dataStoreBlobStore.setBlobStatsCollector(collector);
    return dataStoreBlobStore;
}
Also used : OakFileDataStore(org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore) BlobStatsCollector(org.apache.jackrabbit.oak.spi.blob.stats.BlobStatsCollector) BlobStoreStats(org.apache.jackrabbit.oak.plugins.blob.BlobStoreStats) DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) FileDataStore(org.apache.jackrabbit.core.data.FileDataStore) OakFileDataStore(org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore) 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