Search in sources :

Example 21 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 22 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);
    Closer closer = Closer.create();
    Whiteboard wb = new ClosingWhiteboard(options.getWhiteboard(), closer);
    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, emptyMap());
    NodeStore store;
    if (commonOpts.isMemory()) {
        store = new MemoryNodeStore();
    } else if (commonOpts.isMongo() || commonOpts.isRDB()) {
        DocumentNodeStore dns = DocumentFixtureProvider.configureDocumentMk(options, blobStore, wb, closer, readOnly);
        store = dns;
        if (blobStore == null) {
            blobStore = dns.getBlobStore();
        }
    } else if (commonOpts.isOldSegment()) {
        store = SegmentFixtureProvider.create(options, blobStore, wb, closer, readOnly);
    } else {
        try {
            store = SegmentTarFixtureProvider.configureSegment(options, blobStore, wb, closer, readOnly);
        } catch (InvalidFileStoreVersionException e) {
            if (oldSegmentStore(options)) {
                store = SegmentFixtureProvider.create(options, blobStore, wb, closer, readOnly);
            } else {
                throw e;
            }
        }
    }
    return new SimpleNodeStoreFixture(store, blobStore, wb, closer);
}
Also used : Closer(com.google.common.io.Closer) DocumentNodeStore(org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) InvalidFileStoreVersionException(org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException) DocumentNodeStore(org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore) 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 23 with StatisticsProvider

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

the class SegmentFixtureProvider method create.

static NodeStore create(Options options, BlobStore blobStore, Whiteboard wb, Closer closer, boolean readOnly) throws IOException, InvalidFileStoreVersionException {
    StatisticsProvider statisticsProvider = checkNotNull(getService(wb, StatisticsProvider.class));
    String path = options.getOptionBean(CommonOptions.class).getStoreArg();
    FileStore.Builder builder = FileStore.builder(new File(path)).withMaxFileSize(256).withDefaultMemoryMapping();
    FileStoreBuilderCustomizer customizer = getService(wb, FileStoreBuilderCustomizer.class);
    if (customizer != null) {
        customizer.customize(builder);
    }
    if (blobStore != null) {
        builder.withBlobStore(blobStore);
    }
    NodeStore nodeStore;
    if (readOnly) {
        FileStore.ReadOnlyStore fileStore = builder.withStatisticsProvider(statisticsProvider).buildReadOnly();
        closer.register(fileStore);
        nodeStore = SegmentNodeStore.builder(fileStore).build();
        wb.register(FileStore.ReadOnlyStore.class, fileStore, emptyMap());
    } else {
        FileStore fileStore = builder.withStatisticsProvider(statisticsProvider).build();
        closer.register(fileStore);
        nodeStore = SegmentNodeStore.builder(fileStore).build();
        wb.register(FileStore.class, fileStore, emptyMap());
    }
    return nodeStore;
}
Also used : FileStore(org.apache.jackrabbit.oak.plugins.segment.file.FileStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) SegmentNodeStore(org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider) File(java.io.File)

Example 24 with StatisticsProvider

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

the class SegmentTarFixtureProvider method configureSegment.

static NodeStore configureSegment(Options options, BlobStore blobStore, Whiteboard wb, Closer closer, boolean readOnly) throws IOException, InvalidFileStoreVersionException {
    StatisticsProvider statisticsProvider = checkNotNull(getService(wb, StatisticsProvider.class));
    String path = options.getOptionBean(CommonOptions.class).getStoreArg();
    FileStoreBuilder builder = fileStoreBuilder(new File(path)).withMaxFileSize(256);
    FileStoreTarBuilderCustomizer customizer = getService(wb, FileStoreTarBuilderCustomizer.class);
    if (customizer != null) {
        customizer.customize(builder);
    }
    if (blobStore != null) {
        builder.withBlobStore(blobStore);
    }
    NodeStore nodeStore;
    if (readOnly) {
        ReadOnlyFileStore fileStore = builder.withStatisticsProvider(statisticsProvider).buildReadOnly();
        closer.register(fileStore);
        nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
        wb.register(ReadOnlyFileStore.class, fileStore, emptyMap());
    } else {
        FileStore fileStore = builder.withStrictVersionCheck(true).withStatisticsProvider(statisticsProvider).build();
        closer.register(fileStore);
        nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
        wb.register(FileStore.class, fileStore, emptyMap());
    }
    return nodeStore;
}
Also used : ReadOnlyFileStore(org.apache.jackrabbit.oak.segment.file.ReadOnlyFileStore) FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) FileStoreBuilder(org.apache.jackrabbit.oak.segment.file.FileStoreBuilder) ReadOnlyFileStore(org.apache.jackrabbit.oak.segment.file.ReadOnlyFileStore) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider) File(java.io.File)

Example 25 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, String user, String password) 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(user, password.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)

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