Search in sources :

Example 1 with MarkSweepGarbageCollector

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

the class MongoBlobGCTest method checkConsistencyPathLogging.

@Test
public void checkConsistencyPathLogging() 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(86400, executor, rootFolder);
    gcObj.checkConsistency();
    customLogs.finished();
    assertBlobReferenceRecords(2, 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 2 with MarkSweepGarbageCollector

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

the class MongoBlobGCTest method checkMark.

@Test
public void checkMark() throws Exception {
    String rootFolder = folder.newFolder().getAbsolutePath();
    LogCustomizer customLogs = LogCustomizer.forLogger(MarkSweepGarbageCollector.class.getName()).enable(Level.TRACE).filter(Level.TRACE).create();
    DataStoreState state = setUp(true, 10);
    log.info("{} blobs available : {}", state.blobsPresent.size(), state.blobsPresent);
    customLogs.starting();
    ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10);
    MarkSweepGarbageCollector gcObj = init(0, executor, rootFolder);
    gcObj.collectGarbage(true);
    customLogs.finished();
    assertBlobReferences(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 3 with MarkSweepGarbageCollector

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

the class MongoBlobGCTest method init.

private MarkSweepGarbageCollector init(int blobGcMaxAgeInSecs, ThreadPoolExecutor executor, String root) throws Exception {
    DocumentNodeStore store = mk.getNodeStore();
    String repoId = null;
    if (SharedDataStoreUtils.isShared(store.getBlobStore())) {
        repoId = ClusterRepositoryInfo.getOrCreateId(store);
        ((SharedDataStore) store.getBlobStore()).addMetadataRecord(new ByteArrayInputStream(new byte[0]), REPOSITORY.getNameFromId(repoId));
    }
    if (Strings.isNullOrEmpty(root)) {
        root = folder.newFolder().getAbsolutePath();
    }
    MarkSweepGarbageCollector gc = new MarkSweepGarbageCollector(new DocumentBlobReferenceRetriever(store), (GarbageCollectableBlobStore) store.getBlobStore(), executor, root, 5, 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 4 with MarkSweepGarbageCollector

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

the class MongoBlobGCTest method consistencyCheckInlined.

@Test
public void consistencyCheckInlined() throws Exception {
    DataStoreState state = setUp(true);
    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) MarkSweepGarbageCollector(org.apache.jackrabbit.oak.plugins.blob.MarkSweepGarbageCollector) Test(org.junit.Test)

Example 5 with MarkSweepGarbageCollector

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

the class MongoBlobGCTest method gc.

private Set<String> gc(int blobGcMaxAgeInSecs) throws Exception {
    ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10);
    MarkSweepGarbageCollector gc = init(blobGcMaxAgeInSecs, executor);
    gc.collectGarbage(false);
    assertEquals(0, executor.getTaskCount());
    return iterate();
}
Also used : ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) MarkSweepGarbageCollector(org.apache.jackrabbit.oak.plugins.blob.MarkSweepGarbageCollector)

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