This is an automated email from the ASF dual-hosted git repository.
daim pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push:
new dffc7af926 OAK-11453 : added support for setting max revision age for
full gc fr… (#2051)
dffc7af926 is described below
commit dffc7af926a422192db5aa9835478aeabdbd0c53
Author: Rishabh Kumar <[email protected]>
AuthorDate: Tue Feb 4 19:53:06 2025 +0530
OAK-11453 : added support for setting max revision age for full gc fr…
(#2051)
* OAK-11453 : added support for setting max revision age for full gc from
oak-run
* OAK-11453 : changed variable name for setting full gc max revision age
---------
Co-authored-by: Rishabh Kumar <[email protected]>
---
.../org/apache/jackrabbit/oak/run/RevisionsCommand.java | 12 ++++++++++++
.../oak/plugins/document/RevisionsCommandTest.java | 14 ++++++++++++--
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git
a/oak-run/src/main/java/org/apache/jackrabbit/oak/run/RevisionsCommand.java
b/oak-run/src/main/java/org/apache/jackrabbit/oak/run/RevisionsCommand.java
index eb3d6d86b5..07f6c4dc86 100644
--- a/oak-run/src/main/java/org/apache/jackrabbit/oak/run/RevisionsCommand.java
+++ b/oak-run/src/main/java/org/apache/jackrabbit/oak/run/RevisionsCommand.java
@@ -121,6 +121,7 @@ public class RevisionsCommand implements Command {
final OptionSpec<Long> olderThan;
final OptionSpec<Double> delay;
final OptionSpec<Double> fullGcDelayFactor;
+ final OptionSpec<Long> fullGcMaxAge;
final OptionSpec<?> continuous;
final OptionSpec<?> fullGCOnly;
final OptionSpec<Boolean> resetFullGC;
@@ -190,6 +191,10 @@ public class RevisionsCommand implements Command {
fullGcProgressSize = parser.accepts("fullGcProgressSize", "The
number of documents to check for " +
"garbage in each Full GC cycle")
.withRequiredArg().ofType(Integer.class).defaultsTo(10000);
+ fullGcMaxAge = parser.accepts("fullGcMaxAge", "The maximum age of
the document in seconds " +
+ "to be considered for Full GC i.e. Version Garbage
Collector (Full GC) logic will only consider those " +
+ "nodes for Full GC which are not accessed recently
(currentTime - lastModifiedTime > fullGcMaxAge)")
+
.withOptionalArg().ofType(Long.class).defaultsTo(TimeUnit.DAYS.toMillis(1));
}
public RevisionsOptions parse(String[] args) {
@@ -233,6 +238,10 @@ public class RevisionsCommand implements Command {
return fullGcProgressSize.value(options);
}
+ long getFullGcMaxAge() {
+ return fullGcMaxAge.value(options);
+ }
+
double getFullGcDelayFactor() {
return fullGcDelayFactor.value(options);
}
@@ -348,6 +357,7 @@ public class RevisionsCommand implements Command {
builder.setFullGCDelayFactor(options.getFullGcDelayFactor());
builder.setFullGCBatchSize(options.getFullGcBatchSize());
builder.setFullGCProgressSize(options.getFullGcProgressSize());
+
builder.setFullGcMaxAgeMillis(SECONDS.toMillis(options.getFullGcMaxAge()));
// create a VersionGCSupport while builder is read-write
VersionGCSupport gcSupport = builder.createVersionGCSupport();
@@ -379,6 +389,8 @@ public class RevisionsCommand implements Command {
System.out.println("FullGcDelayFactory is : " +
options.getFullGcDelayFactor());
System.out.println("FullGcBatchSize is : " +
options.getFullGcBatchSize());
System.out.println("FullGcProgressSize is : " +
options.getFullGcProgressSize());
+ System.out.println("FullGcMaxAgeInSecs is : " +
options.getFullGcMaxAge());
+ System.out.println("FullGcMaxAgeMillis is : " +
builder.getFullGcMaxAgeMillis());
VersionGarbageCollector gc = createVersionGC(builder.build(),
gcSupport, options.isDryRun(), builder);
VersionGCOptions gcOptions = gc.getOptions();
diff --git
a/oak-run/src/test/java/org/apache/jackrabbit/oak/plugins/document/RevisionsCommandTest.java
b/oak-run/src/test/java/org/apache/jackrabbit/oak/plugins/document/RevisionsCommandTest.java
index 30dd2c0750..ca60524191 100644
---
a/oak-run/src/test/java/org/apache/jackrabbit/oak/plugins/document/RevisionsCommandTest.java
+++
b/oak-run/src/test/java/org/apache/jackrabbit/oak/plugins/document/RevisionsCommandTest.java
@@ -18,8 +18,6 @@
*/
package org.apache.jackrabbit.oak.plugins.document;
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -203,6 +201,18 @@ public class RevisionsCommandTest {
assertTrue(output.contains("FullGcDelayFactory is : 2.0"));
assertTrue(output.contains("FullGcBatchSize is : 1000"));
assertTrue(output.contains("FullGcProgressSize is : 10000"));
+ assertTrue(output.contains("FullGcMaxAgeInSecs is : 86400"));
+ assertTrue(output.contains("FullGcMaxAgeMillis is : 86400000"));
+ }
+
+ @Test
+ public void fullGCWithMaxAgeInSecs() {
+ ns.dispose();
+
+ String output = captureSystemOut(new RevisionsCmd("fullGC",
"--fullGcMaxAge", "10000", "--entireRepo"));
+ assertTrue(output.contains("FullGcMaxAgeInSecs is : 10000"));
+ assertTrue(output.contains("FullGcMaxAgeMillis is : 10000000"));
+ assertTrue(output.contains("starting gc collect"));
}
@Test