use of org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore in project jackrabbit-oak by apache.
the class VersionGCSupportTest method fixtures.
@Parameterized.Parameters(name = "{0}")
public static java.util.Collection<Object[]> fixtures() {
List<Object[]> fixtures = Lists.newArrayList();
if (RDB_H2.isAvailable()) {
RDBDocumentStore store = (RDBDocumentStore) RDB_H2.createDocumentStore();
fixtures.add(new Object[] { RDB_H2, store, new RDBVersionGCSupport(store) });
}
if (MONGO.isAvailable()) {
MongoDocumentStore store = (MongoDocumentStore) MONGO.createDocumentStore();
fixtures.add(new Object[] { MONGO, store, new MongoVersionGCSupport(store) });
}
if (MEMORY.isAvailable()) {
DocumentStore store = new MemoryDocumentStore();
fixtures.add(new Object[] { MEMORY, store, new VersionGCSupport(store) });
}
return fixtures;
}
use of org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore in project jackrabbit-oak by apache.
the class UnlockUpgradeCommand method execute.
@Override
public void execute(String... args) throws Exception {
OptionParser parser = new OptionParser();
// RDB specific options
OptionSpec<String> rdbjdbcuser = parser.accepts("rdbjdbcuser", "RDB JDBC user").withOptionalArg().defaultsTo("");
OptionSpec<String> rdbjdbcpasswd = parser.accepts("rdbjdbcpasswd", "RDB JDBC password").withOptionalArg().defaultsTo("");
OptionSpec<String> nonOption = parser.nonOptions("unlockUpgrade {<jdbc-uri> | <mongodb-uri>}");
OptionSpec help = parser.acceptsAll(asList("h", "?", "help"), "show help").forHelp();
OptionSet options = parser.parse(args);
List<String> nonOptions = nonOption.values(options);
if (options.has(help)) {
parser.printHelpOn(System.out);
return;
}
if (nonOptions.isEmpty()) {
parser.printHelpOn(System.err);
return;
}
DocumentStore store = null;
try {
String uri = nonOptions.get(0);
if (uri.startsWith(MONGODB_PREFIX)) {
MongoClientURI clientURI = new MongoClientURI(uri);
if (clientURI.getDatabase() == null) {
System.err.println("Database missing in MongoDB URI: " + clientURI.getURI());
} else {
MongoConnection mongo = new MongoConnection(clientURI.getURI());
store = new MongoDocumentStore(mongo.getDB(), new DocumentMK.Builder());
}
} else if (uri.startsWith("jdbc")) {
DataSource ds = RDBDataSourceFactory.forJdbcUrl(uri, rdbjdbcuser.value(options), rdbjdbcpasswd.value(options));
store = new RDBDocumentStore(ds, new DocumentMK.Builder());
} else {
System.err.println("Unrecognized URI: " + uri);
}
if (store != null && VERSION.writeTo(store)) {
System.out.println("Format version set to " + VERSION);
}
} catch (DocumentStoreException e) {
System.err.println(e.getMessage());
} finally {
if (store != null) {
store.dispose();
}
}
}
use of org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore in project jackrabbit-oak by apache.
the class UnlockUpgradeCommandTest method resetFormatVersion.
private void resetFormatVersion(FormatVersion v) {
MongoConnection c = connectionFactory.getConnection();
DocumentStore s = new MongoDocumentStore(c.getDB(), new DocumentMK.Builder());
s.remove(Collection.SETTINGS, "version");
assertTrue(v.writeTo(s));
s.dispose();
}
use of org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore in project jackrabbit-oak by apache.
the class DocumentNodeStoreServiceTest method keepAlive.
@Test
public void keepAlive() throws Exception {
Map<String, Object> config = newConfig(repoHome);
config.put(DocumentNodeStoreService.PROP_SO_KEEP_ALIVE, true);
MockOsgi.activate(service, context.bundleContext(), config);
DocumentNodeStore store = context.getService(DocumentNodeStore.class);
MongoDocumentStore mds = getMongoDocumentStore(store);
DB db = MongoDocumentStoreHelper.getDB(mds);
assertTrue(db.getMongo().getMongoOptions().isSocketKeepAlive());
}
use of org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore in project jackrabbit-oak by apache.
the class DocumentNodeStoreServiceTest method getMongoDocumentStore.
private static MongoDocumentStore getMongoDocumentStore(DocumentNodeStore s) {
try {
Field f = s.getClass().getDeclaredField("nonLeaseCheckingStore");
f.setAccessible(true);
return (MongoDocumentStore) f.get(s);
} catch (Exception e) {
fail(e.getMessage());
return null;
}
}
Aggregations