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 md...@apache.org on 2016/04/26 13:57:45 UTC

svn commit: r1741004 - in /jackrabbit/oak/trunk/oak-segment-next/src: main/java/org/apache/jackrabbit/oak/segment/ main/java/org/apache/jackrabbit/oak/segment/compaction/ main/java/org/apache/jackrabbit/oak/segment/file/ test/java/org/apache/jackrabbit...

Author: mduerig
Date: Tue Apr 26 11:57:45 2016
New Revision: 1741004

URL: http://svn.apache.org/viewvc?rev=1741004&view=rev
Log:
OAK-4276: Refactor / rework compaction strategies
Rename CompactionStrategy to SegmentGCOptions to better reflect its purpose. Also rename the related MBean accordingly.

Added:
    jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentGCOptions.java
      - copied, changed from r1741003, jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/CompactionStrategy.java
    jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGC.java
      - copied, changed from r1741003, jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/CompactionStrategyMBean.java
    jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGCMBean.java
      - copied, changed from r1741003, jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/DefaultCompactionStrategyMBean.java
Removed:
    jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/CompactionStrategy.java
    jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/CompactionStrategyMBean.java
    jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/DefaultCompactionStrategyMBean.java
Modified:
    jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java
    jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java
    jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/CompactionAndCleanupIT.java
    jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/SegmentCompactionIT.java

Modified: jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java?rev=1741004&r1=1741003&r2=1741004&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java (original)
+++ jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java Tue Apr 26 11:57:45 2016
@@ -24,11 +24,11 @@ import static org.apache.jackrabbit.oak.
 import static org.apache.jackrabbit.oak.commons.PropertiesUtil.toInteger;
 import static org.apache.jackrabbit.oak.commons.PropertiesUtil.toLong;
 import static org.apache.jackrabbit.oak.osgi.OsgiUtil.lookupConfigurationThenFramework;
-import static org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy.FORCE_AFTER_FAIL_DEFAULT;
-import static org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy.GAIN_THRESHOLD_DEFAULT;
-import static org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy.MEMORY_THRESHOLD_DEFAULT;
-import static org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy.PAUSE_DEFAULT;
-import static org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy.RETRY_COUNT_DEFAULT;
+import static org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions.FORCE_AFTER_FAIL_DEFAULT;
+import static org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions.GAIN_THRESHOLD_DEFAULT;
+import static org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions.MEMORY_THRESHOLD_DEFAULT;
+import static org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions.PAUSE_DEFAULT;
+import static org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions.RETRY_COUNT_DEFAULT;
 import static org.apache.jackrabbit.oak.spi.blob.osgi.SplitBlobStoreService.ONLY_STANDALONE_TARGET;
 import static org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.registerMBean;
 import static org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.scheduleWithFixedDelay;
@@ -65,9 +65,9 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.blob.datastore.SharedDataStoreUtils;
 import org.apache.jackrabbit.oak.plugins.blob.datastore.SharedDataStoreUtils.SharedStoreRecordType;
 import org.apache.jackrabbit.oak.plugins.identifier.ClusterRepositoryInfo;
-import org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy;
-import org.apache.jackrabbit.oak.segment.compaction.CompactionStrategyMBean;
-import org.apache.jackrabbit.oak.segment.compaction.DefaultCompactionStrategyMBean;
+import org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions;
+import org.apache.jackrabbit.oak.segment.compaction.SegmentRevisionGC;
+import org.apache.jackrabbit.oak.segment.compaction.SegmentRevisionGCMBean;
 import org.apache.jackrabbit.oak.segment.file.FileStore;
 import org.apache.jackrabbit.oak.segment.file.FileStore.Builder;
 import org.apache.jackrabbit.oak.segment.file.FileStoreGCMonitor;
@@ -228,7 +228,7 @@ public class SegmentNodeStoreService ext
     private Registration checkpointRegistration;
     private Registration revisionGCRegistration;
     private Registration blobGCRegistration;
