You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by am...@apache.org on 2015/06/03 04:59:15 UTC
svn commit: r1683213 -
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
Author: amitj
Date: Wed Jun 3 02:59:15 2015
New Revision: 1683213
URL: http://svn.apache.org/r1683213
Log:
OAK-2016: Make blob gc max age configurable in SegmentNodeStoreService
Added property 'blobGcMaxAgeInSecs' to controlgc max age
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java?rev=1683213&r1=1683212&r2=1683213&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java Wed Jun 3 02:59:15 2015
@@ -37,12 +37,14 @@ import java.io.File;
import java.io.IOException;
import java.util.Dictionary;
import java.util.Hashtable;
+import java.util.Map;
import org.apache.commons.io.FilenameUtils;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.ConfigurationPolicy;
import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Modified;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.PropertyOption;
import org.apache.felix.scr.annotations.Reference;
@@ -241,6 +243,20 @@ public class SegmentNodeStoreService ext
private WhiteboardExecutor executor;
private boolean customBlobStore;
+ /**
+ * Blob modified before this time duration would be considered for Blob GC
+ */
+ private static final long DEFAULT_BLOB_GC_MAX_AGE = 24 * 60 * 60;
+ @Property (longValue = DEFAULT_BLOB_GC_MAX_AGE,
+ label = "Blob GC Max Age (in secs)",
+ description = "Blob Garbage Collector (GC) logic will only consider those blobs for GC which " +
+ "are not accessed recently (currentTime - lastModifiedTime > blobGcMaxAgeInSecs). For " +
+ "example as per default only those blobs which have been created 24 hrs ago will be " +
+ "considered for GC"
+ )
+ public static final String PROP_BLOB_GC_MAX_AGE = "blobGcMaxAgeInSecs";
+ private long blobGcMaxAgeInSecs = DEFAULT_BLOB_GC_MAX_AGE;
+
@Override
protected synchronized SegmentNodeStore getNodeStore() {
checkState(delegate != null, "service must be activated when used");
@@ -248,9 +264,10 @@ public class SegmentNodeStoreService ext
}
@Activate
- private void activate(ComponentContext context) throws IOException {
+ private void activate(ComponentContext context, Map<String, ?> config) throws IOException {
this.context = context;
this.customBlobStore = Boolean.parseBoolean(lookup(context, CUSTOM_BLOB_STORE));
+ modified(config);
if (blobStore == null && customBlobStore) {
log.info("BlobStore use enabled. SegmentNodeStore would be initialized when BlobStore would be available");
@@ -397,7 +414,7 @@ public class SegmentNodeStoreService ext
MarkSweepGarbageCollector gc = new MarkSweepGarbageCollector(
new SegmentBlobReferenceRetriever(store.getTracker()),
(GarbageCollectableBlobStore) store.getBlobStore(),
- executor,
+ executor, blobGcMaxAgeInSecs,
ClusterRepositoryInfo.getId(delegate));
gc.collectGarbage(sweep);
}
@@ -427,6 +444,14 @@ public class SegmentNodeStoreService ext
return null;
}
+ /**
+ * At runtime SegmentNodeStore only picks up modification of certain properties
+ */
+ @Modified
+ protected void modified(Map<String, ?> config){
+ blobGcMaxAgeInSecs = toLong(config.get(PROP_BLOB_GC_MAX_AGE), DEFAULT_BLOB_GC_MAX_AGE);
+ }
+
@Deactivate
public synchronized void deactivate() {
unregisterNodeStore();