Author: frm
Date: Tue Jan 16 13:37:26 2018
New Revision: 1821244

URL: http://svn.apache.org/viewvc?rev=1821244&view=rev
Log:
OAK-7158 - Prevent users from changing the number of retained generations

Backport r1821240 from trunk.

Modified:
    jackrabbit/oak/branches/1.8/   (props changed)
    
jackrabbit/oak/branches/1.8/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java
    
jackrabbit/oak/branches/1.8/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentGCOptions.java
    
jackrabbit/oak/branches/1.8/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGCMBean.java

Propchange: jackrabbit/oak/branches/1.8/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 16 13:37:26 2018
@@ -1,3 +1,3 @@
 /jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1820660-1820661,1820859,1820861,1820878,1820888,1820947,1821130,1821140-1821141
+/jackrabbit/oak/trunk:1820660-1820661,1820859,1820861,1820878,1820888,1820947,1821130,1821140-1821141,1821240
 /jackrabbit/trunk:1345480

Modified: 
jackrabbit/oak/branches/1.8/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.8/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java?rev=1821244&r1=1821243&r2=1821244&view=diff
==============================================================================
--- 
jackrabbit/oak/branches/1.8/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java
 (original)
+++ 
jackrabbit/oak/branches/1.8/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java
 Tue Jan 16 13:37:26 2018
@@ -26,7 +26,6 @@ import static org.apache.jackrabbit.oak.
 import static org.apache.jackrabbit.oak.commons.PropertiesUtil.toLong;
 import static 
org.apache.jackrabbit.oak.osgi.OsgiUtil.lookupConfigurationThenFramework;
 import static 
org.apache.jackrabbit.oak.plugins.blob.datastore.SharedDataStoreUtils.isShared;
-import static 
org.apache.jackrabbit.oak.spi.cluster.ClusterRepositoryInfo.getOrCreateId;
 import static 
org.apache.jackrabbit.oak.segment.CachingSegmentReader.DEFAULT_STRING_CACHE_MB;
 import static 
org.apache.jackrabbit.oak.segment.CachingSegmentReader.DEFAULT_TEMPLATE_CACHE_MB;
 import static 
org.apache.jackrabbit.oak.segment.SegmentCache.DEFAULT_SEGMENT_CACHE_MB;
@@ -69,6 +68,7 @@ import static org.apache.jackrabbit.oak.
 import static 
org.apache.jackrabbit.oak.segment.file.FileStoreBuilder.DEFAULT_MAX_FILE_SIZE;
 import static 
org.apache.jackrabbit.oak.segment.file.FileStoreBuilder.fileStoreBuilder;
 import static 
org.apache.jackrabbit.oak.spi.blob.osgi.SplitBlobStoreService.ONLY_STANDALONE_TARGET;
+import static 
org.apache.jackrabbit.oak.spi.cluster.ClusterRepositoryInfo.getOrCreateId;
 
 import java.io.ByteArrayInputStream;
 import java.io.Closeable;
@@ -81,6 +81,8 @@ import java.util.concurrent.TimeUnit;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
+import com.google.common.base.Supplier;
+import com.google.common.io.Closer;
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.ConfigurationPolicy;
@@ -97,7 +99,6 @@ import org.apache.jackrabbit.oak.api.jmx
 import org.apache.jackrabbit.oak.api.jmx.FileStoreBackupRestoreMBean;
 import org.apache.jackrabbit.oak.backup.impl.FileStoreBackupRestoreImpl;
 import org.apache.jackrabbit.oak.cache.CacheStats;
-import org.apache.jackrabbit.oak.spi.commit.ObserverTracker;
 import org.apache.jackrabbit.oak.osgi.OsgiWhiteboard;
 import org.apache.jackrabbit.oak.plugins.blob.BlobGC;
 import org.apache.jackrabbit.oak.plugins.blob.BlobGCMBean;
@@ -107,7 +108,6 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.blob.SharedDataStore;
 import org.apache.jackrabbit.oak.plugins.blob.datastore.BlobIdTracker;
 import 
org.apache.jackrabbit.oak.plugins.blob.datastore.SharedDataStoreUtils.SharedStoreRecordType;
-import org.apache.jackrabbit.oak.spi.cluster.ClusterRepositoryInfo;
 import org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions;
 import org.apache.jackrabbit.oak.segment.compaction.SegmentRevisionGC;
 import org.apache.jackrabbit.oak.segment.compaction.SegmentRevisionGCMBean;
@@ -119,6 +119,9 @@ import org.apache.jackrabbit.oak.segment
 import org.apache.jackrabbit.oak.segment.file.MetricsIOMonitor;
 import org.apache.jackrabbit.oak.spi.blob.BlobStore;
 import org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore;
+import org.apache.jackrabbit.oak.spi.cluster.ClusterRepositoryInfo;
+import org.apache.jackrabbit.oak.spi.commit.ObserverTracker;
+import org.apache.jackrabbit.oak.spi.descriptors.GenericDescriptors;
 import org.apache.jackrabbit.oak.spi.gc.GCMonitor;
 import org.apache.jackrabbit.oak.spi.gc.GCMonitorTracker;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
