Search in sources :

Example 6 with MarkSweepGarbageCollector

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

the class SegmentDataStoreBlobGCIT method consistencyCheckWithRenegadeDelete.

@Test
public void consistencyCheckWithRenegadeDelete() throws Exception {
    DataStoreState state = setUp();
    // Simulate faulty state by deleting some blobs directly
    Random rand = new Random(87);
    List<String> existing = Lists.newArrayList(state.blobsPresent);
    long count = blobStore.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) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) MarkSweepGarbageCollector(org.apache.jackrabbit.oak.plugins.blob.MarkSweepGarbageCollector) Test(org.junit.Test)

Example 7 with MarkSweepGarbageCollector

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

the class SegmentDataStoreBlobGCIT method checkMark.

@Test
public void checkMark() throws Exception {
    LogCustomizer customLogs = LogCustomizer.forLogger(MarkSweepGarbageCollector.class.getName()).enable(Level.TRACE).filter(Level.TRACE).create();
    DataStoreState state = setUp(10);
    log.info("{} blobs available : {}", state.blobsPresent.size(), state.blobsPresent);
    customLogs.starting();
    ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10);
    String rootFolder = folder.newFolder().getAbsolutePath();
    MarkSweepGarbageCollector gcObj = init(0, executor, rootFolder);
    gcObj.collectGarbage(true);
    customLogs.finished();
    assertBlobReferenceRecords(state.blobsPresent, rootFolder);
}
Also used : LogCustomizer(org.apache.jackrabbit.oak.commons.junit.LogCustomizer) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) MarkSweepGarbageCollector(org.apache.jackrabbit.oak.plugins.blob.MarkSweepGarbageCollector) Test(org.junit.Test)

Example 8 with MarkSweepGarbageCollector

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

the class MongoBlobGCTest method checkGcPathLogging.

@Test
public void checkGcPathLogging() throws Exception {
    String rootFolder = folder.newFolder().getAbsolutePath();
    LogCustomizer customLogs = LogCustomizer.forLogger(MarkSweepGarbageCollector.class.getName()).enable(Level.TRACE).filter(Level.TRACE).create();
    setUp(false);
    customLogs.starting();
    ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10);
    MarkSweepGarbageCollector gcObj = init(0, executor, rootFolder);
    gcObj.collectGarbage(true);
    customLogs.finished();
    assertBlobReferenceRecords(1, rootFolder);
}
Also used : LogCustomizer(org.apache.jackrabbit.oak.commons.junit.LogCustomizer) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) MarkSweepGarbageCollector(org.apache.jackrabbit.oak.plugins.blob.MarkSweepGarbageCollector) Test(org.junit.Test)

Example 9 with MarkSweepGarbageCollector

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

the class MongoBlobGCTest method consistencyCheckInit.

@Test
public void consistencyCheckInit() throws Exception {
    DataStoreState state = setUp(true);
    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 10 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)

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