Author: mduerig
Date: Tue Jan 26 14:39:18 2016
New Revision: 1726805

URL: http://svn.apache.org/viewvc?rev=1726805&view=rev
Log:
OAK-3855: oak-run compact should check segment version
Throw runtime exception instead of system.exit to ensure finalisation

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=1726805&r1=1726804&r2=1726805&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:39:18 2016
@@ -525,33 +525,32 @@ public final class Main {
             System.exit(1);
         }
 
+        Stopwatch watch = Stopwatch.createStarted();
         FileStore store = openFileStore(directory);
-        SegmentVersion segmentVersion = getSegmentVersion(store);
-        if (segmentVersion != LATEST_VERSION) {
-            if (options.has(forceFlag)) {
-                System.out.println("Segment version mismatch. " +
-                    "Found " + segmentVersion + ", expected " + LATEST_VERSION 
+ ". " +
-                    "Upgrading the file store to segment version " + 
LATEST_VERSION);
-            } else {
-                System.err.println("Segment version mismatch. " +
-                    "Found " + segmentVersion + ", expected " + LATEST_VERSION 
+ ". " +
-                    "Specify --force to upgrade the file store to segment 
version " + LATEST_VERSION);
-                System.exit(-1);
+        try {
+            SegmentVersion segmentVersion = getSegmentVersion(store);
+            if (segmentVersion != LATEST_VERSION) {
+                if (options.has(forceFlag)) {
+                    System.out.println("Segment version mismatch. " +
+                        "Found " + segmentVersion + ", expected " + 
LATEST_VERSION + ". " +
+                        "Upgrading the file store to segment version " + 
LATEST_VERSION);
+                } else {
+                    failWith("Segment version mismatch. " +
+                        "Found " + segmentVersion + ", expected " + 
LATEST_VERSION + ". " +
+                        "Specify --force to upgrade the file store to segment 
version " + LATEST_VERSION);
+                }
             }
-        }
 
-        boolean persistCM = Boolean.getBoolean("tar.PersistCompactionMap");
-        Stopwatch watch = Stopwatch.createStarted();
-        System.out.println("Compacting " + directory);
-        System.out.println("    before " + Arrays.toString(directory.list()));
-        long sizeBefore = FileUtils.sizeOfDirectory(directory);
-        System.out.println("    size "
-                + IOUtils.humanReadableByteCount(sizeBefore) + " (" + 
sizeBefore
-                + " bytes)");
+            boolean persistCM = Boolean.getBoolean("tar.PersistCompactionMap");
+            System.out.println("Compacting " + directory);
+            System.out.println("    before " + 
Arrays.toString(directory.list()));
+            long sizeBefore = FileUtils.sizeOfDirectory(directory);
+            System.out.println("    size "
+                    + IOUtils.humanReadableByteCount(sizeBefore) + " (" + 
sizeBefore
+                    + " bytes)");
 
-        System.out.println("    -> compacting");
+            System.out.println("    -> compacting");
 
-        try {
             CompactionStrategy compactionStrategy = new CompactionStrategy(
                     false, CompactionStrategy.CLONE_BINARIES_DEFAULT,
                     CleanupType.CLEAN_ALL, 0,


Reply via email to