use of org.apache.jackrabbit.oak.spi.state.ProxyNodeStore 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));
}
}
Aggregations