Search in sources :

Example 1 with MongoConnection

use of org.apache.jackrabbit.oak.plugins.document.util.MongoConnection in project jackrabbit-oak by apache.

the class DocumentToExternalMigrationTest method createNodeStore.

@Override
protected NodeStore createNodeStore(BlobStore blobStore, File repository) throws IOException {
    MongoConnection connection = connectionFactory.getConnection();
    Assume.assumeNotNull(connection);
    DocumentMK.Builder builder = new DocumentMK.Builder();
    if (blobStore != null) {
        builder.setBlobStore(blobStore);
    }
    builder.setMongoDB(connection.getDB());
    return nodeStore = builder.getNodeStore();
}
Also used : DocumentMK(org.apache.jackrabbit.oak.plugins.document.DocumentMK) MongoConnection(org.apache.jackrabbit.oak.plugins.document.util.MongoConnection)

Example 2 with MongoConnection

use of org.apache.jackrabbit.oak.plugins.document.util.MongoConnection in project jackrabbit-oak by apache.

the class BaseDocumentDiscoveryLiteServiceTest method clear.

@Before
@After
public void clear() {
    logger.info("clear: seed=" + SEED);
    for (SimplifiedInstance i : allInstances) {
        i.dispose();
    }
    for (DocumentMK mk : mks) {
        mk.dispose();
    }
    mks.clear();
    if (MONGO_DB) {
        MongoConnection connection = connectionFactory.getConnection();
        if (connection != null) {
            DB db = connection.getDB();
            if (db != null) {
                MongoUtils.dropCollections(db);
            }
        }
    }
}
Also used : MongoConnection(org.apache.jackrabbit.oak.plugins.document.util.MongoConnection) DB(com.mongodb.DB) Before(org.junit.Before) After(org.junit.After)

Example 3 with MongoConnection

use of org.apache.jackrabbit.oak.plugins.document.util.MongoConnection in project jackrabbit-oak by apache.

the class MongoConnectionTest method socketKeepAlive.

@Test
public void socketKeepAlive() throws Exception {
    assumeTrue(MongoUtils.isAvailable());
    MongoClientOptions.Builder options = MongoConnection.getDefaultBuilder();
    options.socketKeepAlive(true);
    MongoConnection c = new MongoConnection(MongoUtils.URL, options);
    try {
        assertTrue(c.getDB().getMongo().getMongoOptions().isSocketKeepAlive());
    } finally {
        c.close();
    }
    // default is without keep-alive
    c = new MongoConnection(MongoUtils.URL);
    try {
        assertFalse(c.getDB().getMongo().getMongoOptions().isSocketKeepAlive());
    } finally {
        c.close();
    }
}
Also used : MongoClientOptions(com.mongodb.MongoClientOptions) MongoConnection(org.apache.jackrabbit.oak.plugins.document.util.MongoConnection) Test(org.junit.Test)

Example 4 with MongoConnection

use of org.apache.jackrabbit.oak.plugins.document.util.MongoConnection in project jackrabbit-oak by apache.

the class JournalIT method clear.

@Override
public void clear() {
    super.clear();
    MongoConnection mongoConnection = connectionFactory.getConnection();
    MongoUtils.dropCollections(mongoConnection.getDB());
}
Also used : MongoConnection(org.apache.jackrabbit.oak.plugins.document.util.MongoConnection)

Example 5 with MongoConnection

use of org.apache.jackrabbit.oak.plugins.document.util.MongoConnection in project jackrabbit-oak by apache.

the class DocumentMKConcurrentAddTest method createMicroKernel.

private DocumentMK createMicroKernel(int clusterId) throws Exception {
    MongoConnection connection = connectionFactory.getConnection();
    DB mongoDB = connection.getDB();
    return new DocumentMK.Builder().memoryCacheSize(CACHE_SIZE).setMongoDB(mongoDB).setClusterId(clusterId).open();
}
Also used : MongoConnection(org.apache.jackrabbit.oak.plugins.document.util.MongoConnection) DB(com.mongodb.DB)

Aggregations

MongoConnection (org.apache.jackrabbit.oak.plugins.document.util.MongoConnection)23 DocumentMK (org.apache.jackrabbit.oak.plugins.document.DocumentMK)8 Test (org.junit.Test)6 MongoClientURI (com.mongodb.MongoClientURI)5 DB (com.mongodb.DB)3 DBCollection (com.mongodb.DBCollection)3 DataSource (javax.sql.DataSource)3 DocumentStore (org.apache.jackrabbit.oak.plugins.document.DocumentStore)3 DBObject (com.mongodb.DBObject)2 MongoDocumentStore (org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Before (org.junit.Before)2 BasicDBObject (com.mongodb.BasicDBObject)1 MongoClientOptions (com.mongodb.MongoClientOptions)1 Closeable (java.io.Closeable)1 IOException (java.io.IOException)1 CheckForNull (javax.annotation.CheckForNull)1 Repository (javax.jcr.Repository)1 RepositoryException (javax.jcr.RepositoryException)1 Session (javax.jcr.Session)1