Search in sources :

Example 11 with CommitContext

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

the class ExternalChangesTest method changeSetForExternalChanges.

@Test
public void changeSetForExternalChanges() throws Exception {
    NodeBuilder b1 = ns1.getRoot().builder();
    b1.child("a");
    b1.setProperty("foo1", "bar");
    ns1.merge(b1, newCollectingHook(), newCommitInfo());
    NodeBuilder b2 = ns1.getRoot().builder();
    b2.child("b");
    b2.setProperty("foo2", "bar");
    ns1.merge(b2, newCollectingHook(), newCommitInfo());
    ns1.runBackgroundUpdateOperations();
    c2.reset();
    ns2.runBackgroundReadOperations();
    CommitInfo ci = c2.getExternalChange();
    CommitContext cc = (CommitContext) ci.getInfo().get(CommitContext.NAME);
    assertNotNull(cc);
    ChangeSet cs = (ChangeSet) cc.get(ChangeCollectorProvider.COMMIT_CONTEXT_OBSERVATION_CHANGESET);
    assertNotNull(cs);
    assertFalse(cs.anyOverflow());
    assertThat(cs.getPropertyNames(), containsInAnyOrder("foo1", "foo2"));
}
Also used : CommitContext(org.apache.jackrabbit.oak.spi.commit.CommitContext) SimpleCommitContext(org.apache.jackrabbit.oak.core.SimpleCommitContext) CommitInfo(org.apache.jackrabbit.oak.spi.commit.CommitInfo) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) ChangeSet(org.apache.jackrabbit.oak.plugins.observation.ChangeSet) Test(org.junit.Test)

Example 12 with CommitContext

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

the class AsyncIndexerServiceTest method changeCollectionEnabled.

@Test
public void changeCollectionEnabled() throws Exception {
    injectDefaultServices();
    Map<String, Object> config = ImmutableMap.<String, Object>of("asyncConfigs", new String[] { "async:5" });
    context.registerService(IndexEditorProvider.class, new PropertyIndexEditorProvider());
    MockOsgi.activate(service, context.bundleContext(), config);
    NodeBuilder builder = nodeStore.getRoot().builder();
    createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null).setProperty(ASYNC_PROPERTY_NAME, "async");
    builder.child("testRoot").setProperty("foo", "abc");
    // merge it back in
    nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    CommitInfoCollector infoCollector = new CommitInfoCollector();
    nodeStore.addObserver(infoCollector);
    AsyncIndexUpdate indexUpdate = getIndexUpdate("async");
    indexUpdate.run();
    CommitContext commitContext = (CommitContext) infoCollector.infos.get(0).getInfo().get(CommitContext.NAME);
    assertNotNull(commitContext);
    ChangeSet changeSet = (ChangeSet) commitContext.get(ChangeCollectorProvider.COMMIT_CONTEXT_OBSERVATION_CHANGESET);
    assertNotNull(changeSet);
}
Also used : CommitContext(org.apache.jackrabbit.oak.spi.commit.CommitContext) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) CommitInfoCollector(org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdateTest.CommitInfoCollector) ChangeSet(org.apache.jackrabbit.oak.plugins.observation.ChangeSet) Test(org.junit.Test)

Example 13 with CommitContext

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

the class ChangeCollectorProviderTest method getSingleChangeSet.

/**
     * Assumes that the recorder got 1 call, and extracts the ChangeSet from
     * that call
     */
private ChangeSet getSingleChangeSet() {
    assertEquals(recorder.changes.size(), 1);
    CommitContext commitContext = (CommitContext) recorder.changes.get(0).info.getInfo().get(CommitContext.NAME);
    assertNotNull(commitContext);
    ChangeSet changeSet = (ChangeSet) commitContext.get(ChangeCollectorProvider.COMMIT_CONTEXT_OBSERVATION_CHANGESET);
    assertNotNull(changeSet);
    return changeSet;
}
Also used : CommitContext(org.apache.jackrabbit.oak.spi.commit.CommitContext) SimpleCommitContext(org.apache.jackrabbit.oak.core.SimpleCommitContext)

Aggregations

CommitContext (org.apache.jackrabbit.oak.spi.commit.CommitContext)13 SimpleCommitContext (org.apache.jackrabbit.oak.core.SimpleCommitContext)7 CommitInfo (org.apache.jackrabbit.oak.spi.commit.CommitInfo)6 Test (org.junit.Test)6 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)5 ChangeSet (org.apache.jackrabbit.oak.plugins.observation.ChangeSet)4 Map (java.util.Map)1 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)1 JournalProperty (org.apache.jackrabbit.oak.plugins.document.spi.JournalProperty)1 JournalPropertyBuilder (org.apache.jackrabbit.oak.plugins.document.spi.JournalPropertyBuilder)1 CommitInfoCollector (org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdateTest.CommitInfoCollector)1 ContextAwareCallback (org.apache.jackrabbit.oak.plugins.index.ContextAwareCallback)1 IndexingContext (org.apache.jackrabbit.oak.plugins.index.IndexingContext)1 IndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition)1 LuceneDocumentMaker (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneDocumentMaker)1 BlobDeletionCallback (org.apache.jackrabbit.oak.plugins.index.lucene.directory.ActiveDeletedBlobCollectorFactory.BlobDeletionCallback)1 LocalIndexWriterFactory (org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.LocalIndexWriterFactory)1 DefaultIndexWriterFactory (org.apache.jackrabbit.oak.plugins.index.lucene.writer.DefaultIndexWriterFactory)1 LuceneIndexWriterFactory (org.apache.jackrabbit.oak.plugins.index.lucene.writer.LuceneIndexWriterFactory)1 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)1