Search in sources :

Example 1 with IndexUpdateProvider

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

the class PropertyIndexTest method mountAndUniqueIndexes.

@Test(expected = CommitFailedException.class)
public void mountAndUniqueIndexes() throws Exception {
    NodeState root = INITIAL_CONTENT;
    // Add index definition
    NodeBuilder builder = root.builder();
    NodeBuilder index = createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "foo", true, true, ImmutableSet.of("foo"), null);
    index.setProperty("entryCount", -1);
    NodeState before = builder.getNodeState();
    MountInfoProvider mip = Mounts.newBuilder().mount("foo", "/a").build();
    builder.child("a").setProperty("foo", "abc");
    builder.child("b").setProperty("foo", Arrays.asList("abc", "def"), Type.STRINGS);
    NodeState after = builder.getNodeState();
    EditorHook hook = new EditorHook(new IndexUpdateProvider(new PropertyIndexEditorProvider().with(mip)));
    // should throw
    hook.processCommit(before, after, CommitInfo.EMPTY);
}
Also used : IndexUpdateProvider(org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider) EmptyNodeState(org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) Test(org.junit.Test)

Example 2 with IndexUpdateProvider

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

the class ReferenceIndexTest method removeReferencedNode.

@Test
public void removeReferencedNode() throws Exception {
    NodeState root = INITIAL_CONTENT;
    NodeBuilder builder = root.builder();
    NodeState before = builder.getNodeState();
    builder.child("a").setProperty(createProperty(JCR_UUID, "u1", Type.STRING));
    builder.child("b").setProperty(createProperty("foo", "u1", Type.REFERENCE));
    NodeState after = builder.getNodeState();
    EditorHook hook = new EditorHook(new IndexUpdateProvider(new ReferenceEditorProvider()));
    NodeState indexed = hook.processCommit(before, after, CommitInfo.EMPTY);
    builder = indexed.builder();
    builder.getChildNode("a").remove();
    thrown.expect(CommitFailedException.class);
    thrown.expectMessage("OakIntegrity0001: Unable to delete referenced node");
    hook.processCommit(indexed, builder.getNodeState(), CommitInfo.EMPTY);
}
Also used : IndexUpdateProvider(org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 3 with IndexUpdateProvider

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

the class DocumentQueueTest method setUp.

@Before
public void setUp() throws IOException {
    IndexEditorProvider editorProvider = new LuceneIndexEditorProvider(null, null, null, defaultMountInfoProvider());
    syncHook = new EditorHook(new IndexUpdateProvider(editorProvider));
    asyncHook = new EditorHook(new IndexUpdateProvider(editorProvider, "async", false));
}
Also used : IndexUpdateProvider(org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider) LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) IndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider) Before(org.junit.Before)

Example 4 with IndexUpdateProvider

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

the class LuceneIndexEditorTest method multiplexingWriter.

@Test
public void multiplexingWriter() throws Exception {
    newLucenePropertyIndex("lucene", "foo");
    MountInfoProvider mip = Mounts.newBuilder().mount("foo", "/libs", "/apps").build();
    EditorHook hook = new EditorHook(new IndexUpdateProvider(new LuceneIndexEditorProvider(null, new ExtractedTextCache(0, 0), null, mip)));
    NodeState indexed = hook.processCommit(EMPTY_NODE, builder.getNodeState(), CommitInfo.EMPTY);
    builder = indexed.builder();
    NodeState before = indexed;
    builder.child("content").child("en").setProperty("foo", "bar");
    builder.child("libs").child("install").setProperty("foo", "bar");
    NodeState after = builder.getNodeState();
    indexed = hook.processCommit(before, after, CommitInfo.EMPTY);
    builder = indexed.builder();
    assertEquals(1, numDocs(mip.getMountByName("foo")));
    assertEquals(1, numDocs(mip.getDefaultMount()));
}
Also used : IndexUpdateProvider(org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) Test(org.junit.Test)

Example 5 with IndexUpdateProvider

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

the class LuceneIndexEditorTest method setup.

@Before
public void setup() throws Exception {
    if (useBlobStore) {
        LuceneIndexEditorProvider provider = new LuceneIndexEditorProvider();
        CachingFileDataStore ds = DataStoreUtils.createCachingFDS(temporaryFolder.newFolder().getAbsolutePath(), temporaryFolder.newFolder().getAbsolutePath());
        provider.setBlobStore(new DataStoreBlobStore(ds));
        HOOK = new EditorHook(new IndexUpdateProvider(provider));
    } else {
        HOOK = new EditorHook(new IndexUpdateProvider(new LuceneIndexEditorProvider()));
    }
}
Also used : IndexUpdateProvider(org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) CachingFileDataStore(org.apache.jackrabbit.oak.plugins.blob.datastore.CachingFileDataStore) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore) Before(org.junit.Before)

Aggregations

IndexUpdateProvider (org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider)24 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)24 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)14 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)14 Test (org.junit.Test)13 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)6 MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)6 Before (org.junit.Before)6 FilterImpl (org.apache.jackrabbit.oak.query.index.FilterImpl)4 CompositeIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.CompositeIndexEditorProvider)3 IndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider)3 LuceneIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider)3 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)2 CommitHook (org.apache.jackrabbit.oak.spi.commit.CommitHook)2 CompositeHook (org.apache.jackrabbit.oak.spi.commit.CompositeHook)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 ArrayList (java.util.ArrayList)1 Executor (java.util.concurrent.Executor)1 ExecutorService (java.util.concurrent.ExecutorService)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1