use of org.apache.jackrabbit.oak.spi.commit.EditorHook 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.spi.commit.EditorHook 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);
}
use of org.apache.jackrabbit.oak.spi.commit.EditorHook in project jackrabbit-oak by apache.
the class NodeStoreDiffTest method diffWithConflict.
@Test
public void diffWithConflict() throws Exception {
// Last rev on /var would be 1-0-1
createNodes("/var/a", "/var/b/b1");
// 1. Dummy commits to bump the version no
createNodes("/fake/b");
createNodes("/fake/c");
// Root rev = 3-0-1
// Root rev = 3-0-1
// 2. Create a node under /var/a but hold on commit
NodeBuilder b1 = ns.getRoot().builder();
createNodes(b1, "/var/a/a1");
// 3. Remove a node under /var/b and commit it
NodeBuilder b2 = ns.getRoot().builder();
b2.child("var").child("b").child("b1").remove();
merge(b2);
// 4. Now merge and commit the changes in b1 and include conflict hooks
// For now exception would be thrown
ns.merge(b1, new CompositeHook(ConflictHook.of(new AnnotatingConflictHandler()), new EditorHook(new ConflictValidatorProvider())), CommitInfo.EMPTY);
}
use of org.apache.jackrabbit.oak.spi.commit.EditorHook in project jackrabbit-oak by apache.
the class IndexImporterTest method getFooIndexNodeState.
private NodeState getFooIndexNodeState() throws CommitFailedException {
NodeState root = INITIAL_CONTENT;
// Add index definition
NodeBuilder builder = root.builder();
NodeBuilder index = createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "fooIndex", true, false, ImmutableSet.of("foo"), null);
builder.child("a").setProperty("foo", "abc");
NodeState after = builder.getNodeState();
EditorHook hook = new EditorHook(new IndexUpdateProvider(new PropertyIndexEditorProvider()));
NodeState indexed = hook.processCommit(EMPTY_NODE, after, CommitInfo.EMPTY);
return indexed.getChildNode("oak:index").getChildNode("fooIndex");
}
use of org.apache.jackrabbit.oak.spi.commit.EditorHook in project jackrabbit-oak by apache.
the class PropertyIndexTest method mountWithCommitInWritableMount.
@Test
public void mountWithCommitInWritableMount() throws Exception {
NodeState root = INITIAL_CONTENT;
// Add index definition
NodeBuilder builder = root.builder();
NodeBuilder index = createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "foo", true, false, ImmutableSet.of("foo"), null);
index.setProperty("entryCount", -1);
NodeState before = builder.getNodeState();
// Add some content and process it through the property index hook
builder.child("content").setProperty("foo", "abc");
NodeState after = builder.getNodeState();
MountInfoProvider mip = Mounts.newBuilder().readOnlyMount("foo", "/readOnly").build();
CompositeHook hook = new CompositeHook(new EditorHook(new IndexUpdateProvider(new PropertyIndexEditorProvider().with(mip))), new EditorHook(new ValidatorProvider() {
protected Validator getRootValidator(NodeState before, NodeState after, CommitInfo info) {
return new PrivateStoreValidator("/", mip);
}
}));
NodeState indexed = hook.processCommit(before, after, CommitInfo.EMPTY);
Mount defMount = mip.getDefaultMount();
assertTrue(getNode(indexed, pathInIndex(defMount, "/oak:index/foo", "/content", "abc")).exists());
}
Aggregations