Author: amitj
Date: Thu Dec 1 08:42:12 2016
New Revision: 1772154
URL: http://svn.apache.org/viewvc?rev=1772154&view=rev
Log:
OAK-5201: Support upgrade of DataStore cache
Added a fallback option in oak-run to do the upgrade of JR2 DataStore cache -
datastorecacheupgrade
Added:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/DataStoreCacheUpgradeCommand.java
(with props)
Modified:
jackrabbit/oak/trunk/oak-run/README.md
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Mode.java
Modified: jackrabbit/oak/trunk/oak-run/README.md
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/README.md?rev=1772154&r1=1772153&r2=1772154&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/README.md (original)
+++ jackrabbit/oak/trunk/oak-run/README.md Thu Dec 1 08:42:12 2016
@@ -25,7 +25,8 @@ The following runmodes are currently ava
* tarmkdiff : Show changes between revisions on TarMk
* tarmkrecovery : Lists candidates for head journal entries
* datastorecheck : Consistency checker for data store
- * resetclusterid : Resets the cluster id
+ * resetclusterid : Resets the cluster id
+ * datastorecacheupgrade : Upgrades the JR2 DataStore cache
* help : Print a list of available runmodes
@@ -1016,6 +1017,17 @@ Resets the cluster id generated internal
The cluster id will be removed and will be generated on next server start up.
+Oak DataStore Cache Upgrade
+---------------------------
+
+Upgrades the JR2 DataStore cache by moving files to the Upload staging and the
download cache of the DataStore.
+
+ $ java -classpath oak-run-*.jar datastorecacheupgrade \
+ --homeDir <home_directory> \
+ --path <path> \
+ --moveCache <true|false> \
+ --deleteMapFile <true|false>
+
License
-------
Added:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/DataStoreCacheUpgradeCommand.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/DataStoreCacheUpgradeCommand.java?rev=1772154&view=auto
==============================================================================
---
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/DataStoreCacheUpgradeCommand.java
(added)
+++
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/DataStoreCacheUpgradeCommand.java
Thu Dec 1 08:42:12 2016
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.oak.run;
+
+import java.io.File;
+
+import joptsimple.OptionParser;
+import joptsimple.OptionSet;
+import joptsimple.OptionSpec;
+import org.apache.jackrabbit.oak.plugins.blob.DataStoreCacheUpgradeUtils;
+
+import static java.util.Arrays.asList;
+
+/**
+ * Command to upgrade JR2 DataStore cache.
+ */
+public class DataStoreCacheUpgradeCommand implements Command {
+ @Override
+ public void execute(String... args) throws Exception {
+ OptionParser parser = new OptionParser();
+
+ try {
+ OptionSpec<File> homeDirOption = parser.accepts("homeDir",
+ "Home directory of the datastore where the pending uploads is
serialized")
+ .withRequiredArg().ofType(File.class).required();
+ OptionSpec<File> pathOption =
+ parser.accepts("path", "Parent directory of the
datastore").withRequiredArg()
+ .ofType(File.class).required();
+ OptionSpec<Boolean> moveCacheOption = parser
+ .accepts("moveCache", "Move DataStore download cache")
+ .withOptionalArg().ofType(Boolean.class).defaultsTo(true);
+ OptionSpec<Boolean> delPendingUploadsMapFileOption = parser
+ .accepts("deleteMapFile", "Delete pending uploads file post
upgrade")
+ .withOptionalArg().ofType(Boolean.class).defaultsTo(true);
+ OptionSpec<?> help = parser.acceptsAll(asList("h", "?", "help"),
"show help").forHelp();
+
+ OptionSet options = null;
+ try {
+ options = parser.parse(args);
+ } catch (Exception e) {
+ System.err.println(e);
+ parser.printHelpOn(System.err);
+ return;
+ }
+
+ if (options.has(help)) {
+ parser.printHelpOn(System.out);
+ return;
+ }
+
+ File homeDir = options.valueOf(homeDirOption);
+ File path = options.valueOf(pathOption);
+ boolean moveCache = options.valueOf(moveCacheOption);
+ boolean delPendingUploadsMapFile =
options.valueOf(delPendingUploadsMapFileOption);
+
+ System.out.println("homeDir " + homeDir);
+ System.out.println("path " + path);
+ System.out.println("moveCache " + moveCache);
+ System.out.println("delPendingUploadsMapFile " +
delPendingUploadsMapFile);
+ DataStoreCacheUpgradeUtils.upgrade(homeDir, path, moveCache,
delPendingUploadsMapFile);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.err.println("Error upgrading cache");
+ }
+ }
+}
Propchange:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/DataStoreCacheUpgradeCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Mode.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Mode.java?rev=1772154&r1=1772153&r2=1772154&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Mode.java
(original)
+++
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Mode.java
Thu Dec 1 08:42:12 2016
@@ -43,6 +43,7 @@ enum Mode {
RESETCLUSTERID("resetclusterid", new ResetClusterIdCommand()),
PERSISTENTCACHE("persistentcache", new PersistentCacheCommand()),
THREADDUMP("threaddump", new ThreadDumpCommand()),
+ DATASTORECACHEUPGRADE("datastorecacheupgrade", new
DataStoreCacheUpgradeCommand()),
HELP("help", new HelpCommand());
private final String name;