Search in sources :

Example 1 with Counting

use of org.apache.jackrabbit.oak.stats.Counting 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

AbstractDocumentNodeState (org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState)1 PathRev (org.apache.jackrabbit.oak.plugins.document.PathRev)1 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)1 Counting (org.apache.jackrabbit.oak.stats.Counting)1 Test (org.junit.Test)1