Search in sources :

Example 11 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)

Example 12 with MarkSweepGarbageCollector

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

the class SegmentDataStoreBlobGCIT method consistencyCheckWithGc.

@Test
public void consistencyCheckWithGc() throws Exception {
    DataStoreState state = setUp();
    Set<String> existingAfterGC = gcInternal(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 13 with MarkSweepGarbageCollector

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

the class SegmentDataStoreBlobGCIT method init.

private MarkSweepGarbageCollector init(long blobGcMaxAgeInSecs, ThreadPoolExecutor executor, String root) throws Exception {
    String repoId = null;
    if (SharedDataStoreUtils.isShared(store.getBlobStore())) {
        repoId = ClusterRepositoryInfo.getOrCreateId(nodeStore);
        ((SharedDataStore) store.getBlobStore()).addMetadataRecord(new ByteArrayInputStream(new byte[0]), REPOSITORY.getNameFromId(repoId));
    }
    MarkSweepGarbageCollector gc = new MarkSweepGarbageCollector(new SegmentBlobReferenceRetriever(store), (GarbageCollectableBlobStore) store.getBlobStore(), executor, root, 2048, blobGcMaxAgeInSecs, repoId);
    return gc;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) SharedDataStore(org.apache.jackrabbit.oak.plugins.blob.SharedDataStore) MarkSweepGarbageCollector(org.apache.jackrabbit.oak.plugins.blob.MarkSweepGarbageCollector)

Example 14 with MarkSweepGarbageCollector

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

the class SegmentDataStoreBlobGCIT method consistencyCheckInlined.

@Test
public void consistencyCheckInlined() throws Exception {
    blobStore = new DataStoreBlobStore(DataStoreUtils.createFDS(new File(getWorkDir(), "datastore"), 16516));
    DataStoreState state = setUp();
    addInlined();
    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) File(java.io.File) MarkSweepGarbageCollector(org.apache.jackrabbit.oak.plugins.blob.MarkSweepGarbageCollector) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore) Test(org.junit.Test)

Example 15 with MarkSweepGarbageCollector

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

the class SegmentDataStoreBlobGCIT method consistencyCheckInit.

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