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:09:04 UTC

svn commit: r1683230 - in /jackrabbit/oak/branches/1.2: ./ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java

Author: amitj
Date: Wed Jun  3 05:09:04 2015
New Revision: 1683230

URL: http://svn.apache.org/r1683230
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.2/   (props changed)
    jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java

Propchange: jackrabbit/oak/branches/1.2/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jun  3 05:09:04 2015
@@ -1,3 +1,3 @@
 /jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1672350,1672468,1672537,1672603,1672642,1672644,1672834-1672835,1673351,1673410,1673414,1673436,1673644,1673662-1673664,1673669,1673695,1674046,1674065,1674075,1674107,1674228,1674880,1675054-1675055,1675332,1675354,1675357,1675382,1675555,1675566,1675593,1676198,1676237,1676407,1676458,1676539,1676670,1676693,1676703,1676725,1677579,1677581,1677609,1677611,1677774,1677939,1677991,1678173,1678323,1678758,1678938,1678954,1679144,1679165,1679191,1679235,1680182,1680222,1680232,1680236,1680461,1680633,1680643,1680805-1680806,1680903,1681282,1681767,1681918,1682218,1682235,1682437,1682494,1682855,1682904,1683089
+/jackrabbit/oak/trunk:1672350,1672468,1672537,1672603,1672642,1672644,1672834-1672835,1673351,1673410,1673414,1673436,1673644,1673662-1673664,1673669,1673695,1674046,1674065,1674075,1674107,1674228,1674880,1675054-1675055,1675332,1675354,1675357,1675382,1675555,1675566,1675593,1676198,1676237,1676407,1676458,1676539,1676670,1676693,1676703,1676725,1677579,1677581,1677609,1677611,1677774,1677939,1677991,1678173,1678323,1678758,1678938,1678954,1679144,1679165,1679191,1679235,1680182,1680222,1680232,1680236,1680461,1680633,1680643,1680805-1680806,1680903,1681282,1681767,1681918,1682218,1682235,1682437,1682494,1682855,1682904,1683089,1683213
 /jackrabbit/trunk:1345480

Modified: jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java?rev=1683230&r1=1683229&r2=1683230&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java (original)
+++ jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java Wed Jun  3 05:09:04 2015
@@ -35,12 +35,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;
@@ -214,6 +216,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");
@@ -221,9 +237,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");
@@ -367,7 +384,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);
                 }
@@ -397,6 +414,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();