Search in sources :

Example 16 with MarkSweepGarbageCollector

use of org.apache.jackrabbit.oak.plugins.blob.MarkSweepGarbageCollector in project jackrabbit-oak by apache.

the class MongoBlobGCTest method consistencyCheckWithGc.

@Test
public void consistencyCheckWithGc() throws Exception {
    DataStoreState state = setUp(true);
    Set<String> existingAfterGC = gc(0);
    assertTrue(Sets.symmetricDifference(state.blobsPresent, existingAfterGC).isEmpty());
    ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10);
    MarkSweepGarbageCollector gcObj = init(86400, executor);
    long candidates = gcObj.checkConsistency();
    assertEquals(1, executor.getTaskCount());
    assertEquals(0, candidates);
}
Also used : ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) MarkSweepGarbageCollector(org.apache.jackrabbit.oak.plugins.blob.MarkSweepGarbageCollector) Test(org.junit.Test)

Example 17 with MarkSweepGarbageCollector

use of org.apache.jackrabbit.oak.plugins.blob.MarkSweepGarbageCollector in project jackrabbit-oak by apache.

the class MongoBlobGCTest method consistencyCheckWithRenegadeDelete.

@Test
public void consistencyCheckWithRenegadeDelete() throws Exception {
    DataStoreState state = setUp(true);
    // Simulate faulty state by deleting some blobs directly
    Random rand = new Random(87);
    List<String> existing = Lists.newArrayList(state.blobsPresent);
    GarbageCollectableBlobStore store = (GarbageCollectableBlobStore) mk.getNodeStore().getBlobStore();
    long count = store.countDeleteChunks(ImmutableList.of(existing.get(rand.nextInt(existing.size()))), 0);
    ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10);
    MarkSweepGarbageCollector gcObj = init(86400, executor);
    long candidates = gcObj.checkConsistency();
    assertEquals(1, executor.getTaskCount());
    assertEquals(count, candidates);
}
Also used : Random(java.util.Random) GarbageCollectableBlobStore(org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) MarkSweepGarbageCollector(org.apache.jackrabbit.oak.plugins.blob.MarkSweepGarbageCollector) Test(org.junit.Test)

Aggregations

MarkSweepGarbageCollector (org.apache.jackrabbit.oak.plugins.blob.MarkSweepGarbageCollector)17 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)14 Test (org.junit.Test)12 LogCustomizer (org.apache.jackrabbit.oak.commons.junit.LogCustomizer)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 SharedDataStore (org.apache.jackrabbit.oak.plugins.blob.SharedDataStore)3 Random (java.util.Random)2 GarbageCollectableBlobStore (org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore)2 Supplier (com.google.common.base.Supplier)1 File (java.io.File)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 SimpleValueFactory (org.apache.jackrabbit.commons.SimpleValueFactory)1 Descriptors (org.apache.jackrabbit.oak.api.Descriptors)1 CacheStatsMBean (org.apache.jackrabbit.oak.api.jmx.CacheStatsMBean)1 CheckpointMBean (org.apache.jackrabbit.oak.api.jmx.CheckpointMBean)1 FileStoreBackupRestoreMBean (org.apache.jackrabbit.oak.api.jmx.FileStoreBackupRestoreMBean)1 FileStoreBackupRestoreImpl (org.apache.jackrabbit.oak.backup.impl.FileStoreBackupRestoreImpl)1 BlobGC (org.apache.jackrabbit.oak.plugins.blob.BlobGC)1 BlobGCMBean (org.apache.jackrabbit.oak.plugins.blob.BlobGCMBean)1