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 2016/01/26 15:32:20 UTC
svn commit: r1726800 -
/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java
Author: mduerig
Date: Tue Jan 26 14:32:20 2016
New Revision: 1726800
URL: http://svn.apache.org/viewvc?rev=1726800&view=rev
Log:
OAK-3925: oak-run backup/recover should check segment version
Bail out on segment version mismatch
Modified:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java
Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java?rev=1726800&r1=1726799&r2=1726800&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java Tue Jan 26 14:32:20 2016
@@ -277,7 +277,7 @@ public final class Main {
Closer closer = Closer.create();
String h = "backup { /path/to/oak/repository | mongodb://host:port/database } <path/to/backup>";
try {
- NodeStore store = bootstrapNodeStore(args, closer, h);
+ NodeStore store = bootstrapNodeStore(args, closer, h, LATEST_VERSION);
FileStoreBackup.backup(store, new File(args[1]));
} catch (Throwable e) {
throw closer.rethrow(e);
@@ -290,7 +290,7 @@ public final class Main {
Closer closer = Closer.create();
String h = "restore { /path/to/oak/repository | mongodb://host:port/database } <path/to/backup>";
try {
- NodeStore store = bootstrapNodeStore(args, closer, h);
+ NodeStore store = bootstrapNodeStore(args, closer, h, LATEST_VERSION);
FileStoreRestore.restore(new File(args[1]), store);
} catch (Throwable e) {
throw closer.rethrow(e);
@@ -421,8 +421,8 @@ public final class Main {
}
}
- public static NodeStore bootstrapNodeStore(String[] args, Closer closer,
- String h) throws IOException {
+ public static NodeStore bootstrapNodeStore(String[] args, Closer closer, String h,
+ SegmentVersion expectedSegmentVersion) throws IOException {
//TODO add support for other NodeStore flags
OptionParser parser = new OptionParser();
OptionSpec<Integer> clusterId = parser
@@ -464,6 +464,14 @@ public final class Main {
return store;
}
FileStore fs = new FileStore(new File(src), 256, TAR_STORAGE_MEMORY_MAPPED);
+
+ SegmentVersion segmentVersion = getSegmentVersion(fs);
+ if (expectedSegmentVersion != null && expectedSegmentVersion != segmentVersion) {
+ failWith("Segment version mismatch. " +
+ "Found " + segmentVersion + ", expected " + expectedSegmentVersion + ". " +
+ "Please use the respective version of this tool");
+ }
+
closer.register(asCloseable(fs));
return new SegmentNodeStore(fs);
}
@@ -739,7 +747,7 @@ public final class Main {
Closer closer = Closer.create();
String h = "recovery mongodb://host:port/database { dryRun }";
try {
- NodeStore store = bootstrapNodeStore(args, closer, h);
+ NodeStore store = bootstrapNodeStore(args, closer, h, null);
if (!(store instanceof DocumentNodeStore)) {
System.err.println("Recovery only available for DocumentNodeStore");
System.exit(1);
@@ -767,7 +775,7 @@ public final class Main {
Closer closer = Closer.create();
String h = "repair mongodb://host:port/database path";
try {
- NodeStore store = bootstrapNodeStore(args, closer, h);
+ NodeStore store = bootstrapNodeStore(args, closer, h, null);
if (!(store instanceof DocumentNodeStore)) {
System.err.println("Repair only available for DocumentNodeStore");
System.exit(1);
@@ -792,7 +800,7 @@ public final class Main {
Closer closer = Closer.create();
String h = "garbage mongodb://host:port/database";
try {
- NodeStore store = bootstrapNodeStore(args, closer, h);
+ NodeStore store = bootstrapNodeStore(args, closer, h, null);
if (!(store instanceof DocumentNodeStore)) {
System.err.println("Garbage mode only available for DocumentNodeStore");
System.exit(1);