Search in sources :

Example 21 with CommitInfo

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

the class ExternalIndexObserverTest method ruleNotResultingInDoc.

@Test
public void ruleNotResultingInDoc() throws Exception {
    Multimap<String, String> indexedPaths = HashMultimap.create();
    indexedPaths.put("/a", "/oak:index/foo");
    commitContext.set(LuceneDocumentHolder.NAME, new IndexedPaths(indexedPaths));
    CommitInfo ci = newCommitInfo();
    //Rule is of type nt:base but does not have any matching property definition
    when(tracker.getIndexDefinition("/oak:index/foo")).thenReturn(createNRTIndex("nt:base"));
    NodeBuilder nb = INITIAL_CONTENT.builder();
    nb.child("a");
    observer.contentChanged(nb.getNodeState(), ci);
    verifyZeroInteractions(queue);
}
Also used : CommitInfo(org.apache.jackrabbit.oak.spi.commit.CommitInfo) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 22 with CommitInfo

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

the class LocalIndexObserverTest method docsAddedToQueue.

@Test
public void docsAddedToQueue() throws Exception {
    CommitInfo info = newCommitInfo();
    CommitContext cc = (CommitContext) info.getInfo().get(CommitContext.NAME);
    LuceneDocumentHolder holder = new LuceneDocumentHolder(collectingQueue, 500);
    holder.add(false, LuceneDoc.forDelete("foo", "bar"));
    cc.set(LuceneDocumentHolder.NAME, holder);
    observer.contentChanged(EMPTY_NODE, info);
    assertEquals(1, collectingQueue.getQueuedDocs().size());
    assertNull(cc.get(LuceneDocumentHolder.NAME));
}
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) Test(org.junit.Test)

Example 23 with CommitInfo

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

the class ExternalIndexObserverTest method nonApplicableRule.

@Test
public void nonApplicableRule() throws Exception {
    Multimap<String, String> indexedPaths = HashMultimap.create();
    indexedPaths.put("/a", "/oak:index/foo");
    commitContext.set(LuceneDocumentHolder.NAME, new IndexedPaths(indexedPaths));
    CommitInfo ci = newCommitInfo();
    //Rule is on nt:file but node if of type nt:base
    when(tracker.getIndexDefinition("/oak:index/foo")).thenReturn(createNRTIndex("nt:file"));
    NodeBuilder nb = INITIAL_CONTENT.builder();
    nb.child("a");
    observer.contentChanged(nb.getNodeState(), ci);
    verifyZeroInteractions(queue);
}
Also used : CommitInfo(org.apache.jackrabbit.oak.spi.commit.CommitInfo) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 24 with CommitInfo

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

the class LockBasedSchedulerCheckpointTest method createBlockingCommit.

private Commit createBlockingCommit(final Scheduler scheduler, final String property, String value, final Callable<Boolean> callable) {
    NodeBuilder a = getRoot(scheduler).builder();
    a.setProperty(property, value);
    Commit blockingCommit = new Commit(a, new CommitHook() {

        @Override
        @Nonnull
        public NodeState processCommit(NodeState before, NodeState after, CommitInfo info) {
            try {
                callable.call();
            } catch (Exception e) {
                fail();
            }
            return after;
        }
    }, CommitInfo.EMPTY);
    return blockingCommit;
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) Nonnull(javax.annotation.Nonnull) CommitHook(org.apache.jackrabbit.oak.spi.commit.CommitHook) CommitInfo(org.apache.jackrabbit.oak.spi.commit.CommitInfo) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder)

Example 25 with CommitInfo

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

the class DocumentNodeStore method newCommitInfo.

private static CommitInfo newCommitInfo(@Nonnull ChangeSet changeSet, JournalPropertyHandler journalPropertyHandler) {
    CommitContext commitContext = new SimpleCommitContext();
    commitContext.set(COMMIT_CONTEXT_OBSERVATION_CHANGESET, changeSet);
    journalPropertyHandler.addTo(commitContext);
    Map<String, Object> info = ImmutableMap.<String, Object>of(CommitContext.NAME, commitContext);
    return new CommitInfo(CommitInfo.OAK_UNKNOWN, CommitInfo.OAK_UNKNOWN, info, true);
}
Also used : SimpleCommitContext(org.apache.jackrabbit.oak.core.SimpleCommitContext) CommitContext(org.apache.jackrabbit.oak.spi.commit.CommitContext) CommitInfo(org.apache.jackrabbit.oak.spi.commit.CommitInfo) SimpleCommitContext(org.apache.jackrabbit.oak.core.SimpleCommitContext)

Aggregations

CommitInfo (org.apache.jackrabbit.oak.spi.commit.CommitInfo)39 Test (org.junit.Test)29 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)23 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)16 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)11 CommitHook (org.apache.jackrabbit.oak.spi.commit.CommitHook)9 Nonnull (javax.annotation.Nonnull)7 Observer (org.apache.jackrabbit.oak.spi.commit.Observer)7 SimpleCommitContext (org.apache.jackrabbit.oak.core.SimpleCommitContext)6 CommitContext (org.apache.jackrabbit.oak.spi.commit.CommitContext)6 OakBaseTest (org.apache.jackrabbit.oak.OakBaseTest)4 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)3 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)3 ChangeSet (org.apache.jackrabbit.oak.plugins.observation.ChangeSet)3 EditorProvider (org.apache.jackrabbit.oak.spi.commit.EditorProvider)3 Observable (org.apache.jackrabbit.oak.spi.commit.Observable)3 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)3