Search in sources :

Example 16 with EditorHook

use of org.apache.jackrabbit.oak.spi.commit.EditorHook 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)

Example 17 with EditorHook

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

the class NodeStoreUtils method mergeWithConcurrentCheck.

public static void mergeWithConcurrentCheck(NodeStore nodeStore, NodeBuilder builder) throws CommitFailedException {
    List<EditorProvider> editorProviders = Lists.newArrayList();
    editorProviders.add(new ConflictValidatorProvider());
    CompositeHook hooks = new CompositeHook(new ConflictHook(new AnnotatingConflictHandler()), new EditorHook(CompositeEditorProvider.compose(editorProviders)));
    nodeStore.merge(builder, hooks, CommitInfo.EMPTY);
}
Also used : CompositeHook(org.apache.jackrabbit.oak.spi.commit.CompositeHook) AnnotatingConflictHandler(org.apache.jackrabbit.oak.plugins.commit.AnnotatingConflictHandler) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) ConflictHook(org.apache.jackrabbit.oak.plugins.commit.ConflictHook) ConflictValidatorProvider(org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider) CompositeEditorProvider(org.apache.jackrabbit.oak.spi.commit.CompositeEditorProvider) EditorProvider(org.apache.jackrabbit.oak.spi.commit.EditorProvider)

Example 18 with EditorHook

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

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

the class IndexUpdateTest method contextAwareCallback_async.

@Test
public void contextAwareCallback_async() throws Exception {
    NodeState before = builder.getNodeState();
    NodeBuilder idx = createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null);
    idx.setProperty("async", asList("sync", "async"), Type.STRINGS);
    NodeState after = builder.getNodeState();
    CallbackCapturingProvider provider = new CallbackCapturingProvider();
    EditorHook hook = new EditorHook(new IndexUpdateProvider(provider, "async", false));
    hook.processCommit(before, after, CommitInfo.EMPTY);
    assertTrue(((ContextAwareCallback) provider.callback).getIndexingContext().isAsync());
}
Also used : 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) Test(org.junit.Test)

Example 20 with EditorHook

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

the class IndexUpdateTest method contextAwareCallback.

@Test
public void contextAwareCallback() throws Exception {
    NodeState before = builder.getNodeState();
    createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null);
    NodeState after = builder.getNodeState();
    CallbackCapturingProvider provider = new CallbackCapturingProvider();
    EditorHook hook = new EditorHook(new IndexUpdateProvider(provider));
    CommitInfo info = new CommitInfo("foo", "bar");
    NodeState indexed = hook.processCommit(before, after, info);
    assertNotNull(provider.callback);
    assertThat(provider.callback, instanceOf(ContextAwareCallback.class));
    ContextAwareCallback contextualCallback = (ContextAwareCallback) provider.callback;
    IndexingContext context = contextualCallback.getIndexingContext();
    assertNotNull(context);
    assertEquals("/oak:index/rootIndex", context.getIndexPath());
    assertTrue(context.isReindexing());
    assertFalse(context.isAsync());
    assertSame(info, context.getCommitInfo());
    before = indexed;
    builder = indexed.builder();
    builder.child("a").setProperty("foo", "bar");
    after = builder.getNodeState();
    hook.processCommit(before, after, info);
    assertFalse(((ContextAwareCallback) provider.callback).getIndexingContext().isReindexing());
}
Also used : EmptyNodeState(org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) CommitInfo(org.apache.jackrabbit.oak.spi.commit.CommitInfo) Test(org.junit.Test)

Aggregations

EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)69 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)46 Test (org.junit.Test)44 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)43 IndexUpdateProvider (org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider)24 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)14 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)12 ConflictValidatorProvider (org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider)11 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)11 CommitHook (org.apache.jackrabbit.oak.spi.commit.CommitHook)11 CompositeHook (org.apache.jackrabbit.oak.spi.commit.CompositeHook)11 CompositeEditorProvider (org.apache.jackrabbit.oak.spi.commit.CompositeEditorProvider)8 AnnotatingConflictHandler (org.apache.jackrabbit.oak.plugins.commit.AnnotatingConflictHandler)7 ConflictHook (org.apache.jackrabbit.oak.plugins.commit.ConflictHook)7 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)7 EditorProvider (org.apache.jackrabbit.oak.spi.commit.EditorProvider)7 CommitInfo (org.apache.jackrabbit.oak.spi.commit.CommitInfo)6 MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)6 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)6 Before (org.junit.Before)6