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 al...@apache.org on 2014/08/07 12:27:21 UTC
svn commit: r1616463 -
/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java
Author: alexparvulescu
Date: Thu Aug 7 10:27:20 2014
New Revision: 1616463
URL: http://svn.apache.org/r1616463
Log:
OAK-2017 Add checkpoint management to oak-run
- added check that the provided repo path is a valid store for debug, compact and checkpoints
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=1616463&r1=1616462&r2=1616463&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 Thu Aug 7 10:27:20 2014
@@ -297,6 +297,9 @@ public class Main {
if (args.length != 1) {
System.err.println("usage: compact <path>");
System.exit(1);
+ } else if (!isValidFileStore(args[0])) {
+ System.err.println("Invalid FileStore directory " + args[0]);
+ System.exit(1);
} else {
File directory = new File(args[0]);
System.out.println("Compacting " + directory);
@@ -328,6 +331,10 @@ public class Main {
.println("usage: checkpoints <path> [list|rm-all|rm <checkpoint>]");
System.exit(1);
}
+ if (!isValidFileStore(args[0])) {
+ System.err.println("Invalid FileStore directory " + args[0]);
+ System.exit(1);
+ }
String path = args[0];
String op = "list";
@@ -404,6 +411,9 @@ public class Main {
if (args.length == 0) {
System.err.println("usage: debug <path> [id...]");
System.exit(1);
+ } else if (!isValidFileStore(args[0])) {
+ System.err.println("Invalid FileStore directory " + args[0]);
+ System.exit(1);
} else {
// TODO: enable debug information for other node store implementations
System.out.println("Debug " + args[0]);
@@ -526,6 +536,25 @@ public class Main {
}
}
+ /**
+ * Checks if the provided directory is a valid FileStore
+ *
+ * @return true if the provided directory is a valid FileStore
+ */
+ private static boolean isValidFileStore(String path) {
+ File store = new File(path);
+ if (store == null || !store.isDirectory()) {
+ return false;
+ }
+ // for now the only check is the existence of the journal file
+ for (String f : store.list()) {
+ if ("journal.log".equals(f)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private static void upgrade(String[] args) throws Exception {
OptionParser parser = new OptionParser();
parser.accepts("datastore", "keep data store");