Search in sources :

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

use of org.apache.jackrabbit.oak.spi.commit.Observer 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 4 with Observer

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

the class LuceneIndexDescendantSuggestionTest 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 5 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)

Aggregations

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