Search in sources :

Example 11 with PathRev

use of org.apache.jackrabbit.oak.plugins.document.PathRev in project jackrabbit-oak by apache.

the class NodeCacheTest method testAsyncCache.

@Test
public void testAsyncCache() throws Exception {
    initializeNodeStore(true);
    ns.setNodeStateCache(new PathExcludingCache("/c"));
    NodeBuilder builder = ns.getRoot().builder();
    builder.child("a").child("b");
    builder.child("c").child("d");
    AbstractDocumentNodeState root = (AbstractDocumentNodeState) ns.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    PathRev prc = new PathRev("/c", root.getRootRevision());
    PathRev pra = new PathRev("/a", root.getRootRevision());
    Counting counter = nodeCache.getPersistentCacheStats().getPutRejectedAsCachedInSecCounter();
    long count0 = counter.getCount();
    //Adding this should be rejected
    nodeCache.evicted(prc, (DocumentNodeState) root.getChildNode("c"), RemovalCause.SIZE);
    long count1 = counter.getCount();
    assertTrue(count1 > count0);
    //Adding this should NOT be rejected
    nodeCache.evicted(pra, (DocumentNodeState) root.getChildNode("a"), RemovalCause.SIZE);
    long count2 = counter.getCount();
    assertEquals(count1, count2);
}
Also used : PathRev(org.apache.jackrabbit.oak.plugins.document.PathRev) AbstractDocumentNodeState(org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Counting(org.apache.jackrabbit.oak.stats.Counting) Test(org.junit.Test)

Aggregations

PathRev (org.apache.jackrabbit.oak.plugins.document.PathRev)11 Test (org.junit.Test)6 File (java.io.File)4 Revision (org.apache.jackrabbit.oak.plugins.document.Revision)4 StringValue (org.apache.jackrabbit.oak.plugins.document.util.StringValue)4 RevisionVector (org.apache.jackrabbit.oak.plugins.document.RevisionVector)3 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)2 RemovalCause (com.google.common.cache.RemovalCause)1 FileOutputStream (java.io.FileOutputStream)1 ArrayList (java.util.ArrayList)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 CacheLIRS (org.apache.jackrabbit.oak.cache.CacheLIRS)1 AbstractDocumentNodeState (org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState)1 Counting (org.apache.jackrabbit.oak.stats.Counting)1 Before (org.junit.Before)1