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 07:01:48 UTC
svn commit: r1683228 -
/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
Author: amitj
Date: Wed Jun 3 05:01:48 2015
New Revision: 1683228
URL: http://svn.apache.org/r1683228
Log:
OAK-2016: Make blob gc max age configurable in SegmentNodeStoreService
Added property 'blobGcMaxAgeInSecs' to controlgc max age
Merged revision 1683213 from trunk
Modified:
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
Modified: jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java?rev=1683228&r1=1683227&r2=1683228&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java Wed Jun 3 05:01:48 2015
@@ -34,12 +34,14 @@ import java.io.IOException;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.concurrent.Callable;
+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;
@@ -151,6 +153,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");
@@ -158,9 +174,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");
@@ -290,7 +307,7 @@ public class SegmentNodeStoreService ext
MarkSweepGarbageCollector gc = new MarkSweepGarbageCollector(
new SegmentBlobReferenceRetriever(store.getTracker()),
(GarbageCollectableBlobStore) store.getBlobStore(),
- executor);
+ executor, blobGcMaxAgeInSecs);
gc.collectGarbage();
}
};
@@ -319,6 +336,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();