Author: jukka
Date: Tue Mar 18 02:53:28 2014
New Revision: 1578723
URL: http://svn.apache.org/r1578723
Log:
OAK-1390: Document the migration from Jackrabbit Classic to Oak
Extend and document the upgrade mode in oak-run
Modified:
jackrabbit/oak/trunk/oak-run/README.md
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java
Modified: jackrabbit/oak/trunk/oak-run/README.md
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/README.md?rev=1578723&r1=1578722&r2=1578723&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/README.md (original)
+++ jackrabbit/oak/trunk/oak-run/README.md Tue Mar 18 02:53:28 2014
@@ -25,20 +25,46 @@ Debug
-----
The 'debug' mode allows to obtain information about the status of the specified
-store. Currently this is only supported for the segment store (aka tar mk). To
-start this mode, use:
+store. Currently this is only supported for the TarMK. To start this mode, use:
- $ java -jar oak-run-*.jar debug /path/to/oakrepository [id...]
+ $ java -jar oak-run-*.jar debug /path/to/oak/repository [id...]
Upgrade
-------
-The 'upgrade' mode allows to upgrade an existing Jackrabbit 2.x installation to
-Oak. To start the upgrade, use
-
- $ java -jar oak-run-*.jar upgrade /path/to/jr2repository
/path/to/oakrepository
+The 'upgrade' mode allows to migrate the contents of an existing
+Jackrabbit 2.x repository to Oak. To run the migration, use:
+ $ java -jar oak-run-*.jar upgrade [--datastore] \
+ /path/to/jackrabbit/repository [/path/to/jackrabbit/repository.xml] \
+ { /path/to/oak/repository | mongodb://host:port/database }
+
+The source repository is opened from the given repository directory, and
+should not be concurrently accessed by any other client. Repository
+configuration is read from the specified configuration file, or from
+a `repository.xml` file within the repository directory if an explicit
+configuration file is not given.
+
+The target repository is specified either as a local filesystem path to
+a directory (which will be automatically created if it doesn't already exist)
+of a new TarMK repository or as a MongoDB client URI that specifies the
+location of a MongoDB database where a new DocumentMK repository.
+
+The `--datastore` option (if present) prevents the copying of binary data
+from a data store of the source repository to the target Oak repository.
+Instead the binaries are copied by reference, and you need to make the
+source data store available to the new Oak repository.
+
+The content migration will automatically adjust things like node type,
+privilege and user account settings that work a bit differently in Oak.
+Unsupported features like same-name-siblings are migrated on a best-effort
+basis, with no strict guarantees of completeness. Warnings will be logged
+for any content inconsistencies that might be encountered; such content
+should be manually reviewed after the migration is complete. Note that
+things like search index configuration work differently in Oak than in
+Jackrabbit 2.x, and will need to be manually recreated after the migration.
+See the relevant documentation for more details.
Oak server mode
---------------
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=1578723&r1=1578722&r2=1578723&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 Mar 18 02:53:28 2014
@@ -32,6 +32,8 @@ import javax.jcr.Repository;
import com.google.common.collect.Maps;
import com.google.common.collect.Queues;
+import com.mongodb.MongoClient;
+import com.mongodb.MongoClientURI;
import joptsimple.OptionParser;
import joptsimple.OptionSet;
@@ -46,6 +48,8 @@ import org.apache.jackrabbit.oak.fixture
import org.apache.jackrabbit.oak.http.OakServlet;
import org.apache.jackrabbit.oak.jcr.Jcr;
import org.apache.jackrabbit.oak.plugins.backup.FileStoreBackup;
+import org.apache.jackrabbit.oak.plugins.document.DocumentMK;
+import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore;
import org.apache.jackrabbit.oak.plugins.segment.Segment;
import org.apache.jackrabbit.oak.plugins.segment.SegmentId;
import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore;
@@ -227,15 +231,55 @@ public class Main {
}
private static void upgrade(String[] args) throws Exception {
- if (args.length == 2) {
- RepositoryContext source =
RepositoryContext.create(RepositoryConfig.create(new File(args[0])));
+ OptionParser parser = new OptionParser();
+ parser.accepts("datastore", "keep data store");
+
+ OptionSet options = parser.parse(args);
+
+ List<String> argList = options.nonOptionArguments();
+ if (argList.size() == 2 || argList.size() == 3) {
+ File dir = new File(argList.get(0));
+ File xml = new File(dir, "repository.xml");
+ String dst = argList.get(1);
+ if (argList.size() == 3) {
+ xml = new File(dst);
+ dst = argList.get(2);
+ }
+
+ RepositoryContext source =
+ RepositoryContext.create(RepositoryConfig.create(dir,
xml));
try {
- FileStore store = new FileStore(new File(args[1]), 256, true);
- try {
- NodeStore target = new SegmentNodeStore(store);
- new RepositoryUpgrade(source, target).copy();
- } finally {
- store.close();
+ if (dst.startsWith("mongodb://")) {
+ MongoClientURI uri = new MongoClientURI(dst);
+ MongoClient client = new MongoClient(uri);
+ try {
+ DocumentNodeStore target = new DocumentMK.Builder()
+ .setMongoDB(client.getDB(uri.getDatabase()))
+ .getNodeStore();
+ try {
+ RepositoryUpgrade upgrade =
+ new RepositoryUpgrade(source, target);
+ upgrade.setCopyBinariesByReference(
+ options.has("datastore"));
+ upgrade.copy();
+ } finally {
+ target.dispose();
+ }
+ } finally {
+ client.close();
+ }
+ } else {
+ FileStore store = new FileStore(new File(dst), 256);
+ try {
+ NodeStore target = new SegmentNodeStore(store);
+ RepositoryUpgrade upgrade =
+ new RepositoryUpgrade(source, target);
+ upgrade.setCopyBinariesByReference(
+ options.has("datastore"));
+ upgrade.copy();
+ } finally {
+ store.close();
+ }
}
} finally {
source.getRepository().shutdown();