use of org.apache.jackrabbit.oak.spi.filter.PathFilter in project jackrabbit-oak by apache.
the class SecondaryStoreObserverTest method basicSetup.
@Test
public void basicSetup() throws Exception {
PathFilter pathFilter = new PathFilter(of("/a"), empty);
SecondaryStoreObserver observer = createBuilder(pathFilter).buildObserver();
primary.addObserver(observer);
NodeBuilder nb = primary.getRoot().builder();
create(nb, "/a/b", "/a/c", "/x/y/z");
primary.merge(nb, EmptyHook.INSTANCE, CommitInfo.EMPTY);
dump(secondaryRoot(), "/a");
dump(primary.getRoot(), "/a");
assertEquals(secondaryRoot().getChildNode("a"), primary.getRoot().getChildNode("a"));
}
use of org.apache.jackrabbit.oak.spi.filter.PathFilter in project jackrabbit-oak by apache.
the class SecondaryStoreCacheTest method updateAndReadAtReadRev.
@Test
public void updateAndReadAtReadRev() throws Exception {
SecondaryStoreCache cache = createCache(new PathFilter(of("/a"), empty));
NodeBuilder nb = primary.getRoot().builder();
create(nb, "/a/b", "/a/c", "/x/y/z");
AbstractDocumentNodeState r1 = merge(nb);
// Update some other part of tree i.e. which does not change lastRev for /a/c
nb = primary.getRoot().builder();
create(nb, "/a/e/d");
AbstractDocumentNodeState r2 = merge(nb);
// Lookup should work fine
AbstractDocumentNodeState a_r2 = documentState(r2, "/a/c");
AbstractDocumentNodeState result = cache.getDocumentNodeState("/a/c", r2.getRootRevision(), a_r2.getLastRevision());
assertTrue(EqualsDiff.equals(a_r2, result));
// Child docs should only have lastRev and not root rev
assertTrue(result.hasProperty(DelegatingDocumentNodeState.PROP_LAST_REV));
assertFalse(result.hasProperty(DelegatingDocumentNodeState.PROP_REVISION));
// Root doc would have both meta props
assertTrue(secondary.getRoot().hasProperty(DelegatingDocumentNodeState.PROP_LAST_REV));
assertTrue(secondary.getRoot().hasProperty(DelegatingDocumentNodeState.PROP_REVISION));
nb = primary.getRoot().builder();
nb.child("a").child("c").remove();
AbstractDocumentNodeState r3 = merge(nb);
// Now look from older revision
result = cache.getDocumentNodeState("/a/c", r3.getRootRevision(), a_r2.getLastRevision());
// now as its not visible from head it would not be visible
assertNull(result);
}
use of org.apache.jackrabbit.oak.spi.filter.PathFilter in project jackrabbit-oak by apache.
the class SecondaryStoreCacheTest method readWithSecondaryLagging.
@Test
public void readWithSecondaryLagging() throws Exception {
PathFilter pathFilter = new PathFilter(of("/a"), empty);
SecondaryStoreCache cache = createBuilder(pathFilter).buildCache();
SecondaryStoreObserver observer = createBuilder(pathFilter).buildObserver(cache);
NodeBuilder nb = primary.getRoot().builder();
create(nb, "/a/b", "/a/c");
AbstractDocumentNodeState r0 = merge(nb);
AbstractDocumentNodeState a_c_0 = documentState(primary.getRoot(), "/a/c");
observer.contentChanged(r0, CommitInfo.EMPTY);
AbstractDocumentNodeState result = cache.getDocumentNodeState("/a/c", r0.getRootRevision(), a_c_0.getLastRevision());
assertTrue(EqualsDiff.equals(a_c_0, result));
// Make change in some other part of tree i.e. /a/c is unmodified
nb = primary.getRoot().builder();
create(nb, "/a/e");
AbstractDocumentNodeState r1 = merge(nb);
// Change is yet not pushed to secondary i.e. observer not invoked
// but lookup with latest root should still work fine if lastRev matches
result = cache.getDocumentNodeState("/a/c", r1.getRootRevision(), a_c_0.getLastRevision());
assertTrue(EqualsDiff.equals(a_c_0, result));
// Change which is not pushed would though not be visible
AbstractDocumentNodeState a_e_1 = documentState(primary.getRoot(), "/a/e");
result = cache.getDocumentNodeState("/a/e", r1.getRootRevision(), a_e_1.getLastRevision());
assertNull(result);
}
use of org.apache.jackrabbit.oak.spi.filter.PathFilter in project jackrabbit-oak by apache.
the class SecondaryStoreCacheTest method updateAndReadAtPrevRevision.
@Test
public void updateAndReadAtPrevRevision() throws Exception {
SecondaryStoreCache cache = createCache(new PathFilter(of("/a"), empty));
NodeBuilder nb = primary.getRoot().builder();
create(nb, "/a/b", "/a/c");
AbstractDocumentNodeState r0 = merge(nb);
AbstractDocumentNodeState a_c_0 = documentState(primary.getRoot(), "/a/c");
// Update some other part of tree i.e. which does not change lastRev for /a/c
nb = primary.getRoot().builder();
create(nb, "/a/c/d");
AbstractDocumentNodeState r1 = merge(nb);
AbstractDocumentNodeState a_c_1 = documentState(primary.getRoot(), "/a/c");
AbstractDocumentNodeState result = cache.getDocumentNodeState("/a/c", r1.getRootRevision(), a_c_1.getLastRevision());
assertTrue(EqualsDiff.equals(a_c_1, result));
// Read from older revision
result = cache.getDocumentNodeState("/a/c", r0.getRootRevision(), a_c_0.getLastRevision());
assertTrue(EqualsDiff.equals(a_c_0, result));
}
use of org.apache.jackrabbit.oak.spi.filter.PathFilter in project jackrabbit-oak by apache.
the class BundledDocumentDifferTest method configureSecondary.
private SecondaryStoreCache configureSecondary() {
SecondaryStoreBuilder builder = createBuilder(new PathFilter(of("/"), Collections.<String>emptyList()));
builder.metaPropNames(DocumentNodeStore.META_PROP_NAMES);
SecondaryStoreCache cache = builder.buildCache();
SecondaryStoreObserver observer = builder.buildObserver(cache);
store.addObserver(observer);
return cache;
}
Aggregations