Search in sources :

Example 6 with Observer

use of org.apache.jackrabbit.oak.spi.commit.Observer in project jackrabbit-oak by apache.

the class LuceneIndexDescendantSpellcheckTest method before.

@Before
public void before() throws Exception {
    LuceneIndexProvider provider = new LuceneIndexProvider();
    Jcr jcr = new Jcr().with(((QueryIndexProvider) provider)).with((Observer) provider).with(new LuceneIndexEditorProvider());
    repository = jcr.createRepository();
    session = (JackrabbitSession) repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
    root = session.getRootNode();
    createContent();
    session.save();
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) Observer(org.apache.jackrabbit.oak.spi.commit.Observer) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) QueryIndexProvider(org.apache.jackrabbit.oak.spi.query.QueryIndexProvider) Before(org.junit.Before)

Example 7 with Observer

use of org.apache.jackrabbit.oak.spi.commit.Observer in project jackrabbit-oak by apache.

the class CheckpointTest method noContentChangeForCheckpoints.

@Test
public void noContentChangeForCheckpoints() throws Exception {
    final AtomicInteger invocationCount = new AtomicInteger();
    ((Observable) store).addObserver(new Observer() {

        @Override
        public void contentChanged(@Nonnull NodeState root, @Nonnull CommitInfo info) {
            invocationCount.incrementAndGet();
        }
    });
    invocationCount.set(0);
    String cp = store.checkpoint(Long.MAX_VALUE);
    assertEquals(0, invocationCount.get());
    store.release(cp);
    assertEquals(0, invocationCount.get());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Observer(org.apache.jackrabbit.oak.spi.commit.Observer) CommitInfo(org.apache.jackrabbit.oak.spi.commit.CommitInfo) Observable(org.apache.jackrabbit.oak.spi.commit.Observable) Test(org.junit.Test) OakBaseTest(org.apache.jackrabbit.oak.OakBaseTest)

Example 8 with Observer

use of org.apache.jackrabbit.oak.spi.commit.Observer in project jackrabbit-oak by apache.

the class HybridIndexClusterIT method customize.

@Override
protected Jcr customize(Jcr jcr) {
    IndexCopier copier;
    try {
        copier = new IndexCopier(executorService, temporaryFolder.getRoot());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    MountInfoProvider mip = defaultMountInfoProvider();
    NRTIndexFactory nrtIndexFactory = new NRTIndexFactory(copier, clock, TimeUnit.MILLISECONDS.toSeconds(refreshDelta), StatisticsProvider.NOOP);
    LuceneIndexReaderFactory indexReaderFactory = new DefaultIndexReaderFactory(mip, copier);
    IndexTracker tracker = new IndexTracker(indexReaderFactory, nrtIndexFactory);
    LuceneIndexProvider provider = new LuceneIndexProvider(tracker);
    DocumentQueue 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);
    ExternalIndexObserver externalIndexObserver = new ExternalIndexObserver(queue, tracker, StatisticsProvider.NOOP);
    QueryEngineSettings qs = new QueryEngineSettings();
    qs.setFailTraversal(true);
    jcr.with((QueryIndexProvider) provider).with((Observer) provider).with(localIndexObserver).with(externalIndexObserver).with(editorProvider).with(qs).withAsyncIndexing("async", TimeUnit.DAYS.toSeconds(1));
    return jcr;
}
Also used : IndexTracker(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) IOException(java.io.IOException) 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) Observer(org.apache.jackrabbit.oak.spi.commit.Observer) 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)

Example 9 with Observer

use of org.apache.jackrabbit.oak.spi.commit.Observer in project jackrabbit-oak by apache.

the class LuceneIndexSuggestionTest method before.

@Before
public void before() throws Exception {
    LuceneIndexProvider provider = new LuceneIndexProvider();
    Jcr jcr = new Jcr().with(((QueryIndexProvider) provider)).with((Observer) provider).with(new LuceneIndexEditorProvider());
    repository = jcr.createRepository();
    session = (JackrabbitSession) repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
    root = session.getRootNode();
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) Observer(org.apache.jackrabbit.oak.spi.commit.Observer) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) QueryIndexProvider(org.apache.jackrabbit.oak.spi.query.QueryIndexProvider) Before(org.junit.Before)

Example 10 with Observer

use of org.apache.jackrabbit.oak.spi.commit.Observer in project jackrabbit-oak by apache.

the class LuceneIndexProviderService method registerLocalIndexObserver.

private void registerLocalIndexObserver(BundleContext bundleContext, IndexTracker tracker, Map<String, ?> config) {
    if (!hybridIndex) {
        log.info("Hybrid indexing feature disabled");
        return;
    }
    int queueSize = PropertiesUtil.toInteger(config.get(PROP_HYBRID_QUEUE_SIZE), PROP_HYBRID_QUEUE_SIZE_DEFAULT);
    documentQueue = new DocumentQueue(queueSize, tracker, getExecutorService(), statisticsProvider);
    LocalIndexObserver localIndexObserver = new LocalIndexObserver(documentQueue, statisticsProvider);
    regs.add(bundleContext.registerService(Observer.class.getName(), localIndexObserver, null));
    int observerQueueSize = 1000;
    int builderMaxSize = 5000;
    regs.add(bundleContext.registerService(JournalPropertyService.class.getName(), new LuceneJournalPropertyService(builderMaxSize), null));
    ExternalObserverBuilder builder = new ExternalObserverBuilder(documentQueue, tracker, statisticsProvider, getExecutorService(), observerQueueSize);
    log.info("Configured JournalPropertyBuilder with max size {} and backed by BackgroundObserver " + "with queue size {}", builderMaxSize, observerQueueSize);
    Observer observer = builder.build();
    externalIndexObserver = builder.getBackgroundObserver();
    regs.add(bundleContext.registerService(Observer.class.getName(), observer, null));
    oakRegs.add(registerMBean(whiteboard, BackgroundObserverMBean.class, externalIndexObserver.getMBean(), BackgroundObserverMBean.TYPE, "LuceneExternalIndexObserver queue stats"));
    log.info("Hybrid indexing enabled for configured indexes with queue size of {}", queueSize);
}
Also used : ExternalObserverBuilder(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.ExternalObserverBuilder) LocalIndexObserver(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.LocalIndexObserver) Observer(org.apache.jackrabbit.oak.spi.commit.Observer) LocalIndexObserver(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.LocalIndexObserver) BackgroundObserver(org.apache.jackrabbit.oak.spi.commit.BackgroundObserver) DocumentQueue(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.DocumentQueue) LuceneJournalPropertyService(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.LuceneJournalPropertyService) BackgroundObserverMBean(org.apache.jackrabbit.oak.spi.commit.BackgroundObserverMBean)

Aggregations

Observer (org.apache.jackrabbit.oak.spi.commit.Observer)21 Test (org.junit.Test)8 CommitInfo (org.apache.jackrabbit.oak.spi.commit.CommitInfo)7 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)6 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)5 SimpleCredentials (javax.jcr.SimpleCredentials)4 Jcr (org.apache.jackrabbit.oak.jcr.Jcr)4 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)4 QueryIndexProvider (org.apache.jackrabbit.oak.spi.query.QueryIndexProvider)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 Oak (org.apache.jackrabbit.oak.Oak)3 LuceneIndexProvider (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider)3 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)3 Observable (org.apache.jackrabbit.oak.spi.commit.Observable)3 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)3 Before (org.junit.Before)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 InitialContent (org.apache.jackrabbit.oak.InitialContent)2