-    private Registration compactionStrategyRegistration;
+    private Registration gcOptionsRegistration;
     private Registration segmentCacheMBean;
     private Registration stringCacheMBean;
     private Registration fsgcMonitorMBean;
@@ -325,8 +325,8 @@ public class SegmentNodeStoreService ext
         gcMonitor = new GCMonitorTracker();
         gcMonitor.start(whiteboard);
 
-        // Create the compaction strategy
-        CompactionStrategy compactionStrategy = newCompactionStrategy();
+        // Create the gc options
+        SegmentGCOptions gcOptions = newGCOptions();
 
         // Build the FileStore
         Builder builder = FileStore.builder(getDirectory())
@@ -335,7 +335,7 @@ public class SegmentNodeStoreService ext
                 .withMemoryMapping(getMode().equals("64"))
                 .withGCMonitor(gcMonitor)
                 .withStatisticsProvider(statisticsProvider)
-                .withCompactionStrategy(compactionStrategy);
+                .withGCOptions(gcOptions);
 
         if (customBlobStore) {
             log.info("Initializing SegmentNodeStore with BlobStore [{}]", blobStore);
@@ -344,14 +344,14 @@ public class SegmentNodeStoreService ext
 
         store = builder.build();
 
-        // Expose an MBean to provide information about the compaction strategy
+        // Expose an MBean to provide information about the gc options
 
-        compactionStrategyRegistration = registerMBean(
+        gcOptionsRegistration = registerMBean(
                 whiteboard,
-                CompactionStrategyMBean.class,
-                new DefaultCompactionStrategyMBean(compactionStrategy),
-                CompactionStrategyMBean.TYPE,
-                "Segment node store compaction strategy settings"
+                SegmentRevisionGC.class,
+                new SegmentRevisionGCMBean(gcOptions),
+                SegmentRevisionGC.TYPE,
+                "Segment node store gc options"
         );
 
         // Expose stats about the segment cache
@@ -436,7 +436,7 @@ public class SegmentNodeStoreService ext
         return true;
     }
 
-    private CompactionStrategy newCompactionStrategy() {
+    private SegmentGCOptions newGCOptions() {
         boolean pauseCompaction = toBoolean(property(PAUSE_COMPACTION), PAUSE_DEFAULT);
         int retryCount = toInteger(property(COMPACTION_RETRY_COUNT), RETRY_COUNT_DEFAULT);
         boolean forceAfterFail = toBoolean(property(COMPACTION_FORCE_AFTER_FAIL), FORCE_AFTER_FAIL_DEFAULT);
@@ -445,7 +445,7 @@ public class SegmentNodeStoreService ext
         byte memoryThreshold = getMemoryThreshold();
         byte gainThreshold = getGainThreshold();
 
-        CompactionStrategy segmentGCOptions = new CompactionStrategy(
+        SegmentGCOptions segmentGCOptions = new SegmentGCOptions(
                 pauseCompaction, memoryThreshold, gainThreshold, retryCount, forceAfterFail, lockWaitTime);
         segmentGCOptions.setForceAfterFail(forceAfterFail);
         return segmentGCOptions;
@@ -538,9 +538,9 @@ public class SegmentNodeStoreService ext
             blobGCRegistration.unregister();
             blobGCRegistration = null;
         }
-        if (compactionStrategyRegistration != null) {
-            compactionStrategyRegistration.unregister();
-            compactionStrategyRegistration = null;
+        if (gcOptionsRegistration != null) {
+            gcOptionsRegistration.unregister();
+            gcOptionsRegistration = null;
         }
         if (fsgcMonitorMBean != null) {
             fsgcMonitorMBean.unregister();

Copied: jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentGCOptions.java (from r1741003, jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/CompactionStrategy.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentGCOptions.java?p2=jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentGCOptions.java&p1=jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/CompactionStrategy.java&r1=1741003&r2=1741004&rev=1741004&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/CompactionStrategy.java (original)
+++ jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentGCOptions.java Tue Apr 26 11:57:45 2016
@@ -22,14 +22,14 @@ package org.apache.jackrabbit.oak.segmen
 /**
  * This class holds configuration options for segment store revision gc.
  */
-public class CompactionStrategy {
+public class SegmentGCOptions {
 
     /**
      * Default options: {@link #PAUSE_DEFAULT}, {@link #MEMORY_THRESHOLD_DEFAULT},
      * {@link #GAIN_THRESHOLD_DEFAULT}, {@link #RETRY_COUNT_DEFAULT},
      * {@link #FORCE_AFTER_FAIL_DEFAULT}, {@link #LOCK_WAIT_TIME_DEFAULT}.
      */
-    public static final CompactionStrategy DEFAULT = new CompactionStrategy();
+    public static final SegmentGCOptions DEFAULT = new SegmentGCOptions();
 
     /**
      * Default value for {@link #isPaused()}
@@ -73,8 +73,8 @@ public class CompactionStrategy {
 
     private int lockWaitTime = LOCK_WAIT_TIME_DEFAULT;
 
-    public CompactionStrategy(boolean paused, int memoryThreshold, int gainThreshold,
-                              int retryCount, boolean forceAfterFail, int lockWaitTime) {
+    public SegmentGCOptions(boolean paused, int memoryThreshold, int gainThreshold,
+                            int retryCount, boolean forceAfterFail, int lockWaitTime) {
         this.paused = paused;
         this.memoryThreshold = memoryThreshold;
         this.gainThreshold = gainThreshold;
@@ -83,7 +83,7 @@ public class CompactionStrategy {
         this.lockWaitTime = lockWaitTime;
     }
 
-    public CompactionStrategy() {
+    public SegmentGCOptions() {
         this(PAUSE_DEFAULT, MEMORY_THRESHOLD_DEFAULT, GAIN_THRESHOLD_DEFAULT,
                 RETRY_COUNT_DEFAULT, FORCE_AFTER_FAIL_DEFAULT, LOCK_WAIT_TIME_DEFAULT);
     }
@@ -100,7 +100,7 @@ public class CompactionStrategy {
      * @param paused
      * @return this instance
      */
-    public CompactionStrategy setPaused(boolean paused) {
+    public SegmentGCOptions setPaused(boolean paused) {
         this.paused = paused;
         return this;
     }
@@ -117,7 +117,7 @@ public class CompactionStrategy {
      * @param memoryThreshold
      * @return this instance
      */
-    public CompactionStrategy setMemoryThreshold(int memoryThreshold) {
+    public SegmentGCOptions setMemoryThreshold(int memoryThreshold) {
         this.memoryThreshold = memoryThreshold;
         return this;
     }
@@ -135,7 +135,7 @@ public class CompactionStrategy {
      * @param gainThreshold
      * @return this instance
      */
-    public CompactionStrategy setGainThreshold(int gainThreshold) {
+    public SegmentGCOptions setGainThreshold(int gainThreshold) {
         this.gainThreshold = gainThreshold;
         return this;
     }
@@ -155,7 +155,7 @@ public class CompactionStrategy {
      * @param retryCount
      * @return this instance
      */
-    public CompactionStrategy setRetryCount(int retryCount) {
+    public SegmentGCOptions setRetryCount(int retryCount) {
         this.retryCount = retryCount;
         return this;
     }
@@ -177,7 +177,7 @@ public class CompactionStrategy {
      * @param forceAfterFail
      * @return this instance
      */
-    public CompactionStrategy setForceAfterFail(boolean forceAfterFail) {
+    public SegmentGCOptions setForceAfterFail(boolean forceAfterFail) {
         this.forceAfterFail = forceAfterFail;
         return this;
     }
@@ -197,7 +197,7 @@ public class CompactionStrategy {
      * @return
      * @return this instance
      */
-    public CompactionStrategy setLockWaitTime(int lockWaitTime) {
+    public SegmentGCOptions setLockWaitTime(int lockWaitTime) {
         this.lockWaitTime = lockWaitTime;
         return this;
     }

Copied: jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGC.java (from r1741003, jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/CompactionStrategyMBean.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGC.java?p2=jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGC.java&p1=jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/CompactionStrategyMBean.java&r1=1741003&r2=1741004&rev=1741004&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/CompactionStrategyMBean.java (original)
+++ jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGC.java Tue Apr 26 11:57:45 2016
@@ -20,10 +20,10 @@
 package org.apache.jackrabbit.oak.segment.compaction;
 
 /**
- * This MBean exposes the settings from {@link CompactionStrategy}.
+ * This MBean exposes the settings from {@link SegmentGCOptions}.
  */
-public interface CompactionStrategyMBean {
-    String TYPE = "CompactionStrategy";
+public interface SegmentRevisionGC {
+    String TYPE = "SegmentRevisionGarbageCollection";
 
     /**
      * @return  {@code true} iff revision gc is paused.

Copied: jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGCMBean.java (from r1741003, jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/DefaultCompactionStrategyMBean.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGCMBean.java?p2=jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGCMBean.java&p1=jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/DefaultCompactionStrategyMBean.java&r1=1741003&r2=1741004&rev=1741004&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/DefaultCompactionStrategyMBean.java (original)
+++ jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGCMBean.java Tue Apr 26 11:57:45 2016
@@ -21,74 +21,74 @@ package org.apache.jackrabbit.oak.segmen
 
 import org.apache.jackrabbit.oak.commons.jmx.AnnotatedStandardMBean;
 
-public class DefaultCompactionStrategyMBean
+public class SegmentRevisionGCMBean
         extends AnnotatedStandardMBean
-        implements CompactionStrategyMBean {
+        implements SegmentRevisionGC {
 
-    private final CompactionStrategy strategy;
+    private final SegmentGCOptions gcOptions;
 
-    public DefaultCompactionStrategyMBean(CompactionStrategy strategy) {
-        super(CompactionStrategyMBean.class);
-        this.strategy = strategy;
+    public SegmentRevisionGCMBean(SegmentGCOptions gcOptions) {
+        super(SegmentRevisionGC.class);
+        this.gcOptions = gcOptions;
     }
 
     @Override
     public boolean isPausedCompaction() {
-        return strategy.isPaused();
+        return gcOptions.isPaused();
     }
 
     @Override
     public void setPausedCompaction(boolean paused) {
-        strategy.setPaused(paused);
+        gcOptions.setPaused(paused);
     }
 
     @Override
     public int getGainThreshold() {
-        return strategy.getGainThreshold();
+        return gcOptions.getGainThreshold();
     }
 
     @Override
     public void setGainThreshold(int gainThreshold) {
-        strategy.setGainThreshold(gainThreshold);
+        gcOptions.setGainThreshold(gainThreshold);
     }
 
     @Override
     public int getMemoryThreshold() {
-        return strategy.getMemoryThreshold();
+        return gcOptions.getMemoryThreshold();
     }
 
     @Override
     public void setMemoryThreshold(int memoryThreshold) {
-        strategy.setMemoryThreshold(memoryThreshold);
+        gcOptions.setMemoryThreshold(memoryThreshold);
     }
 
     @Override
     public int getRetryCount() {
-        return strategy.getRetryCount();
+        return gcOptions.getRetryCount();
     }
 
     @Override
     public void setRetryCount(int retryCount) {
-        strategy.setRetryCount(retryCount);
+        gcOptions.setRetryCount(retryCount);
     }
 
     @Override
     public boolean getForceAfterFail() {
-        return strategy.getForceAfterFail();
+        return gcOptions.getForceAfterFail();
     }
 
     @Override
     public void setForceAfterFail(boolean forceAfterFail) {
-        strategy.setForceAfterFail(forceAfterFail);
+        gcOptions.setForceAfterFail(forceAfterFail);
     }
 
     @Override
     public int getLockWaitTime() {
-        return strategy.getLockWaitTime();
+        return gcOptions.getLockWaitTime();
     }
 
     @Override
     public void setLockWaitTime(int lockWaitTime) {
-        strategy.setLockWaitTime(lockWaitTime);
+        gcOptions.setLockWaitTime(lockWaitTime);
     }
 }

Modified: jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java?rev=1741004&r1=1741003&r2=1741004&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java (original)
+++ jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java Tue Apr 26 11:57:45 2016
@@ -81,7 +81,7 @@ import org.apache.jackrabbit.oak.segment
 import org.apache.jackrabbit.oak.segment.SegmentTracker;
 import org.apache.jackrabbit.oak.segment.SegmentVersion;
 import org.apache.jackrabbit.oak.segment.SegmentWriter;
-import org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy;
+import org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions;
 import org.apache.jackrabbit.oak.spi.blob.BlobStore;
 import org.apache.jackrabbit.oak.spi.gc.GCMonitor;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
@@ -165,14 +165,14 @@ public class FileStore implements Segmen
     private final BackgroundThread compactionThread;
 
     /**
-     * This background thread periodically asks the {@code CompactionStrategy}
+     * This background thread periodically asks the {@code SegmentGCOptions}
      * to compare the approximate size of the repository with the available disk
      * space. The result of this comparison is stored in the state of this
      * {@code FileStore}.
      */
     private final BackgroundThread diskSpaceThread;
 
-    private final CompactionStrategy compactionStrategy;
+    private final SegmentGCOptions gcOptions;
 
     /**
      * Flag to request revision cleanup during the next flush.
@@ -202,8 +202,8 @@ public class FileStore implements Segmen
     private final AtomicLong approximateSize;
 
     /**
-     * This flag is periodically updated by calling the {@code
-     * CompactionStrategy} at regular intervals.
+     * This flag is periodically updated by calling the {@code SegmentGCOptions}
+     * at regular intervals.
      */
     private final AtomicBoolean sufficientDiskSpace;
 
@@ -249,7 +249,7 @@ public class FileStore implements Segmen
 
         private SegmentVersion version = SegmentVersion.LATEST_VERSION;
 
-        private CompactionStrategy compactionStrategy = CompactionStrategy.DEFAULT;
+        private SegmentGCOptions gcOptions = SegmentGCOptions.DEFAULT;
 
         private Builder(File directory) {
             this.directory = directory;
@@ -364,8 +364,8 @@ public class FileStore implements Segmen
         }
 
         @Nonnull
-        public Builder withCompactionStrategy(CompactionStrategy strategy) {
-            this.compactionStrategy = strategy;
+        public Builder withGCOptions(SegmentGCOptions gcOptions) {
+            this.gcOptions = gcOptions;
             return this;
         }
 
@@ -426,7 +426,7 @@ public class FileStore implements Segmen
         this.maxFileSize = builder.maxFileSize * MB;
         this.memoryMapping = builder.memoryMapping;
         this.gcMonitor = builder.gcMonitor;
-        this.compactionStrategy = builder.compactionStrategy;
+        this.gcOptions = builder.gcOptions;
 
         if (readOnly) {
             journalFile = new RandomAccessFile(new File(directory,
@@ -587,7 +587,7 @@ public class FileStore implements Segmen
         // FIXME OAK-4281: Rework memory estimation for compaction
         // What value should we use for delta?
         long delta = 0;
-        long needed = delta * compactionStrategy.getMemoryThreshold();
+        long needed = delta * gcOptions.getMemoryThreshold();
         if (needed >= avail) {
             gcMonitor.skipped(
                     "TarMK GC #{}: not enough available memory {} ({} bytes), needed {} ({} bytes)," +
@@ -597,7 +597,7 @@ public class FileStore implements Segmen
                     humanReadableByteCount(needed), needed,
                     humanReadableByteCount(delta), delta);
             if (cleanup) {
-                cleanupNeeded.set(!compactionStrategy.isPaused());
+                cleanupNeeded.set(!gcOptions.isPaused());
             }
             return false;
         }
@@ -605,12 +605,12 @@ public class FileStore implements Segmen
         Stopwatch watch = Stopwatch.createStarted();
         boolean compacted = false;
 
-        int gainThreshold = compactionStrategy.getGainThreshold();
+        int gainThreshold = gcOptions.getGainThreshold();
         boolean runCompaction = true;
         if (gainThreshold <= 0) {
             gcMonitor.info("TarMK GC #{}: estimation skipped because gain threshold value ({} <= 0)", GC_COUNT,
                 gainThreshold);
-        } else if (compactionStrategy.isPaused()) {
+        } else if (gcOptions.isPaused()) {
             gcMonitor.info("TarMK GC #{}: estimation skipped because compaction is paused", GC_COUNT);
         } else {
             gcMonitor.info("TarMK GC #{}: estimation started", GC_COUNT);
@@ -648,7 +648,7 @@ public class FileStore implements Segmen
         }
 
         if (runCompaction) {
-            if (!compactionStrategy.isPaused()) {
+            if (!gcOptions.isPaused()) {
                 compact();
                 compacted = true;
             } else {
@@ -656,7 +656,7 @@ public class FileStore implements Segmen
             }
         }
         if (cleanup) {
-            cleanupNeeded.set(!compactionStrategy.isPaused());
+            cleanupNeeded.set(!gcOptions.isPaused());
         }
         return compacted;
     }
@@ -1025,7 +1025,7 @@ public class FileStore implements Segmen
      * reference to them).
      */
     public void compact() throws IOException {
-        gcMonitor.info("TarMK GC #{}: compaction started, strategy={}", GC_COUNT, compactionStrategy);
+        gcMonitor.info("TarMK GC #{}: compaction started, gc options={}", GC_COUNT, gcOptions);
         Stopwatch watch = Stopwatch.createStarted();
 
         // FIXME OAK-4277: Finalise de-duplication caches
@@ -1061,7 +1061,7 @@ public class FileStore implements Segmen
         try {
             int cycles = 0;
             boolean success = false;
-            while (cycles++ < compactionStrategy.getRetryCount()
+            while (cycles++ < gcOptions.getRetryCount()
                 && !(success = setHead(before, after))) {
                 // Some other concurrent changes have been made.
                 // Rebase (and compact) those changes on top of the
@@ -1086,7 +1086,7 @@ public class FileStore implements Segmen
             } else {
                 gcMonitor.info("TarMK GC #{}: compaction gave up compacting concurrent commits after {} cycles.",
                         GC_COUNT, cycles - 1);
-                if (compactionStrategy.getForceAfterFail()) {
+                if (gcOptions.getForceAfterFail()) {
                     gcMonitor.info("TarMK GC #{}: compaction force compacting remaining commits", GC_COUNT);
                     if (!forceCompact(writer)) {
                         gcMonitor.warn("TarMK GC #{}: compaction failed to force compact remaining commits. " +
@@ -1114,7 +1114,7 @@ public class FileStore implements Segmen
     }
 
     private boolean forceCompact(SegmentWriter writer) throws InterruptedException, IOException {
-        if (rwLock.writeLock().tryLock(compactionStrategy.getLockWaitTime(), TimeUnit.SECONDS)) {
+        if (rwLock.writeLock().tryLock(gcOptions.getLockWaitTime(), TimeUnit.SECONDS)) {
             try {
                 SegmentNodeState head = getHead();
                 return setHead(head, compact(writer, head));
@@ -1411,7 +1411,7 @@ public class FileStore implements Segmen
     private void checkDiskSpace() {
         long repositoryDiskSpace = approximateSize.get();
         long availableDiskSpace = directory.getFreeSpace();
-        boolean updated = compactionStrategy.isDiskSpaceSufficient(repositoryDiskSpace, availableDiskSpace);
+        boolean updated = gcOptions.isDiskSpaceSufficient(repositoryDiskSpace, availableDiskSpace);
         boolean previous = sufficientDiskSpace.getAndSet(updated);
 
         if (previous && !updated) {

Modified: jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/CompactionAndCleanupIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/CompactionAndCleanupIT.java?rev=1741004&r1=1741003&r2=1741004&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/CompactionAndCleanupIT.java (original)
+++ jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/CompactionAndCleanupIT.java Tue Apr 26 11:57:45 2016
@@ -52,7 +52,7 @@ import org.apache.jackrabbit.oak.api.Blo
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy;
+import org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions;
 import org.apache.jackrabbit.oak.segment.file.FileStore;
 import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
 import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
@@ -211,7 +211,7 @@ public class CompactionAndCleanupIT {
         FileStore store = FileStore.builder(getFileStoreFolder())
                 .withMaxFileSize(2)
                 .withMemoryMapping(true)
-                .withCompactionStrategy(CompactionStrategy.DEFAULT.setForceAfterFail(true))
+                .withGCOptions(SegmentGCOptions.DEFAULT.setForceAfterFail(true))
                 .build();
         final SegmentNodeStore nodeStore = SegmentNodeStore.builder(store).build();
         final AtomicBoolean compactionSuccess = new AtomicBoolean(true);

Modified: jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/SegmentCompactionIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/SegmentCompactionIT.java?rev=1741004&r1=1741003&r2=1741004&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/SegmentCompactionIT.java (original)
+++ jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/SegmentCompactionIT.java Tue Apr 26 11:57:45 2016
@@ -73,11 +73,11 @@ import org.apache.jackrabbit.oak.cache.C
 import org.apache.jackrabbit.oak.commons.jmx.AnnotatedStandardMBean;
 import org.apache.jackrabbit.oak.plugins.commit.ConflictHook;
 import org.apache.jackrabbit.oak.plugins.commit.DefaultConflictHandler;
-import org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy;
-import org.apache.jackrabbit.oak.segment.compaction.DefaultCompactionStrategyMBean;
+import org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions;
+import org.apache.jackrabbit.oak.segment.compaction.SegmentRevisionGCMBean;
 import org.apache.jackrabbit.oak.segment.file.FileStore;
 import org.apache.jackrabbit.oak.segment.file.FileStoreGCMonitor;
-import org.apache.jackrabbit.oak.segment.compaction.CompactionStrategyMBean;
+import org.apache.jackrabbit.oak.segment.compaction.SegmentRevisionGC;
 import org.apache.jackrabbit.oak.segment.file.GCMonitorMBean;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
@@ -103,7 +103,7 @@ import org.slf4j.LoggerFactory;
  * <p>The test schedules a number of readers, writers, a compactor and holds some references for a certain time.
  * All of which can be interactively modified through the accompanying
  * {@link SegmentCompactionITMBean}, the
- * {@link CompactionStrategyMBean} and the
+ * {@link SegmentRevisionGC} and the
  * {@link GCMonitorMBean}.</p>
  *
  *<p>The test is <b>disabled</b> by default, to run it you need to set the {@code SegmentCompactionIT} system property:<br>
@@ -226,11 +226,11 @@ public class SegmentCompactionIT {
             }
         }, 1, 1, SECONDS);
 
-        CompactionStrategy gcOptions = CompactionStrategy.DEFAULT.setLockWaitTime(lockWaitTime);
+        SegmentGCOptions gcOptions = SegmentGCOptions.DEFAULT.setLockWaitTime(lockWaitTime);
         fileStore = FileStore.builder(folder.getRoot())
                 .withMemoryMapping(true)
                 .withGCMonitor(gcMonitor)
-                .withCompactionStrategy(gcOptions)
+                .withGCOptions(gcOptions)
                 .build();
         nodeStore = SegmentNodeStore.builder(fileStore).build();
 
@@ -239,8 +239,8 @@ public class SegmentCompactionIT {
         List<Registration> registrations = newArrayList();
         registrations.add(registerMBean(segmentCompactionMBean,
                 new ObjectName("IT:TYPE=Segment Compaction")));
-        registrations.add(registerMBean(new DefaultCompactionStrategyMBean(gcOptions),
-                new ObjectName("IT:TYPE=Compaction Strategy")));
+        registrations.add(registerMBean(new SegmentRevisionGCMBean(gcOptions),
+                new ObjectName("IT:TYPE=Segment Revision GC")));
         registrations.add(registerMBean(fileStoreGCMonitor,
                 new ObjectName("IT:TYPE=GC Monitor")));
         registrations.add(registerMBean(segmentCacheStats,