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();
}
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();
}
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();
}
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);
}
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);
}
Aggregations