Search in sources :

Example 11 with LuceneIndexProvider

use of org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider in project jackrabbit-oak by apache.

the class HybridIndexTest method prepareLuceneIndexer.

private void prepareLuceneIndexer(File workDir) {
    try {
        indexCopierDir = createTemporaryFolderIn(workDir);
        copier = new IndexCopier(executorService, indexCopierDir, true);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    nrtIndexFactory = new NRTIndexFactory(copier, Clock.SIMPLE, TimeUnit.MILLISECONDS.toSeconds(refreshDeltaMillis), StatisticsProvider.NOOP);
    MountInfoProvider mip = Mounts.defaultMountInfoProvider();
    LuceneIndexReaderFactory indexReaderFactory = new DefaultIndexReaderFactory(mip, copier);
    IndexTracker tracker = new IndexTracker(indexReaderFactory, nrtIndexFactory);
    luceneIndexProvider = new LuceneIndexProvider(tracker);
    luceneEditorProvider = new LuceneIndexEditorProvider(copier, tracker, //extractedTextCache
    null, //augmentorFactory
    null, mip);
    queue = new DocumentQueue(queueSize, tracker, executorService, statsProvider);
    localIndexObserver = new LocalIndexObserver(queue, statsProvider);
    luceneEditorProvider.setIndexingQueue(queue);
}
Also used : LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) IndexTracker(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker) LocalIndexObserver(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.LocalIndexObserver) NRTIndexFactory(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndexFactory) DefaultIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory) DocumentQueue(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.DocumentQueue) IOException(java.io.IOException) LuceneIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory) LuceneIndexProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider) IndexCopier(org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)

Example 12 with LuceneIndexProvider

use of org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider in project jackrabbit-oak by apache.

the class HybridIndexTest method createRepository.

@Override
protected ContentRepository createRepository() {
    IndexCopier copier;
    try {
        copier = new IndexCopier(executorService, temporaryFolder.getRoot());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    MountInfoProvider mip = defaultMountInfoProvider();
    nrtIndexFactory = new NRTIndexFactory(copier, clock, TimeUnit.MILLISECONDS.toSeconds(refreshDelta), StatisticsProvider.NOOP);
    nrtIndexFactory.setAssertAllResourcesClosed(true);
    LuceneIndexReaderFactory indexReaderFactory = new DefaultIndexReaderFactory(mip, copier);
    IndexTracker tracker = new IndexTracker(indexReaderFactory, nrtIndexFactory);
    luceneIndexProvider = new LuceneIndexProvider(tracker);
    queue = new DocumentQueue(100, tracker, sameThreadExecutor());
    LuceneIndexEditorProvider editorProvider = new LuceneIndexEditorProvider(copier, tracker, null, null, mip);
    editorProvider.setIndexingQueue(queue);
    LocalIndexObserver localIndexObserver = new LocalIndexObserver(queue, StatisticsProvider.NOOP);
    nodeStore = new MemoryNodeStore();
    Oak oak = new Oak(nodeStore).with(new InitialContent()).with(new OpenSecurityProvider()).with((QueryIndexProvider) luceneIndexProvider).with((Observer) luceneIndexProvider).with(localIndexObserver).with(editorProvider).with(new PropertyIndexEditorProvider()).with(new NodeTypeIndexProvider()).with(optionalEditorProvider).with(new NodeCounterEditorProvider()).withAsyncIndexing("async", TimeUnit.DAYS.toSeconds(1));
    wb = oak.getWhiteboard();
    return oak.createContentRepository();
}
Also used : NodeTypeIndexProvider(org.apache.jackrabbit.oak.plugins.index.nodetype.NodeTypeIndexProvider) IndexTracker(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) IOException(java.io.IOException) LuceneIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory) IndexCopier(org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier) InitialContent(org.apache.jackrabbit.oak.InitialContent) LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) Observer(org.apache.jackrabbit.oak.spi.commit.Observer) Oak(org.apache.jackrabbit.oak.Oak) DefaultIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory) LuceneIndexProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider) Mounts.defaultMountInfoProvider(org.apache.jackrabbit.oak.spi.mount.Mounts.defaultMountInfoProvider) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) NodeCounterEditorProvider(org.apache.jackrabbit.oak.plugins.index.counter.NodeCounterEditorProvider)

