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 ad...@apache.org on 2019/12/17 09:28:20 UTC
svn commit: r1871693 - in /jackrabbit/oak/trunk:
oak-doc/src/site/markdown/nodestore/segment/
oak-run/src/main/java/org/apache/jackrabbit/oak/run/
oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/
Author: adulceanu
Date: Tue Dec 17 09:28:19 2019
New Revision: 1871693
URL: http://svn.apache.org/viewvc?rev=1871693&view=rev
Log:
OAK-8828 - Configure the maximum number of journal entries to be copied with segment-copy
Contribution by Ieran Draghiciu
Modified:
jackrabbit/oak/trunk/oak-doc/src/site/markdown/nodestore/segment/overview.md
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/SegmentCopyCommand.java
jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/SegmentCopy.java
jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/SegmentStoreMigrator.java
Modified: jackrabbit/oak/trunk/oak-doc/src/site/markdown/nodestore/segment/overview.md
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-doc/src/site/markdown/nodestore/segment/overview.md?rev=1871693&r1=1871692&r2=1871693&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-doc/src/site/markdown/nodestore/segment/overview.md (original)
+++ jackrabbit/oak/trunk/oak-doc/src/site/markdown/nodestore/segment/overview.md Tue Dec 17 09:28:19 2019
@@ -676,14 +676,18 @@ Besides the local storage in TAR files (
### <a name="segment-copy"/> Segment-Copy
```
-java -jar oak-run.jar segment-copy SOURCE DESTINATION
+java -jar oak-run.jar segment-copy SOURCE DESTINATION [--last <REV_COUNT>]
```
The `segment-copy` command allows the "translation" of the Segment Store at `SOURCE` from one persistence type (e.g. local TarMK Segment Store) to a different persistence type (e.g. remote Azure Segment Store), saving the resulted Segment Store at `DESTINATION`.
Unlike a sidegrade peformed with `oak-upgrade` (see [Repository Migration](#../../migration.md)) which includes only the current head state, this translation includes __all previous revisions persisted in the Segment Store__, therefore retaining the entire history.
+If `--last` option is present, the tool will start with the most recent revision and will copy at most <REV_COUNT> journal revisions.
`SOURCE` must be a valid path/uri to an existing Segment Store.
`DESTINATION` must be a valid path/uri for the resulting Segment Store.
+
+The optional `--last [Integer]` argument can be used to control the maximum number of revisions to be copied from the journal (default is 1).
+
Both are specified as `PATH | cloud-prefix:URI`.
Please refer to the [Remote Segment Stores](#remote-segment-stores) section for details on how to correctly specify connection URIs.
Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/SegmentCopyCommand.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/SegmentCopyCommand.java?rev=1871693&r1=1871692&r2=1871693&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/SegmentCopyCommand.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/SegmentCopyCommand.java Tue Dec 17 09:28:19 2019
@@ -17,6 +17,7 @@
package org.apache.jackrabbit.oak.run;
+import joptsimple.OptionSpec;
import org.apache.jackrabbit.oak.run.commons.Command;
import org.apache.jackrabbit.oak.segment.azure.tool.SegmentCopy;
@@ -31,6 +32,11 @@ class SegmentCopyCommand implements Comm
@Override
public void execute(String... args) throws Exception {
OptionParser parser = new OptionParser();
+
+ OptionSpec<Integer> last = parser.accepts("last", "define the number of revisions to be copied (default: 1)")
+ .withOptionalArg()
+ .ofType(Integer.class);
+
OptionSet options = parser.parse(args);
PrintWriter out = new PrintWriter(System.out, true);
@@ -43,14 +49,17 @@ class SegmentCopyCommand implements Comm
String source = options.nonOptionArguments().get(0).toString();
String destination = options.nonOptionArguments().get(1).toString();
- int statusCode = SegmentCopy.builder()
+ SegmentCopy.Builder builder = SegmentCopy.builder()
.withSource(source)
.withDestination(destination)
.withOutWriter(out)
- .withErrWriter(err)
- .build()
- .run();
- System.exit(statusCode);
+ .withErrWriter(err);
+
+ if (options.has(last)) {
+ builder.withRevisionsCount(last.value(options) != null ? last.value(options) : 1);
+ }
+
+ System.exit(builder.build().run());
}
private void printUsage(OptionParser parser, PrintWriter err, String... messages) throws IOException {
Modified: jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/SegmentCopy.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/SegmentCopy.java?rev=1871693&r1=1871692&r2=1871693&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/SegmentCopy.java (original)
+++ jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/SegmentCopy.java Tue Dec 17 09:28:19 2019
@@ -63,6 +63,8 @@ public class SegmentCopy {
private PrintWriter errWriter;
+ private Integer revisionsCount = Integer.MAX_VALUE;
+
private Builder() {
// Prevent external instantiation.
}
@@ -141,6 +143,18 @@ public class SegmentCopy {
}
/**
+ * The last {@code revisionsCount} revisions to be copied.
+ * This parameter is not required and defaults to {@code 1}.
+ *
+ * @param revisionsCount number of revisions to copied.
+ * @return this builder.
+ */
+ public Builder withRevisionsCount(Integer revisionsCount) {
+ this.revisionsCount = revisionsCount;
+ return this;
+ }
+
+ /**
* Create an executable version of the {@link Check} command.
*
* @return an instance of {@link Runnable}.
@@ -150,6 +164,7 @@ public class SegmentCopy {
checkNotNull(source);
checkNotNull(destination);
}
+
return new SegmentCopy(this);
}
}
@@ -162,6 +177,8 @@ public class SegmentCopy {
private final PrintWriter errWriter;
+ private final Integer revisionCount;
+
private SegmentNodeStorePersistence srcPersistence;
private SegmentNodeStorePersistence destPersistence;
@@ -172,6 +189,7 @@ public class SegmentCopy {
this.destination = builder.destination;
this.srcPersistence = builder.srcPersistence;
this.destPersistence = builder.destPersistence;
+ this.revisionCount = builder.revisionsCount;
this.outWriter = builder.outWriter;
this.errWriter = builder.errWriter;
}
@@ -198,6 +216,7 @@ public class SegmentCopy {
SegmentStoreMigrator migrator = new SegmentStoreMigrator.Builder()
.withSourcePersistence(srcPersistence, srcDescription)
.withTargetPersistence(destPersistence, destDescription)
+ .withRevisionCount(revisionCount)
.build();
migrator.migrate();
Modified: jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/SegmentStoreMigrator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/SegmentStoreMigrator.java?rev=1871693&r1=1871692&r2=1871693&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/SegmentStoreMigrator.java (original)
+++ jackrabbit/oak/trunk/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/tool/SegmentStoreMigrator.java Tue Dec 17 09:28:19 2019
@@ -72,7 +72,7 @@ public class SegmentStoreMigrator implem
private final boolean appendMode;
- private final boolean onlyLastJournalEntry;
+ private final Integer revisionCount;
private ExecutorService executor = Executors.newFixedThreadPool(READ_THREADS + 1);
@@ -82,7 +82,7 @@ public class SegmentStoreMigrator implem
this.sourceName = builder.sourceName;
this.targetName = builder.targetName;
this.appendMode = builder.appendMode;
- this.onlyLastJournalEntry = builder.onlyLastJournalEntry;
+ this.revisionCount = builder.revisionCount;
}
public void migrate() throws IOException, ExecutionException, InterruptedException {
@@ -106,7 +106,7 @@ public class SegmentStoreMigrator implem
if (line.length() > 0 && !line.trim().equals("")) {
journal.add(line);
}
- if (!journal.isEmpty() && onlyLastJournalEntry) {
+ if (journal.size() == revisionCount) {
break;
}
}
@@ -291,7 +291,7 @@ public class SegmentStoreMigrator implem
private boolean appendMode;
- private boolean onlyLastJournalEntry;
+ private Integer revisionCount = Integer.MAX_VALUE;
public Builder withSource(File dir) {
this.source = new TarPersistence(dir);
@@ -334,8 +334,8 @@ public class SegmentStoreMigrator implem
return this;
}
- public Builder withOnlyLastJournalEntry() {
- this.onlyLastJournalEntry = true;
+ public Builder withRevisionCount(Integer revisionCount) {
+ this.revisionCount = revisionCount;
return this;
}