Search in sources :

Example 1 with CompositeIndexEditorProvider

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

the class CrossMountReferenceValidatorTest method initializeHook.

@Before
public void initializeHook() {
    MountInfoProvider mip = Mounts.newBuilder().mount("foo", "/a").build();
    hook = new EditorHook(new CompositeEditorProvider(new IndexUpdateProvider(new CompositeIndexEditorProvider(new PropertyIndexEditorProvider().with(mip), new ReferenceEditorProvider().with(mip))), new CrossMountReferenceValidatorProvider().with(mip).withFailOnDetection(true)));
}
Also used : ReferenceEditorProvider(org.apache.jackrabbit.oak.plugins.index.reference.ReferenceEditorProvider) CompositeEditorProvider(org.apache.jackrabbit.oak.spi.commit.CompositeEditorProvider) IndexUpdateProvider(org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) CompositeIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.CompositeIndexEditorProvider) Before(org.junit.Before)

Example 2 with CompositeIndexEditorProvider

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

the class LuceneIndexEditorTest method copyOnWriteAndLocks.

@Test
public void copyOnWriteAndLocks() throws Exception {
    assumeNotWindows();
    ExecutorService executorService = Executors.newFixedThreadPool(2);
    IndexCopier copier = new IndexCopier(executorService, temporaryFolder.getRoot());
    FailOnDemandEditorProvider failingProvider = new FailOnDemandEditorProvider();
    EditorHook hook = new EditorHook(new IndexUpdateProvider(new CompositeIndexEditorProvider(failingProvider, new LuceneIndexEditorProvider(copier))));
    NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME);
    NodeBuilder nb = newLuceneIndexDefinitionV2(index, "lucene", of(TYPENAME_STRING));
    IndexUtils.createIndexDefinition(index, "failingIndex", false, false, of("foo"), null);
    //1. Get initial set indexed. So that next cycle is normal indexing
    NodeState indexed = hook.processCommit(EMPTY_NODE, builder.getNodeState(), CommitInfo.EMPTY);
    builder = indexed.builder();
    NodeState before = indexed;
    builder.child("test").setProperty("a", "fox is jumping");
    NodeState after = builder.getNodeState();
    //2. Ensure that Lucene gets triggered but close is not called
    failingProvider.setShouldFail(true);
    try {
        hook.processCommit(before, after, CommitInfo.EMPTY);
        fail();
    } catch (CommitFailedException ignore) {
    }
    //3. Disable the troubling editor
    failingProvider.setShouldFail(false);
    //4. Now commit should process fine
    hook.processCommit(before, after, CommitInfo.EMPTY);
    executorService.shutdown();
}
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) ExecutorService(java.util.concurrent.ExecutorService) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) CommitFailedException(org.apache.jackrabbit.oak.api.CommitFailedException) CompositeIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.CompositeIndexEditorProvider) Test(org.junit.Test)

Aggregations

CompositeIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.CompositeIndexEditorProvider)2 IndexUpdateProvider (org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider)2 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)2 ExecutorService (java.util.concurrent.ExecutorService)1 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)1 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)1 ReferenceEditorProvider (org.apache.jackrabbit.oak.plugins.index.reference.ReferenceEditorProvider)1 CompositeEditorProvider (org.apache.jackrabbit.oak.spi.commit.CompositeEditorProvider)1 MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)1 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)1 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)1 Before (org.junit.Before)1 Test (org.junit.Test)1