Search in sources :

Example 1 with BinaryPropertyState

use of org.apache.jackrabbit.oak.plugins.memory.BinaryPropertyState in project jackrabbit-oak by apache.

the class VersionGCQueryTest method noQueryForFirstLevelPrevDocs.

@Test
public void noQueryForFirstLevelPrevDocs() throws Exception {
    // create some garbage
    NodeBuilder builder = ns.getRoot().builder();
    for (int i = 0; i < 10; i++) {
        InputStream s = new RandomStream(10 * 1024, 42);
        PropertyState p = new BinaryPropertyState("p", ns.createBlob(s));
        builder.child("test").child("node-" + i).setProperty(p);
    }
    merge(builder);
    // overwrite with other binaries to force document splits
    builder = ns.getRoot().builder();
    for (int i = 0; i < 10; i++) {
        InputStream s = new RandomStream(10 * 1024, 17);
        PropertyState p = new BinaryPropertyState("p", ns.createBlob(s));
        builder.child("test").child("node-" + i).setProperty(p);
    }
    merge(builder);
    ns.runBackgroundOperations();
    builder = ns.getRoot().builder();
    builder.child("test").remove();
    merge(builder);
    ns.runBackgroundOperations();
    clock.waitUntil(clock.getTime() + TimeUnit.HOURS.toMillis(1));
    VersionGarbageCollector gc = new VersionGarbageCollector(ns, new VersionGCSupport(store));
    prevDocIds.clear();
    VersionGCStats stats = gc.gc(30, TimeUnit.MINUTES);
    assertEquals(11, stats.deletedDocGCCount);
    assertEquals(10, stats.splitDocGCCount);
    assertEquals(0, prevDocIds.size());
    assertEquals(1, Iterables.size(Utils.getAllDocuments(store)));
}
Also used : VersionGCStats(org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats) InputStream(java.io.InputStream) BinaryPropertyState(org.apache.jackrabbit.oak.plugins.memory.BinaryPropertyState) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) BinaryPropertyState(org.apache.jackrabbit.oak.plugins.memory.BinaryPropertyState) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 2 with BinaryPropertyState

use of org.apache.jackrabbit.oak.plugins.memory.BinaryPropertyState in project jackrabbit-oak by apache.

the class VersionGCQueryTest method queryDeepPreviousDocs.

@Test
public void queryDeepPreviousDocs() throws Exception {
    // create garbage until we have intermediate previous docs
    NodeBuilder builder = ns.getRoot().builder();
    builder.child("test");
    merge(builder);
    String id = Utils.getIdFromPath("/test");
    while (!Iterables.any(store.find(Collection.NODES, id).getPreviousRanges().values(), INTERMEDIATE)) {
        InputStream s = new RandomStream(10 * 1024, 42);
        PropertyState p = new BinaryPropertyState("p", ns.createBlob(s));
        builder = ns.getRoot().builder();
        builder.child("test").setProperty(p);
        merge(builder);
        builder = ns.getRoot().builder();
        builder.child("test").remove();
        merge(builder);
        ns.runBackgroundOperations();
    }
    int numPrevDocs = Iterators.size(store.find(Collection.NODES, id).getAllPreviousDocs());
    assertEquals(1, Iterators.size(Utils.getRootDocument(store).getAllPreviousDocs()));
    clock.waitUntil(clock.getTime() + TimeUnit.HOURS.toMillis(1));
    VersionGarbageCollector gc = new VersionGarbageCollector(ns, new VersionGCSupport(store));
    prevDocIds.clear();
    VersionGCStats stats = gc.gc(30, TimeUnit.MINUTES);
    assertEquals(1, stats.deletedDocGCCount);
    // GC also cleans up the previous doc on root
    assertEquals(numPrevDocs + 1, stats.splitDocGCCount);
    // but only does find calls for previous docs of /test
    assertEquals(numPrevDocs, prevDocIds.size());
    // at the end only the root document remains
    assertEquals(1, Iterables.size(Utils.getAllDocuments(store)));
}
Also used : VersionGCStats(org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats) InputStream(java.io.InputStream) BinaryPropertyState(org.apache.jackrabbit.oak.plugins.memory.BinaryPropertyState) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) BinaryPropertyState(org.apache.jackrabbit.oak.plugins.memory.BinaryPropertyState) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Aggregations

InputStream (java.io.InputStream)2 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)2 VersionGCStats (org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats)2 BinaryPropertyState (org.apache.jackrabbit.oak.plugins.memory.BinaryPropertyState)2 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)2 Test (org.junit.Test)2