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 re...@apache.org on 2019/02/13 10:48:56 UTC
svn commit: r1853487 - in /jackrabbit/oak/branches/1.10: ./
oak-run/src/main/java/org/apache/jackrabbit/oak/run/RecoveryCommand.java
Author: reschke
Date: Wed Feb 13 10:48:56 2019
New Revision: 1853487
URL: http://svn.apache.org/viewvc?rev=1853487&view=rev
Log:
OAK-8004: oak-run: support recovery command for RDBDocumentStore (ported to 1.10)
Modified:
jackrabbit/oak/branches/1.10/ (props changed)
jackrabbit/oak/branches/1.10/oak-run/src/main/java/org/apache/jackrabbit/oak/run/RecoveryCommand.java
Propchange: jackrabbit/oak/branches/1.10/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Feb 13 10:48:56 2019
@@ -1,3 +1,3 @@
/jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1851236,1851253,1851451,1852052,1852084,1852451,1852492-1852493,1852920,1853393,1853433
+/jackrabbit/oak/trunk:1851236,1851253,1851451,1852052,1852084,1852120,1852451,1852492-1852493,1852920,1853393,1853433
/jackrabbit/trunk:1345480
Modified: jackrabbit/oak/branches/1.10/oak-run/src/main/java/org/apache/jackrabbit/oak/run/RecoveryCommand.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.10/oak-run/src/main/java/org/apache/jackrabbit/oak/run/RecoveryCommand.java?rev=1853487&r1=1853486&r2=1853487&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.10/oak-run/src/main/java/org/apache/jackrabbit/oak/run/RecoveryCommand.java (original)
+++ jackrabbit/oak/branches/1.10/oak-run/src/main/java/org/apache/jackrabbit/oak/run/RecoveryCommand.java Wed Feb 13 10:48:56 2019
@@ -17,44 +17,64 @@
package org.apache.jackrabbit.oak.run;
+import java.io.Closeable;
import java.util.Arrays;
-import com.google.common.io.Closer;
-import org.apache.jackrabbit.oak.run.commons.Command;
import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore;
+import org.apache.jackrabbit.oak.plugins.document.DocumentStore;
import org.apache.jackrabbit.oak.plugins.document.LastRevRecoveryAgent;
+import org.apache.jackrabbit.oak.plugins.document.MissingLastRevSeeker;
import org.apache.jackrabbit.oak.plugins.document.NodeDocument;
import org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore;
import org.apache.jackrabbit.oak.plugins.document.mongo.MongoMissingLastRevSeeker;
-import org.apache.jackrabbit.oak.plugins.document.util.CloseableIterable;
+import org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore;
import org.apache.jackrabbit.oak.plugins.document.util.MapDBMapFactory;
import org.apache.jackrabbit.oak.plugins.document.util.MapFactory;
+import org.apache.jackrabbit.oak.run.commons.Command;
import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import com.google.common.io.Closer;
+
class RecoveryCommand implements Command {
@Override
public void execute(String... args) throws Exception {
MapFactory.setInstance(new MapDBMapFactory());
Closer closer = Closer.create();
- String h = "recovery mongodb://host:port/database { dryRun }";
+ String h = "recovery mongodb://host:port/database|jdbc:... { dryRun }";
try {
NodeStore store = Utils.bootstrapNodeStore(args, closer, h);
+
if (!(store instanceof DocumentNodeStore)) {
System.err.println("Recovery only available for DocumentNodeStore");
System.exit(1);
}
+
DocumentNodeStore dns = (DocumentNodeStore) store;
- if (!(dns.getDocumentStore() instanceof MongoDocumentStore)) {
- System.err.println("Recovery only available for MongoDocumentStore");
+ DocumentStore ds = dns.getDocumentStore();
+ LastRevRecoveryAgent agent = null;
+ MissingLastRevSeeker seeker = null;
+
+ if (ds instanceof MongoDocumentStore) {
+ MongoDocumentStore docStore = (MongoDocumentStore) ds;
+ agent = new LastRevRecoveryAgent(docStore, dns);
+ seeker = new MongoMissingLastRevSeeker(docStore, dns.getClock());
+ } else if (ds instanceof RDBDocumentStore) {
+ RDBDocumentStore docStore = (RDBDocumentStore) ds;
+ agent = new LastRevRecoveryAgent(docStore, dns);
+ seeker = new MissingLastRevSeeker(docStore, dns.getClock());
+ }
+
+ if (agent == null || seeker == null) {
+ System.err.println("Recovery only available for MongoDocumentStore and RDBDocumentStore (this: "
+ + ds.getClass().getName() + ")");
System.exit(1);
}
- MongoDocumentStore docStore = (MongoDocumentStore) dns.getDocumentStore();
- LastRevRecoveryAgent agent = new LastRevRecoveryAgent(docStore, dns);
- MongoMissingLastRevSeeker seeker = new MongoMissingLastRevSeeker(
- docStore, dns.getClock());
- CloseableIterable<NodeDocument> docs = seeker.getCandidates(0);
- closer.register(docs);
+
+ Iterable<NodeDocument> docs = seeker.getCandidates(0);
+ if (docs instanceof Closeable) {
+ closer.register((Closeable) docs);
+ }
boolean dryRun = Arrays.asList(args).contains("dryRun");
agent.recover(docs, dns.getClusterId(), dryRun);
} catch (Throwable e) {
@@ -63,5 +83,4 @@ class RecoveryCommand implements Command
closer.close();
}
}
-
}