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 2017/08/11 08:35:00 UTC
svn commit: r1804758 - in
/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment:
compaction/SegmentGCOptions.java compaction/SegmentRevisionGCMBean.java
file/FileStore.java file/GCType.java
Author: mduerig
Date: Fri Aug 11 08:35:00 2017
New Revision: 1804758
URL: http://svn.apache.org/viewvc?rev=1804758&view=rev
Log:
OAK-6549: Move gcType to SegmentGCOptions
Removed:
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/GCType.java
Modified:
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentGCOptions.java
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGCMBean.java
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java
Modified: jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentGCOptions.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentGCOptions.java?rev=1804758&r1=1804757&r2=1804758&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentGCOptions.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentGCOptions.java Fri Aug 11 08:35:00 2017
@@ -21,6 +21,8 @@ package org.apache.jackrabbit.oak.segmen
import static com.google.common.base.Preconditions.checkArgument;
+import javax.annotation.Nonnull;
+
import org.apache.jackrabbit.oak.segment.file.GCNodeWriteMonitor;
/**
@@ -28,6 +30,12 @@ import org.apache.jackrabbit.oak.segment
*/
public class SegmentGCOptions {
+ // michid doc
+ public enum GCType {
+ FULL,
+ TAIL
+ }
+
/**
* Default value for {@link #isPaused()}
*/
@@ -81,6 +89,9 @@ public class SegmentGCOptions {
private int retainedGenerations = RETAINED_GENERATIONS_DEFAULT;
+ @Nonnull
+ private GCType gcType = GCType.FULL;
+
private boolean offline = false;
private int memoryThreshold = MEMORY_THRESHOLD_DEFAULT;
@@ -206,6 +217,17 @@ public class SegmentGCOptions {
return this;
}
+ // michid doc
+ @Nonnull
+ public GCType getGCType() {
+ return gcType;
+ }
+
+ // michid doc
+ public void setGCType(@Nonnull GCType gcType) {
+ this.gcType = gcType;
+ }
+
@Override
public String toString() {
if (offline) {
@@ -221,7 +243,8 @@ public class SegmentGCOptions {
", gcSizeDeltaEstimation=" + gcSizeDeltaEstimation +
", retryCount=" + retryCount +
", forceTimeout=" + forceTimeout +
- ", retainedGenerations=" + retainedGenerations + "}";
+ ", retainedGenerations=" + retainedGenerations +
+ ", gcType=" + gcType + "}";
}
}
@@ -345,4 +368,5 @@ public class SegmentGCOptions {
public GCNodeWriteMonitor getGCNodeWriteMonitor() {
return gcNodeWriteMonitor;
}
+
}
Modified: jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGCMBean.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGCMBean.java?rev=1804758&r1=1804757&r2=1804758&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGCMBean.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGCMBean.java Fri Aug 11 08:35:00 2017
@@ -27,7 +27,7 @@ import javax.annotation.Nonnull;
import org.apache.jackrabbit.oak.commons.jmx.AnnotatedStandardMBean;
import org.apache.jackrabbit.oak.segment.file.FileStore;
import org.apache.jackrabbit.oak.segment.file.FileStoreGCMonitor;
-import org.apache.jackrabbit.oak.segment.file.GCType;
+import org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions.GCType;
public class SegmentRevisionGCMBean
extends AnnotatedStandardMBean
@@ -116,12 +116,12 @@ public class SegmentRevisionGCMBean
@Override
public String getGCType() {
- return fileStore.getGcType().toString();
+ return gcOptions.getGCType().toString();
}
@Override
public void setGCType(String gcType) {
- fileStore.setGcType(GCType.valueOf(gcType));
+ gcOptions.setGCType(GCType.valueOf(gcType));
}
@Override
Modified: jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java?rev=1804758&r1=1804757&r2=1804758&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java Fri Aug 11 08:35:00 2017
@@ -18,7 +18,6 @@
*/
package org.apache.jackrabbit.oak.segment.file;
-import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Maps.newLinkedHashMap;
import static com.google.common.collect.Sets.newHashSet;
@@ -169,8 +168,6 @@ public class FileStore extends AbstractF
@Nonnull
private final SegmentNotFoundExceptionListener snfeListener;
- private volatile GCType gcType = GCType.FULL;
-
FileStore(final FileStoreBuilder builder) throws InvalidFileStoreVersionException, IOException {
super(builder);
@@ -280,35 +277,15 @@ public class FileStore extends AbstractF
return revisions.getHead().getSegmentId().getGcGeneration();
}
- public void setGcType(GCType gcType) {
- this.gcType = checkNotNull(gcType);
- }
-
- public GCType getGcType() {
- return gcType;
- }
-
/**
* @return a runnable for running garbage collection
*/
public Runnable getGCRunner() {
- return new SafeRunnable(format("TarMK revision gc [%s]", directory), new Runnable() {
- @Override
- public void run() {
- try {
- switch (gcType) {
- case FULL:
- fullGC();
- break;
- case TAIL:
- tailGC();
- break;
- default:
- throw new IllegalStateException("Invalid GC type");
- }
- } catch (IOException e) {
- log.error("Error running revision garbage collection", e);
- }
+ return new SafeRunnable(format("TarMK revision gc [%s]", directory), () -> {
+ try {
+ garbageCollector.run();
+ } catch (IOException e) {
+ log.error("Error running revision garbage collection", e);
}
});
}
@@ -593,6 +570,19 @@ public class FileStore extends AbstractF
this.statisticsProvider = statisticsProvider;
}
+ synchronized void run() throws IOException {
+ switch (gcOptions.getGCType()) {
+ case FULL:
+ runFull();
+ break;
+ case TAIL:
+ runTail();
+ break;
+ default:
+ throw new IllegalStateException("Invalid GC type");
+ }
+ }
+
synchronized void runFull() throws IOException {
run(this::compactFull);
}