Author: catholicon
Date: Tue Apr 12 16:07:52 2016
New Revision: 1738825
URL: http://svn.apache.org/viewvc?rev=1738825&view=rev
Log:
OAK-4182: oak-run->console should have a read-only mode to connect to document
stores (mongo, rdb, etc)
Modified:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/console/Console.java
Modified:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/console/Console.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/console/Console.java?rev=1738825&r1=1738824&r2=1738825&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/console/Console.java
(original)
+++
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/console/Console.java
Tue Apr 12 16:07:52 2016
@@ -54,6 +54,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 readOnly = parser.accepts("read-only", "connect to
repository in read-only mode");
OptionSpec help = parser.acceptsAll(asList("h", "?", "help"), "show
help").forHelp();
// RDB specific options
@@ -83,16 +84,22 @@ public class Console {
System.exit(1);
}
MongoConnection mongo = new MongoConnection(uri.getURI());
- DocumentNodeStore store = new DocumentMK.Builder().
+
+ DocumentMK.Builder builder = new DocumentMK.Builder().
setMongoDB(mongo.getDB()).
- setClusterId(clusterId.value(options)).getNodeStore();
+ setClusterId(clusterId.value(options));
+ if (options.has(readOnly)) {
+ builder.setReadOnlyMode();
+ }
+ 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().
+ DocumentMK.Builder builder = new DocumentMK.Builder().
setRDBConnection(ds).
- setClusterId(clusterId.value(options)).getNodeStore();
+ setClusterId(clusterId.value(options));
+ DocumentNodeStore store = builder.getNodeStore();
fixture = new MongoFixture(store);
} else {
fixture = new SegmentFixture(FileStore.builder(new
File(nonOptions.get(0))).withMaxFileSize(256).build());