oak-run/rdb: add --rdbtableprefix option
@@ -51,6 +51,7 @@ import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore;
import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreBuilder;
import org.apache.jackrabbit.oak.plugins.document.LeaseCheckMode;
import org.apache.jackrabbit.oak.plugins.document.rdb.RDBDataSourceFactory;
+import org.apache.jackrabbit.oak.plugins.document.rdb.RDBOptions;
import org.apache.jackrabbit.oak.plugins.document.util.MongoConnection;
import org.apache.jackrabbit.oak.run.cli.DummyDataStore;
import org.apache.jackrabbit.oak.segment.SegmentNodeStoreBuilders;
@@ -80,6 +81,7 @@ class Utils {
public final OptionParser parser;
public final OptionSpec<String> rdbjdbcuser;
public final OptionSpec<String> rdbjdbcpasswd;
+ public final OptionSpec<String> rdbtableprefix;
public final OptionSpec<Integer> clusterId;
public final OptionSpec<Void> disableBranchesSpec;
public final OptionSpec<Integer> cacheSizeSpec;
@@ -96,6 +98,9 @@ class Utils {
rdbjdbcpasswd = parser
.accepts("rdbjdbcpasswd", "RDB JDBC password")
.withOptionalArg().defaultsTo("");
+ rdbtableprefix = parser
+ .accepts("rdbtableprefix", "RDB table prefix")
+ .withOptionalArg();
clusterId = parser
.accepts("clusterId", "MongoMK clusterId")
.withRequiredArg().ofType(Integer.class).defaultsTo(0);
@@ -151,6 +156,10 @@ class Utils {
public String getRDBJDBCPassword() {
return rdbjdbcpasswd.value(options);
}
+
+ public String getRDBTablePrefix() {
+ return rdbtableprefix.value(options);
+ }
}
public static NodeStore bootstrapNodeStore(String[] args, Closer closer, String h) throws IOException, InvalidFileStoreVersionException {
@@ -207,9 +216,12 @@ class Utils {
builder = newMongoDocumentNodeStoreBuilder().setMongoDB(
mongo.getMongoClient(), mongo.getDBName());
} else if (src.startsWith("jdbc")) {
- DataSource ds = RDBDataSourceFactory.forJdbcUrl(src,
- options.getRDBJDBCUser(), options.getRDBJDBCPassword());
- builder = newRDBDocumentNodeStoreBuilder().setRDBConnection(ds);
+ RDBOptions opts = new RDBOptions();
+ if (options.getRDBTablePrefix() != null) {
+ opts = opts.tablePrefix(options.getRDBTablePrefix());
+ }
+ DataSource ds = RDBDataSourceFactory.forJdbcUrl(src, options.getRDBJDBCUser(), options.getRDBJDBCPassword());
+ builder = newRDBDocumentNodeStoreBuilder().setRDBConnection(ds, opts);
} else {
return null;
}
