Search in sources :

Example 11 with VersionGCStats

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

the class NodeDocumentTest method getPreviousDocLeavesAfterGC1.

@Test
public void getPreviousDocLeavesAfterGC1() throws Exception {
    DocumentNodeStore ns = createTestStore(200);
    Revision previous = ns.newRevision();
    NodeDocument root = getRootDocument(ns.getDocumentStore());
    int numLeaves = Iterators.size(root.getPreviousDocLeaves());
    // remove most recent previous doc
    NodeDocument toRemove = root.getAllPreviousDocs().next();
    int numDeleted = new SplitDocumentCleanUp(ns.getDocumentStore(), new VersionGCStats(), Collections.singleton(toRemove)).disconnect().deleteSplitDocuments();
    assertEquals(1, numDeleted);
    root = getRootDocument(ns.getDocumentStore());
    assertEquals(numLeaves - 1, Iterators.size(root.getPreviousDocLeaves()));
    Iterator<NodeDocument> it = root.getPreviousDocLeaves();
    while (it.hasNext()) {
        NodeDocument leaf = it.next();
        Revision r = leaf.getAllChanges().iterator().next();
        assertTrue(previous.compareRevisionTime(r) > 0);
        previous = r;
    }
    ns.dispose();
}
Also used : VersionGCStats(org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats) Test(org.junit.Test)

Example 12 with VersionGCStats

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

the class NodeDocumentTest method getPreviousDocLeavesAfterGC2.

@Test
public void getPreviousDocLeavesAfterGC2() throws Exception {
    DocumentNodeStore ns = createTestStore(200);
    Revision previous = ns.newRevision();
    NodeDocument root = getRootDocument(ns.getDocumentStore());
    int numLeaves = Iterators.size(root.getPreviousDocLeaves());
    // remove oldest previous doc
    NodeDocument toRemove = Iterators.getLast(root.getAllPreviousDocs());
    int numDeleted = new SplitDocumentCleanUp(ns.getDocumentStore(), new VersionGCStats(), Collections.singleton(toRemove)).disconnect().deleteSplitDocuments();
    assertEquals(1, numDeleted);
    root = getRootDocument(ns.getDocumentStore());
    assertEquals(numLeaves - 1, Iterators.size(root.getPreviousDocLeaves()));
    Iterator<NodeDocument> it = root.getPreviousDocLeaves();
    while (it.hasNext()) {
        NodeDocument leaf = it.next();
        Revision r = leaf.getAllChanges().iterator().next();
        assertTrue(previous.compareRevisionTime(r) > 0);
        previous = r;
    }
    ns.dispose();
}
Also used : VersionGCStats(org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats) Test(org.junit.Test)

Example 13 with VersionGCStats

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

the class NodeDocumentTest method getAllChangesAfterGC1.

@Test
public void getAllChangesAfterGC1() throws Exception {
    int numChanges = 200;
    DocumentNodeStore ns = createTestStore(numChanges);
    NodeDocument root = getRootDocument(ns.getDocumentStore());
    // remove most recent previous doc
    NodeDocument toRemove = root.getAllPreviousDocs().next();
    int numDeleted = new SplitDocumentCleanUp(ns.getDocumentStore(), new VersionGCStats(), Collections.singleton(toRemove)).disconnect().deleteSplitDocuments();
    assertEquals(1, numDeleted);
    numChanges -= Iterables.size(toRemove.getAllChanges());
    root = getRootDocument(ns.getDocumentStore());
    Revision previous = ns.newRevision();
    for (Revision r : root.getAllChanges()) {
        assertTrue(previous.compareRevisionTime(r) > 0);
        previous = r;
    }
    // numChanges + one revision when node was created
    assertEquals(numChanges + 1, Iterables.size(root.getAllChanges()));
    ns.dispose();
}
Also used : VersionGCStats(org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats) Test(org.junit.Test)

Example 14 with VersionGCStats

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

the class RevisionGCStatsTest method timers.

@Test
public void timers() {
    VersionGCStats vgcs = new VersionGCStats();
    vgcs.collectDeletedDocsElapsed = MILLISECONDS.toMicros(2);
    vgcs.checkDeletedDocsElapsed = MILLISECONDS.toMicros(3);
    vgcs.deleteDeletedDocsElapsed = MILLISECONDS.toMicros(5);
    vgcs.collectAndDeleteSplitDocsElapsed = MILLISECONDS.toMicros(7);
    vgcs.sortDocIdsElapsed = MILLISECONDS.toMicros(11);
    vgcs.updateResurrectedDocumentsElapsed = MILLISECONDS.toMicros(13);
    vgcs.active.start();
    while (vgcs.active.elapsed(MILLISECONDS) < 5) {
        // busy wait
        assertTrue(vgcs.active.isRunning());
    }
    vgcs.active.stop();
    stats.finished(vgcs);
    assertTimer(vgcs.active.elapsed(MILLISECONDS), RevisionGCStats.ACTIVE_TIMER);
    assertTimer(2, RevisionGCStats.READ_DOC_TIMER);
    assertTimer(3, RevisionGCStats.CHECK_DELETED_TIMER);
    assertTimer(5, RevisionGCStats.DELETE_DOC_TIMER);
    assertTimer(7, RevisionGCStats.DELETE_SPLIT_DOC_TIMER);
    assertTimer(11, RevisionGCStats.SORT_IDS_TIMER);
    assertTimer(13, RevisionGCStats.RESET_DELETED_FLAG_TIMER);
}
Also used : VersionGCStats(org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats) Test(org.junit.Test)

Example 15 with VersionGCStats

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

the class VersionGCStatsTest method addRunCumulative.

@Test
public void addRunCumulative() {
    VersionGCStats cumulative = new VersionGCStats();
    cumulative.addRun(stats);
    // double stats by adding to itself
    cumulative.addRun(cumulative);
    // now the stats must have doubled
    assertEquals(stats.active.elapsed(MICROSECONDS) * 2, cumulative.activeElapsed);
    assertEquals(stats.collectDeletedDocs.elapsed(MICROSECONDS) * 2, cumulative.collectDeletedDocsElapsed);
    assertEquals(stats.checkDeletedDocs.elapsed(MICROSECONDS) * 2, cumulative.checkDeletedDocsElapsed);
    assertEquals(stats.deleteDeletedDocs.elapsed(MICROSECONDS) * 2, cumulative.deleteDeletedDocsElapsed);
    assertEquals(stats.collectAndDeleteSplitDocs.elapsed(MICROSECONDS) * 2, cumulative.collectAndDeleteSplitDocsElapsed);
    assertEquals(stats.sortDocIds.elapsed(MICROSECONDS) * 2, cumulative.sortDocIdsElapsed);
    assertEquals(stats.updateResurrectedDocuments.elapsed(MICROSECONDS) * 2, cumulative.updateResurrectedDocumentsElapsed);
}
Also used : VersionGCStats(org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats) Test(org.junit.Test)

Aggregations

VersionGCStats (org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats)29 Test (org.junit.Test)26 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)20 MemoryDocumentStore (org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore)4 ChildNodeEntry (org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)2 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)2 BinaryPropertyState (org.apache.jackrabbit.oak.plugins.memory.BinaryPropertyState)2 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)2 AbstractIterator (com.google.common.collect.AbstractIterator)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Random (java.util.Random)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutionException (java.util.concurrent.ExecutionException)1 Semaphore (java.util.concurrent.Semaphore)1 TimeoutException (java.util.concurrent.TimeoutException)1