Search in sources :

Example 6 with VersionGarbageCollector

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

the class DataStoreTrackerGCTest method addNodeSpecialChars.

private HashSet<String> addNodeSpecialChars(DocumentNodeStore ds) throws Exception {
    List<String> specialCharSets = Lists.newArrayList("q\\%22afdg\\%22", "a\nbcd", "a\n\rabcd", "012\\efg");
    HashSet<String> set = new HashSet<String>();
    NodeBuilder a = ds.getRoot().builder();
    int toBeDeleted = 0;
    for (int i = 0; i < specialCharSets.size(); i++) {
        Blob b = ds.createBlob(randomStream(i, 18432));
        NodeBuilder n = a.child("cspecial" + i);
        n.child(specialCharSets.get(i)).setProperty("x", b);
        Iterator<String> idIter = ((GarbageCollectableBlobStore) ds.getBlobStore()).resolveChunks(b.toString());
        List<String> ids = Lists.newArrayList(idIter);
        if (toBeDeleted != i) {
            set.addAll(ids);
        }
    }
    ds.merge(a, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    // Delete one node again
    a = ds.getRoot().builder();
    a.child("cspecial" + 0).remove();
    ds.merge(a, INSTANCE, EMPTY);
    // minutes
    long maxAge = 10;
    // 1. Go past GC age and check no GC done as nothing deleted
    clock.waitUntil(clock.getTime() + MINUTES.toMillis(maxAge));
    VersionGarbageCollector vGC = ds.getVersionGarbageCollector();
    VersionGarbageCollector.VersionGCStats stats = vGC.gc(0, MILLISECONDS);
    return set;
}
Also used : Blob(org.apache.jackrabbit.oak.api.Blob) VersionGarbageCollector(org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector) GarbageCollectableBlobStore(org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) HashSet(java.util.HashSet)

Aggregations

VersionGarbageCollector (org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector)6 Blob (org.apache.jackrabbit.oak.api.Blob)2 GarbageCollectableBlobStore (org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore)2 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)2 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)1 HashSet (java.util.HashSet)1 Random (java.util.Random)1 ExecutorService (java.util.concurrent.ExecutorService)1 Semaphore (java.util.concurrent.Semaphore)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 DocumentMK (org.apache.jackrabbit.oak.plugins.document.DocumentMK)1 DocumentNodeStoreHelper.createVersionGCSupport (org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreHelper.createVersionGCSupport)1 FormatVersion (org.apache.jackrabbit.oak.plugins.document.FormatVersion)1 VersionGCOptions (org.apache.jackrabbit.oak.plugins.document.VersionGCOptions)1 VersionGCSupport (org.apache.jackrabbit.oak.plugins.document.VersionGCSupport)1 VersionGCInfo (org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCInfo)1