Search in sources :

Example 1 with JournalGarbageCollector

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

the class JournalIT method doLargeCleanupTest.

private void doLargeCleanupTest(int offset, int size) throws Exception {
    Clock clock = new Clock.Virtual();
    DocumentMK mk1 = createMK(0, /* clusterId: 0 => uses clusterNodes collection */
    0, new MemoryDocumentStore(), new MemoryBlobStore());
    DocumentNodeStore ns1 = mk1.getNodeStore();
    // make sure we're visible and marked as active
    renewClusterIdLease(ns1);
    JournalGarbageCollector gc = new JournalGarbageCollector(ns1);
    clock.getTimeIncreasing();
    clock.getTimeIncreasing();
    // cleanup everything that might still be there
    gc.gc(0, TimeUnit.MILLISECONDS);
    // create entries as parametrized:
    for (int i = offset; i < size + offset; i++) {
        mk1.commit("/", "+\"regular" + i + "\": {}", null, null);
        // always run background ops to 'flush' the change
        // into the journal:
        ns1.runBackgroundOperations();
    }
    // sleep 100millis
    Thread.sleep(100);
    // should now be able to clean up everything
    assertEquals(size, gc.gc(0, TimeUnit.MILLISECONDS));
}
Also used : MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) JournalGarbageCollector(org.apache.jackrabbit.oak.plugins.document.JournalGarbageCollector) DocumentMK(org.apache.jackrabbit.oak.plugins.document.DocumentMK) DocumentNodeStore(org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore) MemoryBlobStore(org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore) Clock(org.apache.jackrabbit.oak.stats.Clock)

Aggregations

DocumentMK (org.apache.jackrabbit.oak.plugins.document.DocumentMK)1 DocumentNodeStore (org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore)1 JournalGarbageCollector (org.apache.jackrabbit.oak.plugins.document.JournalGarbageCollector)1 MemoryDocumentStore (org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore)1 MemoryBlobStore (org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore)1 Clock (org.apache.jackrabbit.oak.stats.Clock)1