use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore in project jackrabbit-oak by apache.
the class AsyncIndexUpdateTest method cpCleanupNoRelease.
@Test
public void cpCleanupNoRelease() throws Exception {
final MemoryNodeStore mns = new MemoryNodeStore();
final AtomicBoolean canRelease = new AtomicBoolean(false);
ProxyNodeStore store = new ProxyNodeStore() {
@Override
protected NodeStore getNodeStore() {
return mns;
}
@Override
public boolean release(String checkpoint) {
if (canRelease.get()) {
return super.release(checkpoint);
}
return false;
}
};
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);
assertTrue("Expecting no checkpoints", mns.listCheckpoints().size() == 0);
AsyncIndexUpdate async = new AsyncIndexUpdate("async", store, provider);
async.run();
assertTrue("Expecting one checkpoint", mns.listCheckpoints().size() == 1);
assertTrue("Expecting one temp checkpoint", newHashSet(store.getRoot().getChildNode(ASYNC).getStrings("async-temp")).size() == 1);
builder = store.getRoot().builder();
builder.child("testRoot").setProperty("foo", "def");
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
async.run();
assertTrue("Expecting two checkpoints", mns.listCheckpoints().size() == 2);
assertTrue("Expecting two temp checkpoints", newHashSet(store.getRoot().getChildNode(ASYNC).getStrings("async-temp")).size() == 2);
canRelease.set(true);
builder = store.getRoot().builder();
builder.child("testRoot").setProperty("foo", "ghi");
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
async.run();
assertTrue("Expecting one checkpoint", mns.listCheckpoints().size() == 1);
String secondCp = mns.listCheckpoints().iterator().next();
assertEquals(secondCp, store.getRoot().getChildNode(ASYNC).getString("async"));
// cleared from the store already
for (String cp : store.getRoot().getChildNode(ASYNC).getStrings("async-temp")) {
if (cp.equals(secondCp)) {
continue;
}
assertNull("Temp checkpoint was already cleared from store", store.retrieve(cp));
}
}
use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore in project jackrabbit-oak by apache.
the class AsyncIndexUpdateTest method cpCleanupWErrors.
@Test
public void cpCleanupWErrors() throws Exception {
MemoryNodeStore store = new MemoryNodeStore();
FaultyIndexEditorProvder provider = new FaultyIndexEditorProvder();
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);
assertTrue("Expecting no checkpoints", store.listCheckpoints().size() == 0);
AsyncIndexUpdate async = new AsyncIndexUpdate("async", store, provider);
async.run();
assertTrue("Error should have been triggered by the commit", provider.isFailed());
assertTrue("Expecting no checkpoints", store.listCheckpoints().size() == 0);
// OAK-3054 failure reports
AsyncIndexStats stats = async.getIndexStats();
String since = stats.getFailingSince();
assertTrue(stats.isFailing());
assertEquals(1, stats.getConsecutiveFailedExecutions());
assertEquals(since, stats.getLatestErrorTime());
TimeUnit.MILLISECONDS.sleep(100);
async.run();
assertTrue(stats.isFailing());
assertEquals(2, stats.getConsecutiveFailedExecutions());
assertEquals(since, stats.getFailingSince());
assertNotEquals(since, stats.getLatestErrorTime());
stats.fixed();
assertFalse(stats.isFailing());
assertEquals(0, stats.getConsecutiveFailedExecutions());
assertEquals("", stats.getFailingSince());
}
use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore in project jackrabbit-oak by apache.
the class NodeCounterIndexTest method createRepository.
protected ContentRepository createRepository() {
nodeStore = new MemoryNodeStore();
Oak oak = new Oak(nodeStore).with(new InitialContent()).with(new OpenSecurityProvider()).with(new PropertyIndexEditorProvider()).with(new NodeCounterEditorProvider()).withAsyncIndexing("async", TimeUnit.DAYS.toSeconds(1));
wb = oak.getWhiteboard();
return oak.createContentRepository();
}
use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore in project jackrabbit-oak by apache.
the class AsyncIndexUpdateTest method cpCleanupWUnrelatedChanges.
@Test
public void cpCleanupWUnrelatedChanges() throws Exception {
MemoryNodeStore 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);
assertTrue("Expecting no checkpoints", store.listCheckpoints().size() == 0);
AsyncIndexUpdate async = new AsyncIndexUpdate("async", store, provider);
async.run();
assertTrue("Expecting one checkpoint", store.listCheckpoints().size() == 1);
String firstCp = store.listCheckpoints().iterator().next();
// add content that's hidden from indexing
builder = store.getRoot().builder();
builder.child("testRoot").child(":hidden");
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
async.run();
assertTrue("Expecting one checkpoint", store.listCheckpoints().size() == 1);
String secondCp = store.listCheckpoints().iterator().next();
assertFalse("Store should keep only second checkpoint", secondCp.equals(firstCp));
assertEquals(secondCp, store.getRoot().getChildNode(ASYNC).getString("async"));
}
use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore 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());
}
Aggregations