@@ -131,15 +134,11 @@ import org.apache.jackrabbit.oak.spi.whi
 import org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils;
 import org.apache.jackrabbit.oak.stats.Clock;
 import org.apache.jackrabbit.oak.stats.StatisticsProvider;
-import org.apache.jackrabbit.oak.spi.descriptors.GenericDescriptors;
 import org.osgi.framework.Constants;
 import org.osgi.service.component.ComponentContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Supplier;
-import com.google.common.io.Closer;
-
 /**
  * An OSGi wrapper for the segment node store.
  */
@@ -277,8 +276,9 @@ public class SegmentNodeStoreService {
             intValue = RETAINED_GENERATIONS_DEFAULT,
             label = "Compaction retained generations",
             description = "Number of segment generations to retain during 
garbage collection. " +
-                    "Must be set to at least 2. " +
-                    "Default value is '" + RETAINED_GENERATIONS_DEFAULT + "'."
+                "The number of generations defaults to " + 
RETAINED_GENERATIONS_DEFAULT + " and " +
+                "can't be changed. This configuration option is considered 
deprecated " +
+                "and will be removed in the future."
     )
     public static final String RETAINED_GENERATIONS = 
"compaction.retainedGenerations";
 
@@ -432,6 +432,14 @@ public class SegmentNodeStoreService {
                     + "Please use 'compaction.sizeDeltaEstimation' instead and 
"
                     + "'compaction.disableEstimation' to disable estimation.");
         }
+        if (configuration.getRetainedGenerations() != 
RETAINED_GENERATIONS_DEFAULT) {
+            log.warn(
+                "The number of retained generations defaults to {} and can't 
be " +
+                    "changed. This configuration option is considered 
deprecated " +
+                    "and will be removed in the future.",
+                RETAINED_GENERATIONS_DEFAULT
+            );
+        }
         SegmentGCOptions gcOptions = new 
SegmentGCOptions(configuration.getPauseCompaction(), 
configuration.getRetryCount(), configuration.getForceCompactionTimeout())
                 .setRetainedGenerations(configuration.getRetainedGenerations())
                 
.setGcSizeDeltaEstimation(configuration.getSizeDeltaEstimation())

Modified: 
jackrabbit/oak/branches/1.8/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentGCOptions.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.8/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentGCOptions.java?rev=1821244&r1=1821243&r2=1821244&view=diff
==============================================================================
--- 
jackrabbit/oak/branches/1.8/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentGCOptions.java
 (original)
+++ 
jackrabbit/oak/branches/1.8/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentGCOptions.java
 Tue Jan 16 13:37:26 2018
@@ -19,8 +19,6 @@
 
 package org.apache.jackrabbit.oak.segment.compaction;
 
-import static com.google.common.base.Preconditions.checkArgument;
-
 import javax.annotation.Nonnull;
 
 /**
@@ -196,7 +194,6 @@ public class SegmentGCOptions {
 
     /**
      * Number of segment generations to retain.
-     * @see #setRetainedGenerations(int)
      * @return  number of gc generations.
      */
     public int getRetainedGenerations() {
@@ -213,8 +210,6 @@ public class SegmentGCOptions {
      * @throws IllegalArgumentException if {@code retainGenerations < 2}
      */
     public SegmentGCOptions setRetainedGenerations(int retainedGenerations) {
-        checkArgument(retainedGenerations > 1,
-                "RetainedGenerations must not be below 2. Got %s", 
retainedGenerations);
         this.retainedGenerations = retainedGenerations;
         return this;
     }

Modified: 
jackrabbit/oak/branches/1.8/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGCMBean.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.8/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGCMBean.java?rev=1821244&r1=1821243&r2=1821244&view=diff
==============================================================================
--- 
jackrabbit/oak/branches/1.8/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGCMBean.java
 (original)
+++ 
jackrabbit/oak/branches/1.8/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGCMBean.java
 Tue Jan 16 13:37:26 2018
@@ -20,19 +20,24 @@
 package org.apache.jackrabbit.oak.segment.compaction;
 
 import static com.google.common.base.Preconditions.checkNotNull;
+import static 
org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions.RETAINED_GENERATIONS_DEFAULT;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 
 import org.apache.jackrabbit.oak.commons.jmx.AnnotatedStandardMBean;
+import org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions.GCType;
 import org.apache.jackrabbit.oak.segment.file.FileStore;
 import org.apache.jackrabbit.oak.segment.file.FileStoreGCMonitor;
-import org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions.GCType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class SegmentRevisionGCMBean
         extends AnnotatedStandardMBean
         implements SegmentRevisionGC {
 
+    private static final Logger log = 
LoggerFactory.getLogger(SegmentRevisionGCMBean.class);
+
     @Nonnull
     private final FileStore fileStore;
 
@@ -91,7 +96,14 @@ public class SegmentRevisionGCMBean
 
     @Override
     public void setRetainedGenerations(int retainedGenerations) {
-        gcOptions.setRetainedGenerations(retainedGenerations);
+        if (retainedGenerations != RETAINED_GENERATIONS_DEFAULT) {
+            log.warn(
+                "The number of retained generations defaults to {} and can't 
be " +
+                    "changed. This configuration option is considered 
deprecated " +
+                    "and will be removed in the future.",
+                RETAINED_GENERATIONS_DEFAULT
+            );
+        }
     }
 
     @Override


Reply via email to