Author: catholicon
Date: Wed Jun  1 11:47:56 2016
New Revision: 1746440

URL: http://svn.apache.org/viewvc?rev=1746440&view=rev
Log:
OAK-4297: Oak-run console should allow to setup FDS of repository

Exposed --fds-path option to provide FDS path

(backport r1740626 from trunk)

Modified:
    jackrabbit/oak/branches/1.4/   (props changed)
    
jackrabbit/oak/branches/1.4/oak-run/src/main/java/org/apache/jackrabbit/oak/console/Console.java

Propchange: jackrabbit/oak/branches/1.4/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jun  1 11:47:56 2016
@@ -1,3 +1,3 @@
 /jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1733615,1733875,1733913,1733929,1734230,1734254,1734279,1734941,1735052,1735405,1735484,1735549,1735564,1735588,1735622,1735638,1735919,1735983,1736176,1737309-1737310,1737334,1737349,1737998,1738004,1738775,1738795,1738833,1738950,1738957,1738963,1739894,1740116,1740625,1740971,1741032,1741339,1741343,1742520,1742888,1742916,1743097,1743172,1743343,1744265,1744959,1745038,1745197,1745368,1746086,1746117,1746342
+/jackrabbit/oak/trunk:1733615,1733875,1733913,1733929,1734230,1734254,1734279,1734941,1735052,1735405,1735484,1735549,1735564,1735588,1735622,1735638,1735919,1735983,1736176,1737309-1737310,1737334,1737349,1737998,1738004,1738775,1738795,1738833,1738950,1738957,1738963,1739894,1740116,1740625-1740626,1740971,1741032,1741339,1741343,1742520,1742888,1742916,1743097,1743172,1743343,1744265,1744959,1745038,1745197,1745368,1746086,1746117,1746342
 /jackrabbit/trunk:1345480

Modified: 
jackrabbit/oak/branches/1.4/oak-run/src/main/java/org/apache/jackrabbit/oak/console/Console.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.4/oak-run/src/main/java/org/apache/jackrabbit/oak/console/Console.java?rev=1746440&r1=1746439&r2=1746440&view=diff
==============================================================================
--- 
jackrabbit/oak/branches/1.4/oak-run/src/main/java/org/apache/jackrabbit/oak/console/Console.java
 (original)
+++ 
jackrabbit/oak/branches/1.4/oak-run/src/main/java/org/apache/jackrabbit/oak/console/Console.java
 Wed Jun  1 11:47:56 2016
@@ -31,6 +31,8 @@ import joptsimple.OptionParser;
 import joptsimple.OptionSet;
 import joptsimple.OptionSpec;
 
+import org.apache.jackrabbit.core.data.FileDataStore;
+import org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore;
 import org.apache.jackrabbit.oak.plugins.document.DocumentMK;
 import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore;
 import org.apache.jackrabbit.oak.plugins.document.rdb.RDBDataSourceFactory;
@@ -38,6 +40,7 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore;
 import org.apache.jackrabbit.oak.plugins.segment.SegmentStore;
 import org.apache.jackrabbit.oak.plugins.segment.file.FileStore;
+import org.apache.jackrabbit.oak.spi.blob.BlobStore;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
 import org.codehaus.groovy.tools.shell.IO;
 
@@ -54,6 +57,7 @@ public class Console {
                 .withRequiredArg().ofType(Integer.class).defaultsTo(0);
         OptionSpec quiet = parser.accepts("quiet", "be less chatty");
         OptionSpec shell = parser.accepts("shell", "run the shell after 
executing files");
+        OptionSpec<String> fdsPathSpec = parser.accepts("fds-path", "Path to 
FDS store").withOptionalArg().defaultsTo("");
         OptionSpec help = parser.acceptsAll(asList("h", "?", "help"), "show 
help").forHelp();
 
         // RDB specific options
@@ -75,6 +79,19 @@ public class Console {
             System.exit(1);
         }
 
+        BlobStore blobStore = null;
+        String fdsPath = fdsPathSpec.value(options);
+        if (!"".equals(fdsPath)) {
+            File fdsDir = new File(fdsPath);
+            if (fdsDir.exists()) {
+                FileDataStore fds = new FileDataStore();
+                fds.setPath(fdsDir.getAbsolutePath());
+                fds.init(null);
+
+                blobStore = new DataStoreBlobStore(fds);
+            }
+        }
+
         NodeStoreFixture fixture;
         if (nonOptions.get(0).startsWith(MongoURI.MONGODB_PREFIX)) {
             MongoClientURI uri = new MongoClientURI(nonOptions.get(0));
@@ -83,20 +100,31 @@ public class Console {
                 System.exit(1);
             }
             MongoConnection mongo = new MongoConnection(uri.getURI());
-            DocumentNodeStore store = new DocumentMK.Builder().
-                    setMongoDB(mongo.getDB()).
-                    setClusterId(clusterId.value(options)).getNodeStore();
+            DocumentMK.Builder builder = new DocumentMK.Builder();
+            if (blobStore != null) {
+                builder.setBlobStore(blobStore);
+            }
+            builder.setMongoDB(mongo.getDB()).
+                    setClusterId(clusterId.value(options));
+            DocumentNodeStore store = builder.getNodeStore();
             fixture = new MongoFixture(store);
         } else if (nonOptions.get(0).startsWith("jdbc")) {
             DataSource ds = RDBDataSourceFactory.forJdbcUrl(nonOptions.get(0), 
rdbjdbcuser.value(options),
                     rdbjdbcpasswd.value(options));
-            DocumentNodeStore store = new DocumentMK.Builder().
-                    setRDBConnection(ds).
-                    setClusterId(clusterId.value(options)).getNodeStore();
+            DocumentMK.Builder builder = new DocumentMK.Builder();
+            if (blobStore != null) {
+                builder.setBlobStore(blobStore);
+            }
+            builder.setRDBConnection(ds).
+                    setClusterId(clusterId.value(options));
+            DocumentNodeStore store = builder.getNodeStore();
             fixture = new MongoFixture(store);
         } else {
-            fixture = new SegmentFixture(new FileStore(
-                    new File(nonOptions.get(0)), 256));
+            FileStore.Builder fsBuilder = FileStore.newFileStore(new 
File(nonOptions.get(0))).withMaxFileSize(256);
+            if (blobStore != null) {
+                fsBuilder.withBlobStore(blobStore);
+            }
+            fixture = new SegmentFixture(fsBuilder.create());
         }
 
         List<String> scriptArgs = nonOptions.size() > 1 ?


Reply via email to