Author: mreutegg
Date: Thu Jul 11 12:08:27 2019
New Revision: 1862917

URL: http://svn.apache.org/viewvc?rev=1862917&view=rev
Log:
OAK-8474: oak-run revisions fails with custom blob store

Modified:
    
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/RevisionsCommand.java
    
jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/run/RevisionsCommandCustomBlobStoreTest.java

Modified: 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/RevisionsCommand.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/RevisionsCommand.java?rev=1862917&r1=1862916&r2=1862917&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/RevisionsCommand.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/RevisionsCommand.java
 Thu Jul 11 12:08:27 2019
@@ -52,6 +52,7 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.run.commons.Command;
 import org.apache.jackrabbit.oak.plugins.document.VersionGCOptions;
 import org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector;
+import org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -222,6 +223,7 @@ public class RevisionsCommand implements
         // this prevents the DocumentNodeStore from writing a new
         // clusterId to the clusterNodes and nodes collections
         builder.setReadOnlyMode();
+        useMemoryBlobStore(builder);
         // create a version GC that operates on a read-only DocumentNodeStore
         // and a GC support with a writable DocumentStore
         VersionGarbageCollector gc = createVersionGC(builder.build(), 
gcSupport);
@@ -385,6 +387,7 @@ public class RevisionsCommand implements
             return;
         }
         builder.setReadOnlyMode();
+        useMemoryBlobStore(builder);
         DocumentNodeStore ns = builder.build();
         closer.register(asCloseable(ns));
         MissingLastRevSeeker seeker = builder.createMissingLastRevSeeker();
@@ -398,4 +401,16 @@ public class RevisionsCommand implements
     private String fmtDuration(long ts) {
         return TimeDurationFormatter.forLogging().format(ts, 
TimeUnit.MILLISECONDS);
     }
+
+    private void useMemoryBlobStore(DocumentNodeStoreBuilder builder) {
+        // The revisions command does not have options for the blob store
+        // and the DocumentNodeStoreBuilder by default assumes the blobs
+        // are stored in the same location as the documents. That is,
+        // either in MongoDB or RDB, which is not necessarily the case and
+        // can cause an exception when the blob store implementation starts
+        // read-only on a database that does not have the required
+        // collection. Use an in-memory blob store instead, because the
+        // revisions command does not read blobs anyway.
+        builder.setBlobStore(new MemoryBlobStore());
+    }
 }

Modified: 
jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/run/RevisionsCommandCustomBlobStoreTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/run/RevisionsCommandCustomBlobStoreTest.java?rev=1862917&r1=1862916&r2=1862917&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/run/RevisionsCommandCustomBlobStoreTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/run/RevisionsCommandCustomBlobStoreTest.java
 Thu Jul 11 12:08:27 2019
@@ -24,14 +24,12 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore;
 import org.junit.Before;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assume.assumeTrue;
 
-@Ignore
 public class RevisionsCommandCustomBlobStoreTest {
 
     @Rule


Reply via email to