use of org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider in project jackrabbit-oak by apache.
the class ReferenceIndexTest method removeWeaklyReferencedNode.
@Test
public void removeWeaklyReferencedNode() 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.WEAKREFERENCE));
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();
hook.processCommit(indexed, builder.getNodeState(), CommitInfo.EMPTY);
}
use of org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider in project jackrabbit-oak by apache.
the class ReferenceIndexTest method basicReferenceHandling.
@Test
public void basicReferenceHandling() throws Exception {
NodeState root = INITIAL_CONTENT;
NodeBuilder builder = root.builder();
NodeState before = builder.getNodeState();
builder.child("a").setProperty(createProperty("foo", "u1", Type.REFERENCE));
builder.child("b").setProperty(createProperty("foo", "u1", Type.REFERENCE));
builder.child("c").setProperty(createProperty("foo", "u2", Type.WEAKREFERENCE));
NodeState after = builder.getNodeState();
EditorHook hook = new EditorHook(new IndexUpdateProvider(new ReferenceEditorProvider()));
NodeState indexed = hook.processCommit(before, after, CommitInfo.EMPTY);
FilterImpl f = createFilter(indexed, NT_BASE);
f.restrictProperty("*", Operator.EQUAL, newReference("u1"), PropertyType.REFERENCE);
assertFilter(f, new ReferenceIndex(), indexed, of("/a", "/b"));
FilterImpl f2 = createFilter(indexed, NT_BASE);
f2.restrictProperty("*", Operator.EQUAL, newReference("u2"), PropertyType.WEAKREFERENCE);
assertFilter(f2, new ReferenceIndex(), indexed, of("/c"));
}
use of org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider in project jackrabbit-oak by apache.
the class NodeStoreUtils method mergeWithConcurrentCheck.
static void mergeWithConcurrentCheck(NodeStore nodeStore, NodeBuilder builder, IndexEditorProvider indexEditorProvider) throws CommitFailedException {
CompositeHook hooks = new CompositeHook(ResetCommitAttributeHook.INSTANCE, new EditorHook(new IndexUpdateProvider(indexEditorProvider, null, true)), new ConflictHook(new AnnotatingConflictHandler()), new EditorHook(CompositeEditorProvider.compose(singletonList(new ConflictValidatorProvider()))));
nodeStore.merge(builder, hooks, createCommitInfo());
}
use of org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider in project jackrabbit-oak by apache.
the class LuceneIndexEditorTest method copyOnWriteAndLocks.
@Test
public void copyOnWriteAndLocks() throws Exception {
assumeFalse(CIHelper.windows());
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();
}
use of org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider in project jackrabbit-oak by apache.
the class UniqueIndexNodeStoreCheckerTest method populateStore.
private void populateStore(NodeStore ns, Consumer<NodeBuilder> action) throws CommitFailedException {
NodeBuilder builder = ns.getRoot().builder();
NodeBuilder index = createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "foo", true, true, ImmutableSet.of("foo"), null);
index.setProperty("entryCount", -1);
action.accept(builder);
ns.merge(builder, new EditorHook(new IndexUpdateProvider(new PropertyIndexEditorProvider().with(mip))), CommitInfo.EMPTY);
}
Aggregations