Search in sources :

Example 11 with PathFilter

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"));
}
Also used : PathFilter(org.apache.jackrabbit.oak.spi.filter.PathFilter) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 12 with PathFilter

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);
}
Also used : PathFilter(org.apache.jackrabbit.oak.spi.filter.PathFilter) AbstractDocumentNodeState(org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 13 with PathFilter

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);
}
Also used : PathFilter(org.apache.jackrabbit.oak.spi.filter.PathFilter) AbstractDocumentNodeState(org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 14 with PathFilter

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));
}
Also used : PathFilter(org.apache.jackrabbit.oak.spi.filter.PathFilter) AbstractDocumentNodeState(org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 15 with PathFilter

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;
}
Also used : PathFilter(org.apache.jackrabbit.oak.spi.filter.PathFilter) SecondaryStoreCache(org.apache.jackrabbit.oak.plugins.document.secondary.SecondaryStoreCache) SecondaryStoreBuilder(org.apache.jackrabbit.oak.plugins.document.secondary.SecondaryStoreBuilder) SecondaryStoreObserver(org.apache.jackrabbit.oak.plugins.document.secondary.SecondaryStoreObserver)

Aggregations

PathFilter (org.apache.jackrabbit.oak.spi.filter.PathFilter)16 Test (org.junit.Test)13 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)12 AbstractDocumentNodeState (org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState)6 RevisionVector (org.apache.jackrabbit.oak.plugins.document.RevisionVector)4 Predicate (com.google.common.base.Predicate)3 Collections.emptyList (java.util.Collections.emptyList)3 StatisticsProvider (org.apache.jackrabbit.oak.stats.StatisticsProvider)3 RemovalCause (com.google.common.cache.RemovalCause)2 Lists (com.google.common.collect.Lists)2 File (java.io.File)2 Arrays.asList (java.util.Arrays.asList)2 Collections.singletonList (java.util.Collections.singletonList)2 List (java.util.List)2 Executors (java.util.concurrent.Executors)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 Consumer (java.util.function.Consumer)2 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 Predicates (com.google.common.base.Predicates)1 Strings (com.google.common.base.Strings)1