use of org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats in project jackrabbit-oak by apache.
the class MongoBlobGCTest method setUp.
public DataStoreState setUp(boolean deleteDirect, int count) throws Exception {
DocumentNodeStore s = mk.getNodeStore();
NodeBuilder a = s.getRoot().builder();
int number = count;
int maxDeleted = 5;
// track the number of the assets to be deleted
List<Integer> processed = Lists.newArrayList();
Random rand = new Random(47);
for (int i = 0; i < maxDeleted; i++) {
int n = rand.nextInt(number);
if (!processed.contains(n)) {
processed.add(n);
}
}
DataStoreState state = new DataStoreState();
for (int i = 0; i < number; i++) {
Blob b = s.createBlob(randomStream(i, 16516));
Iterator<String> idIter = ((GarbageCollectableBlobStore) s.getBlobStore()).resolveChunks(b.toString());
while (idIter.hasNext()) {
String chunk = idIter.next();
state.blobsAdded.add(chunk);
if (!processed.contains(i)) {
state.blobsPresent.add(chunk);
}
}
a.child("c" + i).setProperty("x", b);
// Add a duplicated entry
if (i == 0) {
a.child("cdup").setProperty("x", b);
}
}
s.merge(a, EmptyHook.INSTANCE, CommitInfo.EMPTY);
if (deleteDirect) {
for (int id : processed) {
deleteFromMongo("c" + id);
}
} else {
a = s.getRoot().builder();
for (int id : processed) {
a.child("c" + id).remove();
s.merge(a, EmptyHook.INSTANCE, CommitInfo.EMPTY);
}
// hours
long maxAge = 10;
// 1. Go past GC age and check no GC done as nothing deleted
clock.waitUntil(clock.getTime() + TimeUnit.MINUTES.toMillis(maxAge));
VersionGarbageCollector vGC = s.getVersionGarbageCollector();
VersionGCStats stats = vGC.gc(0, TimeUnit.MILLISECONDS);
Assert.assertEquals(processed.size(), stats.deletedDocGCCount);
}
return state;
}
use of org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats in project jackrabbit-oak by apache.
the class ResurrectNodeAfterRevisionGCTest method resurrectAfterGC.
@Test
public void resurrectAfterGC() throws Exception {
NodeBuilder builder = ns1.getRoot().builder();
builder.child("foo").child("bar");
builder.child("baz");
merge(ns1, builder);
builder = ns1.getRoot().builder();
builder.child("foo").child("bar").setProperty("p", 0);
merge(ns1, builder);
ns1.runBackgroundOperations();
ns2.runBackgroundOperations();
assertTrue(ns2.getRoot().getChildNode("foo").exists());
assertTrue(ns2.getRoot().getChildNode("foo").getChildNode("bar").exists());
assertEquals(0, ns2.getRoot().getChildNode("foo").getChildNode("bar").getLong("p"));
builder = ns1.getRoot().builder();
// removing both will result in a commit root on 0:/
builder.child("foo").remove();
builder.child("baz").remove();
merge(ns1, builder);
ns1.runBackgroundOperations();
ns2.runBackgroundOperations();
assertFalse(ns2.getRoot().getChildNode("foo").exists());
NodeDocument doc = ds2.find(Collection.NODES, getIdFromPath("/foo/bar"));
assertNotNull(doc);
NodeState state = doc.getNodeAtRevision(ns2, ns2.getHeadRevision(), null);
assertNull(state);
c.waitUntil(c.getTime() + TimeUnit.MINUTES.toMillis(5));
VersionGarbageCollector gc = ns1.getVersionGarbageCollector();
VersionGCStats stats = gc.gc(1, TimeUnit.MINUTES);
assertEquals(3, stats.deletedDocGCCount);
builder = ns1.getRoot().builder();
builder.child("foo").child("bar");
merge(ns1, builder);
builder = ns1.getRoot().builder();
// setting 'x' puts the commit root on /foo
builder.child("foo").setProperty("x", 0);
builder.child("foo").child("bar").setProperty("p", 1);
merge(ns1, builder);
builder = ns1.getRoot().builder();
builder.child("foo").child("bar").setProperty("p", 2);
merge(ns1, builder);
ns1.runBackgroundOperations();
ns2.runBackgroundOperations();
assertTrue(ns2.getRoot().getChildNode("foo").exists());
assertTrue(ns2.getRoot().getChildNode("foo").getChildNode("bar").exists());
assertEquals(2, ns2.getRoot().getChildNode("foo").getChildNode("bar").getLong("p"));
}
use of org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats in project jackrabbit-oak by apache.
the class NodeDocumentTest method getAllChangesAfterGC2.
@Test
public void getAllChangesAfterGC2() throws Exception {
int numChanges = 200;
DocumentNodeStore ns = createTestStore(numChanges);
NodeDocument root = getRootDocument(ns.getDocumentStore());
// 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);
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 VersionGCStatsTest method addRun.
@Test
public void addRun() {
VersionGCStats cumulative = new VersionGCStats();
cumulative.addRun(stats);
assertEquals(stats.active.elapsed(MICROSECONDS), cumulative.activeElapsed);
assertEquals(stats.collectDeletedDocs.elapsed(MICROSECONDS), cumulative.collectDeletedDocsElapsed);
assertEquals(stats.checkDeletedDocs.elapsed(MICROSECONDS), cumulative.checkDeletedDocsElapsed);
assertEquals(stats.deleteDeletedDocs.elapsed(MICROSECONDS), cumulative.deleteDeletedDocsElapsed);
assertEquals(stats.collectAndDeleteSplitDocs.elapsed(MICROSECONDS), cumulative.collectAndDeleteSplitDocsElapsed);
assertEquals(stats.sortDocIds.elapsed(MICROSECONDS), cumulative.sortDocIdsElapsed);
assertEquals(stats.updateResurrectedDocuments.elapsed(MICROSECONDS), cumulative.updateResurrectedDocumentsElapsed);
}
Aggregations