This is an automated email from the ASF dual-hosted git repository.
joscorbe 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 eb1392c8ba OAK-11870: Allow passing fullGCGeneration parameter to
RevisionsCommand (#2465)
eb1392c8ba is described below
commit eb1392c8ba4a12f9c7449b4c632302d3fe024613
Author: horia_poradici <[email protected]>
AuthorDate: Fri Aug 22 18:47:47 2025 +0300
OAK-11870: Allow passing fullGCGeneration parameter to RevisionsCommand
(#2465)
---
.../apache/jackrabbit/oak/run/RevisionsCommand.java | 9 +++++++++
.../oak/plugins/document/RevisionsCommandTest.java | 19 +++++++++++++++++++
.../oak/plugins/document/VersionGarbageCollector.java | 4 ++++
3 files changed, 32 insertions(+)
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 6f765b12d4..862403bf3f 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
@@ -145,6 +145,7 @@ public class RevisionsCommand implements Command {
final OptionSpec<?> continuous;
final OptionSpec<?> fullGCOnly;
final OptionSpec<Boolean> resetFullGC;
+ final OptionSpec<Long> fullGcGeneration;
final OptionSpec<?> verbose;
final OptionSpec<String> path;
final OptionSpec<String> includePaths;
@@ -207,6 +208,10 @@ public class RevisionsCommand implements Command {
resetFullGC = parser
.accepts("resetFullGC", "reset fullGC after running
FullGC")
.withRequiredArg().ofType(Boolean.class).defaultsTo(FALSE);
+ fullGcGeneration = parser.accepts("fullGcGeneration", "The value
indicates the current Full GC generation running on a document node store. " +
+ "To reset the Full GC to run from the beginning,
you must increment this value. " +
+ "If you set the value to one that is smaller than
or equal to the existing generation, the change will be ignored.")
+ .withRequiredArg().ofType(Long.class).defaultsTo(0L);
fullGcBatchSize = parser.accepts("fullGcBatchSize", "The number of
documents to fetch from database " +
"in a single query to check for Full GC.")
.withRequiredArg().ofType(Integer.class).defaultsTo(1000);
@@ -308,6 +313,8 @@ public class RevisionsCommand implements Command {
return resetFullGC.value(options);
}
+ long getFullGcGeneration() { return fullGcGeneration.value(options); }
+
boolean isVerbose() {
return options.has(verbose);
}
@@ -396,6 +403,7 @@ public class RevisionsCommand implements Command {
builder.setFullGCIncludePaths(options.getIncludePaths());
builder.setFullGCExcludePaths(options.getExcludePaths());
builder.setFullGCMode(options.getFullGcMode());
+ builder.setFullGCGeneration(options.getFullGcGeneration());
builder.setFullGCDelayFactor(options.getFullGcDelayFactor());
builder.setFullGCBatchSize(options.getFullGcBatchSize());
builder.setFullGCProgressSize(options.getFullGcProgressSize());
@@ -429,6 +437,7 @@ public class RevisionsCommand implements Command {
System.out.println("IncludePaths are : " +
sortedSet(gc.getFullGCIncludePaths()));
System.out.println("ExcludePaths are : " +
sortedSet(gc.getFullGCExcludePaths()));
System.out.println("FullGcMode is : " +
VersionGarbageCollector.getFullGcMode());
+ System.out.println("FullGCGeneration is : " +
gc.getFullGcGeneration());
System.out.println("FullGcDelayFactor is : " +
gc.getFullGcDelayFactor());
System.out.println("FullGcBatchSize is : " + gc.getFullGcBatchSize());
System.out.println("FullGcProgressSize is : " +
gc.getFullGcProgressSize());
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 1bc4669e0f..6852e5f8b1 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
@@ -203,6 +203,7 @@ public class RevisionsCommandTest {
assertTrue(output.contains("FullGcProgressSize is : 10000\n"));
assertTrue(output.contains("FullGcMaxAgeInSecs is : 86400\n"));
assertTrue(output.contains("FullGcMaxAgeMillis is : 86400000\n"));
+ assertTrue(output.contains("FullGCGeneration is : 0\n"));
}
@Test
@@ -337,6 +338,24 @@ public class RevisionsCommandTest {
assertTrue(output.contains("starting gc collect"));
}
+ @Test
+ public void fullGCWithoutFullGCGeneration() {
+ ns.dispose();
+
+ String output = captureSystemOut(new RevisionsCmd("fullGC",
"--entireRepo"));
+ assertTrue(output.contains("FullGCGeneration is : 0"));
+ assertTrue(output.contains("starting gc collect"));
+ }
+
+ @Test
+ public void fullGCWithFullGCGeneration() {
+ ns.dispose();
+
+ String output = captureSystemOut(new RevisionsCmd("fullGC",
"--entireRepo", "--fullGcGeneration", "2"));
+ assertTrue(output.contains("FullGCGeneration is : 2"));
+ assertTrue(output.contains("starting gc collect"));
+ }
+
@Test
public void embeddedVerification() {
ns.dispose();
diff --git
a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollector.java
b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollector.java
index 195fc670eb..c41c943c54 100644
---
a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollector.java
+++
b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollector.java
@@ -212,6 +212,10 @@ public class VersionGarbageCollector {
return fullGCExcludePaths;
}
+ public long getFullGcGeneration() {
+ return fullGcGen;
+ }
+
/**
* Set the full GC mode to be used according to the provided configuration
value.
* The configuration value will be ignored and fullGCMode will be reset to
NONE