use of org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider in project jackrabbit-oak by apache.
the class AsyncIndexUpdateTest method cpCleanupNoChanges.
@Test
public void cpCleanupNoChanges() throws Exception {
MemoryNodeStore store = new MemoryNodeStore();
IndexEditorProvider provider = new PropertyIndexEditorProvider();
AsyncIndexUpdate async = new AsyncIndexUpdate("async", store, provider);
assertTrue("Expecting no checkpoints", store.listCheckpoints().size() == 0);
// no changes on diff, no checkpoints left behind
async.run();
assertTrue(async.isFinished());
Set<String> checkpoints = newHashSet(store.listCheckpoints());
assertTrue("Expecting the initial checkpoint", checkpoints.size() == 1);
assertEquals(store.getRoot().getChildNode(ASYNC).getString("async"), checkpoints.iterator().next());
async.run();
assertEquals("Expecting no checkpoint changes", checkpoints, store.listCheckpoints());
}
use of org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider in project jackrabbit-oak by apache.
the class AsyncIndexUpdateTest method disableCheckpointCleanup.
@Test
public void disableCheckpointCleanup() throws Exception {
String propertyName = "oak.async.checkpointCleanupIntervalMinutes";
MemoryNodeStore store = new MemoryNodeStore();
IndexEditorProvider provider = new PropertyIndexEditorProvider();
try {
System.setProperty(propertyName, "-1");
final AtomicBoolean cleaned = new AtomicBoolean();
AsyncIndexUpdate async = new AsyncIndexUpdate("async", store, provider) {
@Override
void cleanUpCheckpoints() {
cleaned.set(true);
super.cleanUpCheckpoints();
}
};
async.run();
assertFalse(cleaned.get());
} finally {
System.clearProperty(propertyName);
}
}
use of org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider in project jackrabbit-oak by apache.
the class AsyncIndexUpdateTest method traversalCount.
@Test
public void traversalCount() throws Exception {
MemoryNodeStore store = new MemoryNodeStore();
PropertyIndexEditorProvider 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);
async.run();
//Get rid of changes in index nodes i.e. /oak:index/rootIndex
async.run();
//Do a run without any index property change
builder = store.getRoot().builder();
builder.child("a").child("b");
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
async.run();
AsyncIndexStats stats = async.getIndexStats();
assertEquals(3, stats.getNodesReadCount());
assertEquals(0, stats.getUpdates());
//Do a run with a index property change
builder = store.getRoot().builder();
builder.child("a").child("b").setProperty("foo", "bar");
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
async.run();
stats = async.getIndexStats();
assertEquals(3, stats.getNodesReadCount());
assertEquals(1, stats.getUpdates());
}
use of org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider in project jackrabbit-oak by apache.
the class IndexUpdateTest method testReindexAsync.
/**
* Async Reindex Test (OAK-2174)
* <ul>
* <li>Add some content</li>
* <li>Add an index definition with the reindex flag and the reindex-async flag set</li>
* <li>Run the background async job manually</li>
* <li>Search & verify</li>
* </ul>
*/
@Test
public void testReindexAsync() throws Exception {
IndexEditorProvider provider = new PropertyIndexEditorProvider();
EditorHook hook = new EditorHook(new IndexUpdateProvider(provider));
NodeStore store = new MemoryNodeStore();
NodeBuilder builder = store.getRoot().builder();
createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null).setProperty(REINDEX_ASYNC_PROPERTY_NAME, true);
builder.child("testRoot").setProperty("foo", "abc");
// merge it back in
store.merge(builder, hook, CommitInfo.EMPTY);
// first check that the async flag exist
NodeState ns1 = checkPathExists(store.getRoot(), INDEX_DEFINITIONS_NAME, "rootIndex");
assertTrue(ns1.getProperty(REINDEX_PROPERTY_NAME).getValue(Type.BOOLEAN));
assertTrue(ns1.getProperty(REINDEX_ASYNC_PROPERTY_NAME).getValue(Type.BOOLEAN));
assertEquals(ASYNC_REINDEX_VALUE, ns1.getString(ASYNC_PROPERTY_NAME));
AsyncIndexUpdate async = new AsyncIndexUpdate(ASYNC_REINDEX_VALUE, store, provider, true);
int max = 5;
// same behaviour as PropertyIndexAsyncReindex mbean
boolean done = false;
int count = 0;
while (!done || count >= max) {
async.run();
done = async.isFinished();
count++;
}
// first check that the index content nodes exist
NodeState ns = checkPathExists(store.getRoot(), INDEX_DEFINITIONS_NAME, "rootIndex");
checkPathExists(ns, INDEX_CONTENT_NODE_NAME);
assertFalse(ns.getProperty(REINDEX_PROPERTY_NAME).getValue(Type.BOOLEAN));
assertNull(ns.getProperty(ASYNC_PROPERTY_NAME));
// next, lookup
PropertyIndexLookup lookup = new PropertyIndexLookup(store.getRoot());
assertEquals(ImmutableSet.of("testRoot"), find(lookup, "foo", "abc"));
}
use of org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider in project jackrabbit-oak by apache.
the class RepositoryManagerTest method registerRequiredServices.
private void registerRequiredServices() {
context.registerService(SecurityProvider.class, new OpenSecurityProvider());
context.registerService(NodeStore.class, new MemoryNodeStore());
context.registerService(IndexEditorProvider.class, new PropertyIndexEditorProvider(), ImmutableMap.<String, Object>of("type", "property"));
context.registerService(IndexEditorProvider.class, new ReferenceEditorProvider(), ImmutableMap.<String, Object>of("type", "reference"));
}
Aggregations