Search in sources :

Example 1 with MongoDocumentStore

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;
}
Also used : RDBDocumentStore(org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore) MongoDocumentStore(org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore) RDBDocumentStore(org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore) MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) MongoVersionGCSupport(org.apache.jackrabbit.oak.plugins.document.mongo.MongoVersionGCSupport) RDBVersionGCSupport(org.apache.jackrabbit.oak.plugins.document.rdb.RDBVersionGCSupport) RDBVersionGCSupport(org.apache.jackrabbit.oak.plugins.document.rdb.RDBVersionGCSupport) MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) MongoVersionGCSupport(org.apache.jackrabbit.oak.plugins.document.mongo.MongoVersionGCSupport) MongoDocumentStore(org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore)

Example 2 with MongoDocumentStore

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();
        }
    }
}
Also used : OptionSpec(joptsimple.OptionSpec) DocumentStoreException(org.apache.jackrabbit.oak.plugins.document.DocumentStoreException) MongoClientURI(com.mongodb.MongoClientURI) DocumentMK(org.apache.jackrabbit.oak.plugins.document.DocumentMK) OptionParser(joptsimple.OptionParser) MongoDocumentStore(org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore) DataSource(javax.sql.DataSource) DocumentStore(org.apache.jackrabbit.oak.plugins.document.DocumentStore) MongoDocumentStore(org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore) RDBDocumentStore(org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore) RDBDocumentStore(org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore) OptionSet(joptsimple.OptionSet) MongoConnection(org.apache.jackrabbit.oak.plugins.document.util.MongoConnection)

Example 3 with MongoDocumentStore

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();
}
Also used : DocumentStore(org.apache.jackrabbit.oak.plugins.document.DocumentStore) MongoDocumentStore(org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore) DocumentMK(org.apache.jackrabbit.oak.plugins.document.DocumentMK) MongoConnection(org.apache.jackrabbit.oak.plugins.document.util.MongoConnection) MongoDocumentStore(org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore)

Example 4 with MongoDocumentStore

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());
}
Also used : MongoDocumentStore(org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore) DB(com.mongodb.DB) Test(org.junit.Test)

Example 5 with MongoDocumentStore

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;
    }
}
Also used : Field(java.lang.reflect.Field) MongoDocumentStore(org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore)

Aggregations

MongoDocumentStore (org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore)8 Closer (com.google.common.io.Closer)2 DocumentMK (org.apache.jackrabbit.oak.plugins.document.DocumentMK)2 DocumentNodeStore (org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore)2 DocumentStore (org.apache.jackrabbit.oak.plugins.document.DocumentStore)2 RDBDocumentStore (org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore)2 MongoConnection (org.apache.jackrabbit.oak.plugins.document.util.MongoConnection)2 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)2 DB (com.mongodb.DB)1 DBCollection (com.mongodb.DBCollection)1 DBCursor (com.mongodb.DBCursor)1 DBObject (com.mongodb.DBObject)1 MongoClientURI (com.mongodb.MongoClientURI)1 Field (java.lang.reflect.Field)1 Nullable (javax.annotation.Nullable)1 DataSource (javax.sql.DataSource)1 OptionParser (joptsimple.OptionParser)1 OptionSet (joptsimple.OptionSet)1 OptionSpec (joptsimple.OptionSpec)1 DocumentStoreException (org.apache.jackrabbit.oak.plugins.document.DocumentStoreException)1