Author: mduerig
Date: Tue Apr 26 11:57:34 2016
New Revision: 1741003
URL: http://svn.apache.org/viewvc?rev=1741003&view=rev
Log:
OAK-4276: Refactor / rework compaction strategies
Align CompactionStrategy and related with the implementation: remove all clean
up types and related parameters that don't exist anymore.
Modified:
jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/SegmentIdTable.java
jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStore.java
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/SegmentTracker.java
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
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/HeavyWriteIT.java
jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/SegmentCompactionIT.java
jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/SegmentDataStoreBlobGCIT.java
jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/SegmentIdTableTest.java
jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/SegmentOverflowExceptionIT.java
Modified:
jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/SegmentIdTable.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/SegmentIdTable.java?rev=1741003&r1=1741002&r2=1741003&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/SegmentIdTable.java
(original)
+++
jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/SegmentIdTable.java
Tue Apr 26 11:57:34 2016
@@ -28,7 +28,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
-import org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy;
+import com.google.common.base.Predicate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -194,15 +194,14 @@ public class SegmentIdTable {
return ((int) lsb) & (references.size() - 1);
}
- synchronized void clearSegmentIdTables(CompactionStrategy strategy) {
+ synchronized void clearSegmentIdTables(Predicate<SegmentId> canRemove) {
int size = references.size();
boolean dirty = false;
- for (int i = 0; i < size; i++) {
- WeakReference<SegmentId> reference = references.get(i);
+ for (WeakReference<SegmentId> reference : references) {
if (reference != null) {
SegmentId id = reference.get();
if (id != null) {
- if (strategy.canRemove(id)) {
+ if (canRemove.apply(id)) {
// we clear the reference here, but we must not
// remove the reference from the list, because
// that could cause duplicate references
Modified:
jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStore.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStore.java?rev=1741003&r1=1741002&r2=1741003&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStore.java
(original)
+++
jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStore.java
Tue Apr 26 11:57:34 2016
@@ -29,7 +29,6 @@ import static java.util.concurrent.TimeU
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.jackrabbit.oak.api.Type.LONG;
import static org.apache.jackrabbit.oak.api.Type.STRING;
-import static
org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy.NO_COMPACTION;
import java.io.Closeable;
import java.io.IOException;
@@ -50,7 +49,6 @@ import javax.annotation.Nonnull;
import org.apache.jackrabbit.oak.api.Blob;
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.api.PropertyState;
-import org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy;
import org.apache.jackrabbit.oak.spi.blob.BlobStore;
import org.apache.jackrabbit.oak.spi.commit.ChangeDispatcher;
import org.apache.jackrabbit.oak.spi.commit.CommitHook;
@@ -73,63 +71,19 @@ import org.slf4j.LoggerFactory;
public class SegmentNodeStore implements NodeStore, Observable {
public static class SegmentNodeStoreBuilder {
-
private final SegmentStore store;
-
private boolean isCreated;
- private CompactionStrategy compactionStrategy = NO_COMPACTION;
-
- private volatile SegmentNodeStore segmentNodeStore;
-
private SegmentNodeStoreBuilder(@Nonnull SegmentStore store) {
this.store = store;
}
- SegmentNodeStoreBuilder withCompactionStrategy(CompactionStrategy
compactionStrategy) {
- this.compactionStrategy = compactionStrategy;
- return this;
- }
-
- SegmentNodeStoreBuilder withCompactionStrategy(
- boolean pauseCompaction,
- boolean cloneBinaries,
- String cleanup,
- long cleanupTs,
- byte memoryThreshold,
- final int lockWaitTime,
- int retryCount,
- boolean forceAfterFail,
- byte gainThreshold) {
-
- compactionStrategy = new CompactionStrategy(
- pauseCompaction,
- cloneBinaries,
- CompactionStrategy.CleanupType.valueOf(cleanup),
- cleanupTs,
- memoryThreshold);
-
- compactionStrategy.setRetryCount(retryCount);
- compactionStrategy.setForceAfterFail(forceAfterFail);
- compactionStrategy.setLockWaitTime(lockWaitTime);
- compactionStrategy.setGainThreshold(gainThreshold);
-
- return this;
- }
-
- CompactionStrategy getCompactionStrategy() {
- checkState(isCreated);
- return compactionStrategy;
- }
-
@Nonnull
public SegmentNodeStore build() {
checkState(!isCreated);
isCreated = true;
- segmentNodeStore = new SegmentNodeStore(this);
- return segmentNodeStore;
+ return new SegmentNodeStore(this);
}
-
}
@Nonnull
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=1741003&r1=1741002&r2=1741003&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:34 2016
@@ -24,14 +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.CLEANUP_DEFAULT;
-import static
org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy.CLONE_BINARIES_DEFAULT;
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.CompactionStrategy.TIMESTAMP_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;
@@ -50,7 +47,6 @@ import org.apache.felix.scr.annotations.
import org.apache.felix.scr.annotations.ConfigurationPolicy;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.PropertyOption;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
@@ -70,7 +66,6 @@ import org.apache.jackrabbit.oak.plugins
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.CompactionStrategy.CleanupType;
import org.apache.jackrabbit.oak.segment.compaction.CompactionStrategyMBean;
import
org.apache.jackrabbit.oak.segment.compaction.DefaultCompactionStrategyMBean;
import org.apache.jackrabbit.oak.segment.file.FileStore;
@@ -145,35 +140,6 @@ public class SegmentNodeStoreService ext
public static final String CACHE = "cache";
@Property(
- boolValue = CLONE_BINARIES_DEFAULT,
- label = "Clone Binaries",
- description = "Clone the binary segments while performing
compaction"
- )
- public static final String COMPACTION_CLONE_BINARIES =
"compaction.cloneBinaries";
-
- @Property(options = {
- @PropertyOption(name = "CLEAN_ALL", value = "CLEAN_ALL"),
- @PropertyOption(name = "CLEAN_NONE", value = "CLEAN_NONE"),
- @PropertyOption(name = "CLEAN_OLD", value = "CLEAN_OLD") },
- value = "CLEAN_OLD",
- label = "Cleanup Strategy",
- description = "Cleanup strategy used for live in memory segment
references while performing cleanup. "+
- "1. CLEAN_NONE: All in memory references are considered
valid, " +
- "2. CLEAN_OLD: Only in memory references older than a " +
- "certain age are considered valid
(compaction.cleanup.timestamp), " +
- "3. CLEAN_ALL: None of the in memory references are
considered valid"
- )
- public static final String COMPACTION_CLEANUP = "compaction.cleanup";
-
- @Property(
- longValue = TIMESTAMP_DEFAULT,
- label = "Reference expiry time (ms)",
- description = "Time interval in ms beyond which in memory segment
references would be ignored " +
- "while performing cleanup"
- )
- public static final String COMPACTION_CLEANUP_TIMESTAMP =
"compaction.cleanup.timestamp";
-
- @Property(
byteValue = MEMORY_THRESHOLD_DEFAULT,
label = "Memory Multiplier",
description = "TarMK compaction available memory multiplier needed
to run compaction"
@@ -213,6 +179,7 @@ public class SegmentNodeStoreService ext
public static final String COMPACTION_FORCE_AFTER_FAIL =
"compaction.forceAfterFail";
public static final int COMPACTION_LOCK_WAIT_TIME_DEFAULT = 60;
+
@Property(
intValue = COMPACTION_LOCK_WAIT_TIME_DEFAULT,
label = "Compaction Lock Wait Time",
@@ -249,8 +216,6 @@ public class SegmentNodeStoreService ext
private ComponentContext context;
- private CompactionStrategy compactionStrategy;
-
@Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY,
policy = ReferencePolicy.DYNAMIC, target = ONLY_STANDALONE_TARGET)
private volatile BlobStore blobStore;
@@ -360,14 +325,17 @@ public class SegmentNodeStoreService ext
gcMonitor = new GCMonitorTracker();
gcMonitor.start(whiteboard);
- // Build the FileStore
+ // Create the compaction strategy
+ CompactionStrategy compactionStrategy = newCompactionStrategy();
+ // Build the FileStore
Builder builder = FileStore.builder(getDirectory())
.withCacheSize(getCacheSize())
.withMaxFileSize(getMaxFileSize())
.withMemoryMapping(getMode().equals("64"))
.withGCMonitor(gcMonitor)
- .withStatisticsProvider(statisticsProvider);
+ .withStatisticsProvider(statisticsProvider)
+ .withCompactionStrategy(compactionStrategy);
if (customBlobStore) {
log.info("Initializing SegmentNodeStore with BlobStore [{}]",
blobStore);
@@ -376,10 +344,6 @@ public class SegmentNodeStoreService ext
store = builder.build();
- // Create a compaction strategy
-
- compactionStrategy = newCompactionStrategy();
-
// Expose an MBean to provide information about the compaction strategy
compactionStrategyRegistration = registerMBean(
@@ -390,10 +354,6 @@ public class SegmentNodeStoreService ext
"Segment node store compaction strategy settings"
);
- // Let the FileStore be aware of the compaction strategy
-
- store.setCompactionStrategy(compactionStrategy);
-
// Expose stats about the segment cache
CacheStats segmentCacheStats =
store.getTracker().getSegmentCacheStats();
@@ -478,22 +438,17 @@ public class SegmentNodeStoreService ext
private CompactionStrategy newCompactionStrategy() {
boolean pauseCompaction = toBoolean(property(PAUSE_COMPACTION),
PAUSE_DEFAULT);
- boolean cloneBinaries = toBoolean(property(COMPACTION_CLONE_BINARIES),
CLONE_BINARIES_DEFAULT);
- long cleanupTs = toLong(property(COMPACTION_CLEANUP_TIMESTAMP),
TIMESTAMP_DEFAULT);
int retryCount = toInteger(property(COMPACTION_RETRY_COUNT),
RETRY_COUNT_DEFAULT);
boolean forceAfterFail =
toBoolean(property(COMPACTION_FORCE_AFTER_FAIL), FORCE_AFTER_FAIL_DEFAULT);
final int lockWaitTime =
toInteger(property(COMPACTION_LOCK_WAIT_TIME),
COMPACTION_LOCK_WAIT_TIME_DEFAULT);
- CleanupType cleanupType = getCleanUpType();
byte memoryThreshold = getMemoryThreshold();
byte gainThreshold = getGainThreshold();
- CompactionStrategy compactionStrategy = new
CompactionStrategy(pauseCompaction, cloneBinaries, cleanupType, cleanupTs,
memoryThreshold);
- compactionStrategy.setRetryCount(retryCount);
- compactionStrategy.setForceAfterFail(forceAfterFail);
- compactionStrategy.setGainThreshold(gainThreshold);
- compactionStrategy.setLockWaitTime(lockWaitTime);
- return compactionStrategy;
+ CompactionStrategy segmentGCOptions = new CompactionStrategy(
+ pauseCompaction, memoryThreshold, gainThreshold, retryCount,
forceAfterFail, lockWaitTime);
+ segmentGCOptions.setForceAfterFail(forceAfterFail);
+ return segmentGCOptions;
}
private boolean registerSegmentNodeStore() throws IOException {
@@ -504,9 +459,7 @@ public class SegmentNodeStoreService ext
OsgiWhiteboard whiteboard = new
OsgiWhiteboard(context.getBundleContext());
- SegmentNodeStore.SegmentNodeStoreBuilder nodeStoreBuilder =
SegmentNodeStore.builder(store);
- nodeStoreBuilder.withCompactionStrategy(compactionStrategy);
- segmentNodeStore = nodeStoreBuilder.build();
+ segmentNodeStore = SegmentNodeStore.builder(store).build();
observerTracker = new ObserverTracker(segmentNodeStore);
observerTracker.start(context.getBundleContext());
@@ -655,16 +608,6 @@ public class SegmentNodeStoreService ext
return Integer.parseInt(getMaxFileSizeProperty());
}
- private CleanupType getCleanUpType() {
- String cleanupType = property(COMPACTION_CLEANUP);
-
- if (cleanupType == null) {
- return CLEANUP_DEFAULT;
- }
-
- return CleanupType.valueOf(cleanupType);
- }
-
private byte getMemoryThreshold() {
String mt = property(COMPACTION_MEMORY_THRESHOLD);
Modified:
jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/SegmentTracker.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/SegmentTracker.java?rev=1741003&r1=1741002&r2=1741003&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/SegmentTracker.java
(original)
+++
jackrabbit/oak/trunk/oak-segment-next/src/main/java/org/apache/jackrabbit/oak/segment/SegmentTracker.java
Tue Apr 26 11:57:34 2016
@@ -33,12 +33,12 @@ import java.util.concurrent.atomic.Atomi
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
+import com.google.common.base.Predicate;
import com.google.common.cache.RemovalCause;
import org.apache.jackrabbit.oak.cache.CacheLIRS;
import org.apache.jackrabbit.oak.cache.CacheLIRS.EvictionCallback;
import org.apache.jackrabbit.oak.cache.CacheStats;
import org.apache.jackrabbit.oak.plugins.blob.ReferenceCollector;
-import org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy;
import org.apache.jackrabbit.oak.segment.file.FileStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -337,9 +337,9 @@ public class SegmentTracker {
// FIXME OAK-4285: Align cleanup of segment id tables with the new cleanup
strategy
// ith clean brutal we need to remove those ids that have been cleaned
// i.e. those whose segment was from an old generation
- public synchronized void clearSegmentIdTables(CompactionStrategy strategy)
{
+ public synchronized void clearSegmentIdTables(Predicate<SegmentId>
canRemove) {
for (SegmentIdTable table : tables) {
- table.clearSegmentIdTables(strategy);
+ table.clearSegmentIdTables(canRemove);
}
}
Modified:
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/CompactionStrategy.java?rev=1741003&r1=1741002&r2=1741003&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/CompactionStrategy.java
Tue Apr 26 11:57:34 2016
@@ -19,65 +19,31 @@
package org.apache.jackrabbit.oak.segment.compaction;
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static java.lang.System.currentTimeMillis;
-
-import javax.annotation.Nonnull;
-
-import org.apache.jackrabbit.oak.segment.SegmentId;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-// FIXME OAK-4276: Refactor / rework compaction strategies
-// Refactor this into a proper AST. Identify and remove "legacy" parts
+/**
+ * This class holds configuration options for segment store revision gc.
+ */
public class CompactionStrategy {
- private static final Logger LOG =
LoggerFactory.getLogger(CompactionStrategy.class);
-
- public enum CleanupType {
-
- /**
- * {@code CLEAN_ALL} <em>must</em> be used in conjunction with {@code
cloneBinaries}
- * otherwise segments can go away ({@code SegmentNotFoundException})
- * <p>
- * Pros: best compaction results
- * <p>
- * Cons: larger repo size <em>during</em> compaction (2x). High
chances that a currently
- * running diff (e.g. observation) fails with {@code
SegmentNotFoundException}.
- */
- CLEAN_ALL,
-
- CLEAN_NONE,
-
- /**
- * {@code CLEAN_OLD} with {@code cloneBinaries}
- * <p>
- * Pros: better compaction results
- * <p>
- * Cons: larger repo size {@code during} compaction (2x). {@code
SegmentNotFoundException}
- * with insufficiently large values for {@code olderThan}.
- * <p>
- * {@code CLEAN_OLD} without {@code cloneBinaries}
- * <p>
- * Pros: weakest compaction results, smaller size during compaction
(1x + size of
- * data-segments).
- * <p>
- * Cons: {@code SegmentNotFoundException} with insufficiently large
values for
- * {@code olderThan}.
- */
- CLEAN_OLD
- }
- public static final boolean PAUSE_DEFAULT = true;
-
- public static final boolean CLONE_BINARIES_DEFAULT = false;
-
- public static final CleanupType CLEANUP_DEFAULT = CleanupType.CLEAN_OLD;
+ /**
+ * 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 long TIMESTAMP_DEFAULT = 1000 * 60 * 60 * 10; // 10h
+ /**
+ * Default value for {@link #isPaused()}
+ */
+ public static final boolean PAUSE_DEFAULT = false;
+ /**
+ * Default value for {@link #getMemoryThreshold()}
+ */
public static final byte MEMORY_THRESHOLD_DEFAULT = 5;
+ /**
+ * Default value for {@link #getGainThreshold()}
+ */
public static final byte GAIN_THRESHOLD_DEFAULT = 10;
/**
@@ -91,129 +57,107 @@ public class CompactionStrategy {
public static final boolean FORCE_AFTER_FAIL_DEFAULT = false;
/**
- * No compaction at all
+ * Default value for {@link #getLockWaitTime()}
*/
- public static final CompactionStrategy NO_COMPACTION = new
CompactionStrategy(
- true, false, CleanupType.CLEAN_NONE, 0, MEMORY_THRESHOLD_DEFAULT);
+ public static final int LOCK_WAIT_TIME_DEFAULT = 60000;
- private boolean paused;
+ private boolean paused = PAUSE_DEFAULT;
- private boolean cloneBinaries;
+ private int memoryThreshold = MEMORY_THRESHOLD_DEFAULT;
- @Nonnull
- private CleanupType cleanupType;
-
- /**
- * anything that has a lifetime bigger than this will be removed. a value
of
- * 0 (or very small) acts like a CLEANUP.NONE, a value of -1 (or negative)
- * acts like a CLEANUP.ALL
- *
- */
- private long olderThan;
-
- private byte memoryThreshold = MEMORY_THRESHOLD_DEFAULT;
+ private int gainThreshold = GAIN_THRESHOLD_DEFAULT;
private int retryCount = RETRY_COUNT_DEFAULT;
private boolean forceAfterFail = FORCE_AFTER_FAIL_DEFAULT;
- // FIXME OAK-4276: Refactor / rework compaction strategies
- // Make the lock wait time configurable
- private int lockWaitTime = 60;
-
- private long compactionStart = currentTimeMillis();
-
- /**
- * Compaction gain estimate threshold beyond which compaction should run
- */
- private byte gainThreshold = GAIN_THRESHOLD_DEFAULT;
+ private int lockWaitTime = LOCK_WAIT_TIME_DEFAULT;
- public CompactionStrategy(boolean paused,
- boolean cloneBinaries, @Nonnull CleanupType cleanupType, long
olderThan, byte memoryThreshold) {
- checkArgument(olderThan >= 0);
+ public CompactionStrategy(boolean paused, int memoryThreshold, int
gainThreshold,
+ int retryCount, boolean forceAfterFail, int
lockWaitTime) {
this.paused = paused;
- this.cloneBinaries = cloneBinaries;
- this.cleanupType = checkNotNull(cleanupType);
- this.olderThan = olderThan;
this.memoryThreshold = memoryThreshold;
+ this.gainThreshold = gainThreshold;
+ this.retryCount = retryCount;
+ this.forceAfterFail = forceAfterFail;
+ this.lockWaitTime = lockWaitTime;
}
- public boolean canRemove(SegmentId id) {
- switch (cleanupType) {
- case CLEAN_ALL:
- return true;
- case CLEAN_NONE:
- return false;
- case CLEAN_OLD:
- long age = compactionStart - id.getCreationTime();
- if (age > olderThan) {
- LOG.info("TarMK released segment {} for gc. Age={}", id,
age);
- return true;
- } else {
- return false;
- }
- }
- return false;
- }
-
- public boolean cloneBinaries() {
- return cloneBinaries;
+ public CompactionStrategy() {
+ this(PAUSE_DEFAULT, MEMORY_THRESHOLD_DEFAULT, GAIN_THRESHOLD_DEFAULT,
+ RETRY_COUNT_DEFAULT, FORCE_AFTER_FAIL_DEFAULT,
LOCK_WAIT_TIME_DEFAULT);
}
+ /**
+ * @return {@code true} iff revision gc is paused.
+ */
public boolean isPaused() {
return paused;
}
- public void setPaused(boolean paused) {
+ /**
+ * Set revision gc to paused.
+ * @param paused
+ * @return this instance
+ */
+ public CompactionStrategy setPaused(boolean paused) {
this.paused = paused;
+ return this;
}
- public void setCloneBinaries(boolean cloneBinaries) {
- this.cloneBinaries = cloneBinaries;
- }
-
- public void setCleanupType(@Nonnull CleanupType cleanupType) {
- this.cleanupType = checkNotNull(cleanupType);
- }
-
- public void setOlderThan(long olderThan) {
- checkArgument(olderThan >= 0);
- this.olderThan = olderThan;
- }
-
- String getCleanupType() {
- return cleanupType.toString();
+ /**
+ * @return the memory threshold below which revision gc will not run.
+ */
+ public int getMemoryThreshold() {
+ return memoryThreshold;
}
- long getOlderThan() {
- return olderThan;
+ /**
+ * Set the memory threshold below which revision gc will not run.
+ * @param memoryThreshold
+ * @return this instance
+ */
+ public CompactionStrategy setMemoryThreshold(int memoryThreshold) {
+ this.memoryThreshold = memoryThreshold;
+ return this;
}
-
- @Override
- public String toString() {
- return "CompactionStrategy{" +
- "paused=" + paused +
- ", cloneBinaries=" + cloneBinaries +
- ", cleanupType=" + cleanupType +
- ", olderThan=" + olderThan +
- ", memoryThreshold=" + memoryThreshold +
- ", retryCount=" + retryCount +
- ", forceAfterFail=" + forceAfterFail +
- ", compactionStart=" + compactionStart +
- '}';
+ /**
+ * Get the gain estimate threshold beyond which revision gc should run
+ * @return gainThreshold
+ */
+ public int getGainThreshold() {
+ return gainThreshold;
}
- public void setCompactionStart(long ms) {
- this.compactionStart = ms;
+ /**
+ * Set the revision gain estimate threshold beyond which revision gc
should run
+ * @param gainThreshold
+ * @return this instance
+ */
+ public CompactionStrategy setGainThreshold(int gainThreshold) {
+ this.gainThreshold = gainThreshold;
+ return this;
}
- public byte getMemoryThreshold() {
- return memoryThreshold;
+ /**
+ * Get the number of tries to compact concurrent commits on top of already
+ * compacted commits
+ * @return retry count
+ */
+ public int getRetryCount() {
+ return retryCount;
}
- public void setMemoryThreshold(byte memoryThreshold) {
- this.memoryThreshold = memoryThreshold;
+ /**
+ * Set the number of tries to compact concurrent commits on top of already
+ * compacted commits
+ * @param retryCount
+ * @return this instance
+ */
+ public CompactionStrategy setRetryCount(int retryCount) {
+ this.retryCount = retryCount;
+ return this;
}
/**
@@ -231,53 +175,42 @@ public class CompactionStrategy {
* compacted commits after the maximum number of retries has been reached.
* Force committing tries to exclusively write lock the node store.
* @param forceAfterFail
+ * @return this instance
*/
- public void setForceAfterFail(boolean forceAfterFail) {
+ public CompactionStrategy setForceAfterFail(boolean forceAfterFail) {
this.forceAfterFail = forceAfterFail;
- }
-
- public void setLockWaitTime(int lockWaitTime) {
- this.lockWaitTime = lockWaitTime;
- }
-
- public int getLockWaitTime() {
- return lockWaitTime;
- }
-
- /**
- * Get the number of tries to compact concurrent commits on top of already
- * compacted commits
- * @return retry count
- */
- public int getRetryCount() {
- return retryCount;
+ return this;
}
/**
- * Set the number of tries to compact concurrent commits on top of already
- * compacted commits
- * @param retryCount
+ * Get the time to wait for the lock when force compacting.
+ * See {@link #setForceAfterFail(boolean)}
+ * @return lock wait time in seconds.
*/
- public void setRetryCount(int retryCount) {
- this.retryCount = retryCount;
+ public int getLockWaitTime() {
+ return lockWaitTime;
}
/**
- * Get the compaction gain estimate threshold beyond which compaction
should
- * run
- * @return gainThreshold
+ * Set the time to wait for the lock when force compacting.
+ * @param lockWaitTime lock wait time in seconds
+ * @return
+ * @return this instance
*/
- public byte getGainThreshold() {
- return gainThreshold;
+ public CompactionStrategy setLockWaitTime(int lockWaitTime) {
+ this.lockWaitTime = lockWaitTime;
+ return this;
}
- /**
- * Set the compaction gain estimate threshold beyond which compaction
should
- * run
- * @param gainThreshold
- */
- public void setGainThreshold(byte gainThreshold) {
- this.gainThreshold = gainThreshold;
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "{" +
+ "paused=" + paused +
+ ", memoryThreshold=" + memoryThreshold +
+ ", gainThreshold=" + gainThreshold +
+ ", retryCount=" + retryCount +
+ ", forceAfterFail=" + forceAfterFail +
+ ", lockWaitTime=" + lockWaitTime + '}';
}
/**
Modified:
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/CompactionStrategyMBean.java?rev=1741003&r1=1741002&r2=1741003&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/CompactionStrategyMBean.java
Tue Apr 26 11:57:34 2016
@@ -19,45 +19,46 @@
package org.apache.jackrabbit.oak.segment.compaction;
+/**
+ * This MBean exposes the settings from {@link CompactionStrategy}.
+ */
public interface CompactionStrategyMBean {
-
String TYPE = "CompactionStrategy";
- boolean isCloneBinaries();
-
- void setCloneBinaries(boolean cloneBinaries);
-
+ /**
+ * @return {@code true} iff revision gc is paused.
+ */
boolean isPausedCompaction();
- void setPausedCompaction(boolean pausedCompaction);
-
- String getCleanupStrategy();
-
- void setCleanupStrategy(String cleanup);
-
- long getOlderThan();
-
- void setOlderThan(long olderThan);
+ /**
+ * Set revision gc to paused.
+ * @param paused
+ * @return this instance
+ */
+ void setPausedCompaction(boolean paused);
- byte getMemoryThreshold();
+ /**
+ * Get the gain estimate threshold beyond which revision gc should run
+ * @return gainThreshold
+ */
+ int getGainThreshold();
- void setMemoryThreshold(byte memory);
+ /**
+ * Set the revision gain estimate threshold beyond which revision gc
should run
+ * @param gainThreshold
+ */
+ void setGainThreshold(int gainThreshold);
/**
- * Get whether or not to force compact concurrent commits on top of already
- * compacted commits after the maximum number of retries has been reached.
- * Force committing tries to exclusively write lock the node store.
- * @return {@code true} if force commit is on, {@code false} otherwise
+ * @return the memory threshold below which revision gc will not run.
*/
- boolean getForceAfterFail();
+ int getMemoryThreshold();
/**
- * Set whether or not to force compact concurrent commits on top of already
- * compacted commits after the maximum number of retries has been reached.
- * Force committing tries to exclusively write lock the node store.
- * @param forceAfterFail
+ * Set the memory threshold below which revision gc will not run.
+ * @param memoryThreshold
*/
- void setForceAfterFail(boolean forceAfterFail);
+ void setMemoryThreshold(int memoryThreshold);
/**
* Get the number of tries to compact concurrent commits on top of already
@@ -74,17 +75,32 @@ public interface CompactionStrategyMBean
void setRetryCount(int retryCount);
/**
- * Get the compaction gain estimate threshold beyond which compaction
should
- * run
- * @return gainThreshold
+ * Get whether or not to force compact concurrent commits on top of already
+ * compacted commits after the maximum number of retries has been reached.
+ * Force committing tries to exclusively write lock the node store.
+ * @return {@code true} if force commit is on, {@code false} otherwise
*/
- byte getGainThreshold();
+ boolean getForceAfterFail();
/**
- * Set the compaction gain estimate threshold beyond which compaction
should
- * run
- * @param gainThreshold
+ * Set whether or not to force compact concurrent commits on top of already
+ * compacted commits after the maximum number of retries has been reached.
+ * Force committing tries to exclusively write lock the node store.
+ * @param forceAfterFail
+ */
+ void setForceAfterFail(boolean forceAfterFail);
+
+ /**
+ * Get the time to wait for the lock when force compacting.
+ * See {@link #setForceAfterFail(boolean)}
+ * @return lock wait time in seconds.
+ */
+ int getLockWaitTime();
+
+ /**
+ * Set the time to wait for the lock when force compacting.
+ * @param lockWaitTime lock wait time in seconds
*/
- void setGainThreshold(byte gainThreshold);
+ void setLockWaitTime(int lockWaitTime);
}
Modified:
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/DefaultCompactionStrategyMBean.java?rev=1741003&r1=1741002&r2=1741003&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/DefaultCompactionStrategyMBean.java
Tue Apr 26 11:57:34 2016
@@ -20,7 +20,6 @@
package org.apache.jackrabbit.oak.segment.compaction;
import org.apache.jackrabbit.oak.commons.jmx.AnnotatedStandardMBean;
-import
org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy.CleanupType;
public class DefaultCompactionStrategyMBean
extends AnnotatedStandardMBean
@@ -34,53 +33,43 @@ public class DefaultCompactionStrategyMB
}
@Override
- public boolean isCloneBinaries() {
- return strategy.cloneBinaries();
- }
-
- @Override
- public void setCloneBinaries(boolean cloneBinaries) {
- strategy.setCloneBinaries(cloneBinaries);
- }
-
- @Override
public boolean isPausedCompaction() {
return strategy.isPaused();
}
@Override
- public void setPausedCompaction(boolean pausedCompaction) {
- strategy.setPaused(pausedCompaction);
+ public void setPausedCompaction(boolean paused) {
+ strategy.setPaused(paused);
}
@Override
- public String getCleanupStrategy() {
- return strategy.getCleanupType();
+ public int getGainThreshold() {
+ return strategy.getGainThreshold();
}
@Override
- public void setCleanupStrategy(String cleanup) {
- strategy.setCleanupType(CleanupType.valueOf(cleanup));
+ public void setGainThreshold(int gainThreshold) {
+ strategy.setGainThreshold(gainThreshold);
}
@Override
- public long getOlderThan() {
- return strategy.getOlderThan();
+ public int getMemoryThreshold() {
+ return strategy.getMemoryThreshold();
}
@Override
- public void setOlderThan(long olderThan) {
- strategy.setOlderThan(olderThan);
+ public void setMemoryThreshold(int memoryThreshold) {
+ strategy.setMemoryThreshold(memoryThreshold);
}
@Override
- public byte getMemoryThreshold() {
- return strategy.getMemoryThreshold();
+ public int getRetryCount() {
+ return strategy.getRetryCount();
}
@Override
- public void setMemoryThreshold(byte memory) {
- strategy.setMemoryThreshold(memory);
+ public void setRetryCount(int retryCount) {
+ strategy.setRetryCount(retryCount);
}
@Override
@@ -94,23 +83,12 @@ public class DefaultCompactionStrategyMB
}
@Override
- public int getRetryCount() {
- return strategy.getRetryCount();
+ public int getLockWaitTime() {
+ return strategy.getLockWaitTime();
}
@Override
- public void setRetryCount(int retryCount) {
- strategy.setRetryCount(retryCount);
+ public void setLockWaitTime(int lockWaitTime) {
+ strategy.setLockWaitTime(lockWaitTime);
}
-
- @Override
- public byte getGainThreshold() {
- return strategy.getGainThreshold();
- }
-
- @Override
- public void setGainThreshold(byte gainThreshold) {
- strategy.setGainThreshold(gainThreshold);
- }
-
}
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=1741003&r1=1741002&r2=1741003&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:34 2016
@@ -36,7 +36,6 @@ import static java.util.concurrent.TimeU
import static org.apache.jackrabbit.oak.commons.IOUtils.humanReadableByteCount;
import static
org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
import static org.apache.jackrabbit.oak.segment.SegmentId.isDataSegmentId;
-import static
org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy.NO_COMPACTION;
import java.io.Closeable;
import java.io.File;
@@ -63,6 +62,7 @@ import java.util.regex.Pattern;
import javax.annotation.Nonnull;
+import com.google.common.base.Predicates;
import com.google.common.base.Stopwatch;
import com.google.common.base.Supplier;
import org.apache.jackrabbit.oak.api.Blob;
@@ -172,7 +172,7 @@ public class FileStore implements Segmen
*/
private final BackgroundThread diskSpaceThread;
- private CompactionStrategy compactionStrategy = NO_COMPACTION;
+ private final CompactionStrategy compactionStrategy;
/**
* Flag to request revision cleanup during the next flush.
@@ -249,6 +249,8 @@ public class FileStore implements Segmen
private SegmentVersion version = SegmentVersion.LATEST_VERSION;
+ private CompactionStrategy compactionStrategy =
CompactionStrategy.DEFAULT;
+
private Builder(File directory) {
this.directory = directory;
}
@@ -361,6 +363,12 @@ public class FileStore implements Segmen
return this;
}
+ @Nonnull
+ public Builder withCompactionStrategy(CompactionStrategy strategy) {
+ this.compactionStrategy = strategy;
+ return this;
+ }
+
/**
* Create a new {@link FileStore} instance with the settings specified
in this
* builder. If none of the {@code with} methods have been called
before calling
@@ -418,6 +426,7 @@ public class FileStore implements Segmen
this.maxFileSize = builder.maxFileSize * MB;
this.memoryMapping = builder.memoryMapping;
this.gcMonitor = builder.gcMonitor;
+ this.compactionStrategy = builder.compactionStrategy;
if (readOnly) {
journalFile = new RandomAccessFile(new File(directory,
@@ -594,10 +603,9 @@ public class FileStore implements Segmen
}
Stopwatch watch = Stopwatch.createStarted();
- compactionStrategy.setCompactionStart(System.currentTimeMillis());
boolean compacted = false;
- byte gainThreshold = compactionStrategy.getGainThreshold();
+ int gainThreshold = compactionStrategy.getGainThreshold();
boolean runCompaction = true;
if (gainThreshold <= 0) {
gcMonitor.info("TarMK GC #{}: estimation skipped because gain
threshold value ({} <= 0)", GC_COUNT,
@@ -1017,8 +1025,6 @@ public class FileStore implements Segmen
* reference to them).
*/
public void compact() throws IOException {
- checkState(!compactionStrategy.equals(NO_COMPACTION),
- "You must set a compactionStrategy before calling compact");
gcMonitor.info("TarMK GC #{}: compaction started, strategy={}",
GC_COUNT, compactionStrategy);
Stopwatch watch = Stopwatch.createStarted();
@@ -1070,7 +1076,10 @@ public class FileStore implements Segmen
}
if (success) {
tracker.getWriter().addCachedNodes(gcGeneration, nodeCache);
- tracker.clearSegmentIdTables(compactionStrategy);
+ // FIXME OAK-4285: Align cleanup of segment id tables with the
new cleanup strategy
+ // ith clean brutal we need to remove those ids that have been
cleaned
+ // i.e. those whose segment was from an old generation
+
tracker.clearSegmentIdTables(Predicates.<SegmentId>alwaysFalse());
// FIXME OAK-4283: Align GCMonitor API with implementation
// Refactor GCMonitor: there is no more compaction map stats
gcMonitor.compacted(new long[]{}, new long[]{}, new long[]{});
@@ -1360,9 +1369,6 @@ public class FileStore implements Segmen
@Override
public void gc() {
- if (compactionStrategy == NO_COMPACTION) {
- log.warn("Call to gc while compaction strategy set to {}. ",
NO_COMPACTION);
- }
compactionThread.trigger();
}
@@ -1391,12 +1397,6 @@ public class FileStore implements Segmen
return emptyMap();
}
- public FileStore setCompactionStrategy(CompactionStrategy strategy) {
- this.compactionStrategy = strategy;
- log.info("Compaction strategy set to: {}", strategy);
- return this;
- }
-
private void setRevision(String rootRevision) {
fileStoreLock.writeLock().lock();
try {
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=1741003&r1=1741002&r2=1741003&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:34 2016
@@ -27,9 +27,6 @@ import static org.apache.jackrabbit.oak.
import static org.apache.jackrabbit.oak.commons.FixturesHelper.getFixtures;
import static
org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
import static org.apache.jackrabbit.oak.segment.SegmentNodeStore.builder;
-import static
org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy.CleanupType.CLEAN_ALL;
-import static
org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy.CleanupType.CLEAN_NONE;
-import static
org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy.CleanupType.CLEAN_OLD;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -47,7 +44,6 @@ import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
@@ -102,11 +98,6 @@ public class CompactionAndCleanupIT {
.withMaxFileSize(1)
.build();
final SegmentNodeStore nodeStore =
SegmentNodeStore.builder(fileStore).build();
- CompactionStrategy custom = new CompactionStrategy(false, false,
- CLEAN_OLD, TimeUnit.HOURS.toMillis(1), (byte) 0);
- // Use in memory compaction map as gains asserted later on
- // do not take additional space of the compaction map into
consideration
- fileStore.setCompactionStrategy(custom);
// 1a. Create a bunch of data
NodeBuilder extra = nodeStore.getRoot().builder();
@@ -172,10 +163,6 @@ public class CompactionAndCleanupIT {
fileStore.cleanup();
assertSize("post cleanup", fileStore.size(), 0, blobSize + 2 *
dataSize);
- // refresh the ts ref, to simulate a long wait time
- custom.setOlderThan(0);
- TimeUnit.MILLISECONDS.sleep(5);
-
boolean needsCompaction = true;
for (int i = 0; i < 3 && needsCompaction; i++) {
needsCompaction = fileStore.maybeCompact(false);
@@ -221,12 +208,13 @@ public class CompactionAndCleanupIT {
*/
@Test
public void testMixedSegments() throws Exception {
- FileStore store =
FileStore.builder(getFileStoreFolder()).withMaxFileSize(2).withMemoryMapping(true).build();
+ FileStore store = FileStore.builder(getFileStoreFolder())
+ .withMaxFileSize(2)
+ .withMemoryMapping(true)
+
.withCompactionStrategy(CompactionStrategy.DEFAULT.setForceAfterFail(true))
+ .build();
final SegmentNodeStore nodeStore =
SegmentNodeStore.builder(store).build();
final AtomicBoolean compactionSuccess = new AtomicBoolean(true);
- CompactionStrategy strategy = new CompactionStrategy(true, false,
CLEAN_NONE, 0, (byte) 5);
- strategy.setForceAfterFail(true);
- store.setCompactionStrategy(strategy);
NodeBuilder root = nodeStore.getRoot().builder();
createNodes(root.setChildNode("test"), 10, 3);
@@ -348,7 +336,6 @@ public class CompactionAndCleanupIT {
File repoDir = new File(getFileStoreFolder(), ref);
FileStore fileStore =
FileStore.builder(repoDir).withMaxFileSize(2).build();
final SegmentNodeStore nodeStore = builder(fileStore).build();
- fileStore.setCompactionStrategy(new CompactionStrategy(true,
false, CLEAN_NONE, 0, (byte) 5));
try {
// add some content
NodeBuilder preGCBuilder = nodeStore.getRoot().builder();
@@ -506,9 +493,6 @@ public class CompactionAndCleanupIT {
FileStore fileStore =
FileStore.builder(getFileStoreFolder()).withMaxFileSize(1).build();
try {
final SegmentNodeStore nodeStore =
SegmentNodeStore.builder(fileStore).build();
- CompactionStrategy strategy = new CompactionStrategy(false, false,
CLEAN_ALL, 0, (byte) 0);
- // CLEAN_ALL and persisted compaction map results in SNFE in
compaction map segments
- fileStore.setCompactionStrategy(strategy);
// Add a property
NodeBuilder builder = nodeStore.getRoot().builder();
@@ -547,8 +531,6 @@ public class CompactionAndCleanupIT {
@Test
public void checkpointDeduplicationTest() throws IOException,
CommitFailedException {
FileStore fileStore = FileStore.builder(getFileStoreFolder()).build();
- CompactionStrategy strategy = new CompactionStrategy(false, false,
CLEAN_NONE, 0, (byte) 0);
- fileStore.setCompactionStrategy(strategy);
try {
SegmentNodeStore nodeStore =
SegmentNodeStore.builder(fileStore).build();
NodeBuilder builder = nodeStore.getRoot().builder();
Modified:
jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/HeavyWriteIT.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/HeavyWriteIT.java?rev=1741003&r1=1741002&r2=1741003&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/HeavyWriteIT.java
(original)
+++
jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/HeavyWriteIT.java
Tue Apr 26 11:57:34 2016
@@ -21,7 +21,6 @@ package org.apache.jackrabbit.oak.segmen
import static org.apache.jackrabbit.oak.commons.CIHelper.travis;
import static
org.apache.jackrabbit.oak.commons.FixturesHelper.Fixture.SEGMENT_MK;
-import static
org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy.CleanupType.CLEAN_OLD;
import static org.junit.Assume.assumeTrue;
import java.io.ByteArrayInputStream;
@@ -35,8 +34,6 @@ import org.apache.jackrabbit.oak.api.Blo
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.commons.FixturesHelper;
import org.apache.jackrabbit.oak.commons.FixturesHelper.Fixture;
-import org.apache.jackrabbit.oak.segment.SegmentNodeStore;
-import org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy;
import org.apache.jackrabbit.oak.segment.file.FileStore;
import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
@@ -67,9 +64,6 @@ public class HeavyWriteIT {
public void heavyWrite() throws IOException, CommitFailedException,
InterruptedException {
final FileStore store =
FileStore.builder(getFileStoreFolder()).withMaxFileSize(128).withMemoryMapping(false).build();
final SegmentNodeStore nodeStore =
SegmentNodeStore.builder(store).build();
- CompactionStrategy custom = new CompactionStrategy(false, false,
- CLEAN_OLD, 30000, (byte) 0);
- store.setCompactionStrategy(custom);
int writes = 100;
final AtomicBoolean run = 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=1741003&r1=1741002&r2=1741003&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:34 2016
@@ -33,7 +33,6 @@ import static java.lang.System.getProper
import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
-import static
org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy.CleanupType.CLEAN_OLD;
import static org.junit.Assume.assumeTrue;
import static org.slf4j.helpers.MessageFormatter.arrayFormat;
import static org.slf4j.helpers.MessageFormatter.format;
@@ -136,7 +135,6 @@ public class SegmentCompactionIT {
private FileStore fileStore;
private SegmentNodeStore nodeStore;
- private CompactionStrategy compactionStrategy;
private Registration mBeanRegistration;
private volatile ListenableFuture<?> compactor =
immediateCancelledFuture();
@@ -228,30 +226,20 @@ public class SegmentCompactionIT {
}
}, 1, 1, SECONDS);
+ CompactionStrategy gcOptions =
CompactionStrategy.DEFAULT.setLockWaitTime(lockWaitTime);
fileStore = FileStore.builder(folder.getRoot())
.withMemoryMapping(true)
.withGCMonitor(gcMonitor)
+ .withCompactionStrategy(gcOptions)
.build();
- SegmentNodeStore.SegmentNodeStoreBuilder nodeStoreBuilder =
SegmentNodeStore
- .builder(fileStore);
- nodeStoreBuilder.withCompactionStrategy(false, false,
- CLEAN_OLD.toString(), CompactionStrategy.TIMESTAMP_DEFAULT,
- CompactionStrategy.MEMORY_THRESHOLD_DEFAULT, lockWaitTime,
- CompactionStrategy.RETRY_COUNT_DEFAULT,
- CompactionStrategy.FORCE_AFTER_FAIL_DEFAULT,
- CompactionStrategy.GAIN_THRESHOLD_DEFAULT);
- nodeStore = nodeStoreBuilder.build();
-
- compactionStrategy = nodeStoreBuilder
- .getCompactionStrategy();
- fileStore.setCompactionStrategy(compactionStrategy);
+ nodeStore = SegmentNodeStore.builder(fileStore).build();
CacheStats segmentCacheStats =
fileStore.getTracker().getSegmentCacheStats();
CacheStats stringCacheStats =
fileStore.getTracker().getStringCacheStats();
List<Registration> registrations = newArrayList();
registrations.add(registerMBean(segmentCompactionMBean,
new ObjectName("IT:TYPE=Segment Compaction")));
- registrations.add(registerMBean(new
DefaultCompactionStrategyMBean(compactionStrategy),
+ registrations.add(registerMBean(new
DefaultCompactionStrategyMBean(gcOptions),
new ObjectName("IT:TYPE=Compaction Strategy")));
registrations.add(registerMBean(fileStoreGCMonitor,
new ObjectName("IT:TYPE=GC Monitor")));
Modified:
jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/SegmentDataStoreBlobGCIT.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/SegmentDataStoreBlobGCIT.java?rev=1741003&r1=1741002&r2=1741003&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/SegmentDataStoreBlobGCIT.java
(original)
+++
jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/SegmentDataStoreBlobGCIT.java
Tue Apr 26 11:57:34 2016
@@ -59,7 +59,6 @@ import org.apache.jackrabbit.oak.plugins
import org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreUtils;
import org.apache.jackrabbit.oak.plugins.blob.datastore.SharedDataStoreUtils;
import org.apache.jackrabbit.oak.plugins.identifier.ClusterRepositoryInfo;
-import org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy;
import org.apache.jackrabbit.oak.segment.file.FileStore;
import org.apache.jackrabbit.oak.spi.blob.BlobStore;
import org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore;
@@ -99,10 +98,6 @@ public class SegmentDataStoreBlobGCIT {
.withBlobStore(blobStore).withMaxFileSize(256)
.withCacheSize(64).withMemoryMapping(false);
store = builder.build();
- CompactionStrategy compactionStrategy =
- new CompactionStrategy(false, true,
- CompactionStrategy.CleanupType.CLEAN_OLD, 0,
CompactionStrategy.MEMORY_THRESHOLD_DEFAULT);
- store.setCompactionStrategy(compactionStrategy);
nodeStore = SegmentNodeStore.builder(store).build();
}
return nodeStore;
Modified:
jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/SegmentIdTableTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/SegmentIdTableTest.java?rev=1741003&r1=1741002&r2=1741003&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/SegmentIdTableTest.java
(original)
+++
jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/SegmentIdTableTest.java
Tue Apr 26 11:57:34 2016
@@ -34,8 +34,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
-import org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy;
-import
org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy.CleanupType;
+import com.google.common.base.Predicate;
import org.apache.jackrabbit.oak.segment.memory.MemoryStore;
import org.junit.Test;
@@ -109,16 +108,14 @@ public class SegmentIdTableTest {
}
assertEquals(originalCount, tbl.getEntryCount());
assertEquals(0, tbl.getMapRebuildCount());
-
- tbl.clearSegmentIdTables(new CompactionStrategy(false, false,
- CleanupType.CLEAN_NONE, originalCount, (byte) 0) {
+
+ tbl.clearSegmentIdTables(new Predicate<SegmentId>() {
@Override
- public boolean canRemove(SegmentId id) {
+ public boolean apply(SegmentId id) {
return id.getMostSignificantBits() < 4;
}
-
});
-
+
assertEquals(4, tbl.getEntryCount());
for (SegmentId id : refs) {
Modified:
jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/SegmentOverflowExceptionIT.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/SegmentOverflowExceptionIT.java?rev=1741003&r1=1741002&r2=1741003&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/SegmentOverflowExceptionIT.java
(original)
+++
jackrabbit/oak/trunk/oak-segment-next/src/test/java/org/apache/jackrabbit/oak/segment/SegmentOverflowExceptionIT.java
Tue Apr 26 11:57:34 2016
@@ -20,8 +20,6 @@
package org.apache.jackrabbit.oak.segment;
import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
-import static
org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy.CleanupType.CLEAN_OLD;
-import static
org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy.MEMORY_THRESHOLD_DEFAULT;
import static org.junit.Assume.assumeTrue;
import java.io.ByteArrayInputStream;
@@ -32,7 +30,6 @@ import java.util.Random;
import com.google.common.collect.Iterables;
import org.apache.jackrabbit.oak.api.Blob;
import org.apache.jackrabbit.oak.api.CommitFailedException;
-import org.apache.jackrabbit.oak.segment.compaction.CompactionStrategy;
import org.apache.jackrabbit.oak.segment.file.FileStore;
import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
@@ -99,7 +96,6 @@ public class SegmentOverflowExceptionIT
FileStore fileStore =
FileStore.builder(getFileStoreFolder()).withGCMonitor(gcMonitor).build();
try {
final SegmentNodeStore nodeStore =
SegmentNodeStore.builder(fileStore).build();
- fileStore.setCompactionStrategy(new CompactionStrategy(false,
false, CLEAN_OLD, 1000, MEMORY_THRESHOLD_DEFAULT));
long start = System.currentTimeMillis();
int snfeCount = 0;
while (System.currentTimeMillis() - start < TIMEOUT) {