Example 13 with LuceneIndexProvider

use of org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider in project jackrabbit-oak by apache.

the class HybridIndexTest method prepareLuceneIndexer.

private void prepareLuceneIndexer(File workDir, NodeStore nodeStore) {
    try {
        indexCopierDir = createTemporaryFolderIn(workDir);
        copier = new IndexCopier(executorService, indexCopierDir, true);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    IndexPathService indexPathService = new IndexPathServiceImpl(nodeStore);
    AsyncIndexInfoService asyncIndexInfoService = new AsyncIndexInfoServiceImpl(nodeStore);
    nrtIndexFactory = new NRTIndexFactory(copier, Clock.SIMPLE, TimeUnit.MILLISECONDS.toSeconds(refreshDeltaMillis), StatisticsProvider.NOOP);
    MountInfoProvider mip = Mounts.defaultMountInfoProvider();
    LuceneIndexReaderFactory indexReaderFactory = new DefaultIndexReaderFactory(mip, copier);
    IndexTracker tracker = new IndexTracker(indexReaderFactory, nrtIndexFactory);
    luceneIndexProvider = new LuceneIndexProvider(tracker);
    luceneEditorProvider = new LuceneIndexEditorProvider(copier, tracker, // extractedTextCache
    null, // augmentorFactory
    null, mip);
    queue = new DocumentQueue(queueSize, tracker, executorService, statsProvider);
    localIndexObserver = new LocalIndexObserver(queue, statsProvider);
    luceneEditorProvider.setIndexingQueue(queue);
    if (syncIndexing) {
        PropertyIndexCleaner cleaner = new PropertyIndexCleaner(nodeStore, indexPathService, asyncIndexInfoService, statsProvider);
        regs.add(scheduleWithFixedDelay(whiteboard, cleaner, cleanerIntervalInSecs, true, true));
    }
    Thread.setDefaultUncaughtExceptionHandler((t, e) -> log.warn("Uncaught exception", e));
}
Also used : IndexPathService(org.apache.jackrabbit.oak.plugins.index.IndexPathService) AsyncIndexInfoService(org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfoService) IndexTracker(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker) DocumentQueue(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.DocumentQueue) IOException(java.io.IOException) IndexPathServiceImpl(org.apache.jackrabbit.oak.plugins.index.IndexPathServiceImpl) LuceneIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory) IndexCopier(org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier) LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) LocalIndexObserver(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.LocalIndexObserver) NRTIndexFactory(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndexFactory) DefaultIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory) LuceneIndexProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) AsyncIndexInfoServiceImpl(org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfoServiceImpl) PropertyIndexCleaner(org.apache.jackrabbit.oak.plugins.index.lucene.property.PropertyIndexCleaner)

Example 14 with LuceneIndexProvider

use of org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider 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

LuceneIndexProvider (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider)14 LuceneIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider)12 Oak (org.apache.jackrabbit.oak.Oak)8 IndexCopier (org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier)8 IOException (java.io.IOException)6 IndexTracker (org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker)6 DefaultIndexReaderFactory (org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory)6 Observer (org.apache.jackrabbit.oak.spi.commit.Observer)6 MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)6 LuceneIndexReaderFactory (org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory)5 OpenSecurityProvider (org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider)5 InitialContent (org.apache.jackrabbit.oak.InitialContent)4 Jcr (org.apache.jackrabbit.oak.jcr.Jcr)4 DocumentQueue (org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.DocumentQueue)4 NRTIndexFactory (org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndexFactory)4 QueryIndexProvider (org.apache.jackrabbit.oak.spi.query.QueryIndexProvider)4 Repository (javax.jcr.Repository)3 SimpleCredentials (javax.jcr.SimpleCredentials)3 ExtractedTextCache (org.apache.jackrabbit.oak.plugins.index.lucene.ExtractedTextCache)3 LocalIndexObserver (org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.LocalIndexObserver)3