use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.
the class CompositeNodeStore method reset.
@Override
public NodeState reset(NodeBuilder builder) {
checkArgument(builder instanceof CompositeNodeBuilder);
CompositeNodeBuilder nodeBuilder = (CompositeNodeBuilder) builder;
Map<MountedNodeStore, NodeState> resultStates = newHashMap();
for (MountedNodeStore mountedNodeStore : ctx.getAllMountedNodeStores()) {
NodeStore nodeStore = mountedNodeStore.getNodeStore();
NodeBuilder partialBuilder = nodeBuilder.getBuilders().get(mountedNodeStore);
NodeState result = nodeStore.reset(partialBuilder);
resultStates.put(mountedNodeStore, result);
}
return createRootNodeState(resultStates);
}
use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.
the class CompositeNodeStore method rebase.
@Override
public NodeState rebase(NodeBuilder builder) {
checkArgument(builder instanceof CompositeNodeBuilder);
CompositeNodeBuilder nodeBuilder = (CompositeNodeBuilder) builder;
Map<MountedNodeStore, NodeState> resultStates = newHashMap();
for (MountedNodeStore mountedNodeStore : ctx.getAllMountedNodeStores()) {
NodeStore nodeStore = mountedNodeStore.getNodeStore();
NodeBuilder partialBuilder = nodeBuilder.getBuilders().get(mountedNodeStore);
NodeState result = nodeStore.rebase(partialBuilder);
resultStates.put(mountedNodeStore, result);
}
return createRootNodeState(resultStates);
}
use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.
the class AsyncIndexUpdateTest method testAsyncDoubleSubtree.
/**
* Async Index Test with 2 index defs at different tree locations
* <ul>
* <li>Add an index definition</li>
* <li>Add some content</li>
* <li>Search & verify</li>
* </ul>
*
*/
@Test
public void testAsyncDoubleSubtree() throws Exception {
NodeStore store = new MemoryNodeStore();
IndexEditorProvider provider = new PropertyIndexEditorProvider();
NodeBuilder builder = store.getRoot().builder();
createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null).setProperty(ASYNC_PROPERTY_NAME, "async");
createIndexDefinition(builder.child("newchild").child("other").child(INDEX_DEFINITIONS_NAME), "subIndex", true, false, ImmutableSet.of("foo"), null).setProperty(ASYNC_PROPERTY_NAME, "async");
builder.child("testRoot").setProperty("foo", "abc");
builder.child("newchild").child("other").child("testChild").setProperty("foo", "xyz");
// merge it back in
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
AsyncIndexUpdate async = new AsyncIndexUpdate("async", store, provider);
async.run();
NodeState root = store.getRoot();
// first check that the index content nodes exist
checkPathExists(root, INDEX_DEFINITIONS_NAME, "rootIndex", INDEX_CONTENT_NODE_NAME);
checkPathExists(root, "newchild", "other", INDEX_DEFINITIONS_NAME, "subIndex", INDEX_CONTENT_NODE_NAME);
PropertyIndexLookup lookup = new PropertyIndexLookup(root);
assertEquals(ImmutableSet.of("testRoot"), find(lookup, "foo", "abc"));
PropertyIndexLookup lookupChild = new PropertyIndexLookup(root.getChildNode("newchild").getChildNode("other"));
assertEquals(ImmutableSet.of("testChild"), find(lookupChild, "foo", "xyz"));
assertEquals(ImmutableSet.<String>of(), find(lookupChild, "foo", "abc"));
}
use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.
the class AsyncIndexUpdateTest method testAsyncDouble.
/**
* Async Index Test with 2 index defs at the same location
* <ul>
* <li>Add an index definition</li>
* <li>Add some content</li>
* <li>Search & verify</li>
* </ul>
*
*/
@Test
public void testAsyncDouble() throws Exception {
NodeStore store = new MemoryNodeStore();
IndexEditorProvider provider = new PropertyIndexEditorProvider();
NodeBuilder builder = store.getRoot().builder();
createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null).setProperty(ASYNC_PROPERTY_NAME, "async");
createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndexSecond", true, false, ImmutableSet.of("bar"), null).setProperty(ASYNC_PROPERTY_NAME, "async");
builder.child("testRoot").setProperty("foo", "abc").setProperty("bar", "def");
builder.child("testSecond").setProperty("bar", "ghi");
// merge it back in
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
AsyncIndexUpdate async = new AsyncIndexUpdate("async", store, provider);
async.run();
NodeState root = store.getRoot();
// first check that the index content nodes exist
checkPathExists(root, INDEX_DEFINITIONS_NAME, "rootIndex", INDEX_CONTENT_NODE_NAME);
checkPathExists(root, INDEX_DEFINITIONS_NAME, "rootIndexSecond", INDEX_CONTENT_NODE_NAME);
PropertyIndexLookup lookup = new PropertyIndexLookup(root);
assertEquals(ImmutableSet.of("testRoot"), find(lookup, "foo", "abc"));
assertEquals(ImmutableSet.<String>of(), find(lookup, "foo", "def"));
assertEquals(ImmutableSet.<String>of(), find(lookup, "foo", "ghi"));
assertEquals(ImmutableSet.<String>of(), find(lookup, "bar", "abc"));
assertEquals(ImmutableSet.of("testRoot"), find(lookup, "bar", "def"));
assertEquals(ImmutableSet.of("testSecond"), find(lookup, "bar", "ghi"));
}
use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.
the class AsyncIndexUpdateTest method checkpointStability.
@Test
public void checkpointStability() throws Exception {
NodeStore store = new MemoryNodeStore();
IndexEditorProvider provider = new PropertyIndexEditorProvider();
NodeBuilder builder = store.getRoot().builder();
createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null).setProperty(ASYNC_PROPERTY_NAME, "async");
builder.child("testRoot").setProperty("foo", "abc");
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
AsyncIndexUpdate async = new AsyncIndexUpdate("async", store, provider);
//Initial indexing
async.run();
//Now checkpoints = [checkpoints0]
//Index again so as to get change in reindex flag done
async.run();
//Now checkpoints = [checkpoints1]. checkpoints0 released
//Now make some changes to
builder = store.getRoot().builder();
builder.child("testRoot2").setProperty("foo", "abc");
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
async.run();
//Now checkpoints = [checkpoints1]. Note that size is 1 so new checkpoint name remains same
LogCustomizer customLogs = LogCustomizer.forLogger(AsyncIndexUpdate.class.getName()).filter(Level.WARN).create();
builder = store.getRoot().builder();
builder.child("testRoot3").setProperty("foo", "abc");
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
customLogs.starting();
async.run();
assertEquals(Collections.emptyList(), customLogs.getLogs());
customLogs.finished();
}
Aggregations