Search in sources :

Example 1 with DocumentMongoFixture

use of org.apache.jackrabbit.oak.fixture.DocumentMongoFixture in project jackrabbit-oak by apache.

the class ReferenceBinaryIT method fixtures.

@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> fixtures() throws Exception {
    File file = getTestDir("tar");
    FileStore fileStore = FileStoreBuilder.fileStoreBuilder(file).withBlobStore(createBlobStore()).withMaxFileSize(256).withMemoryMapping(true).build();
    SegmentNodeStore sns = SegmentNodeStoreBuilders.builder(fileStore).build();
    List<Object[]> fixtures = Lists.newArrayList();
    SegmentTarFixture segmentTarFixture = new SegmentTarFixture(sns);
    if (segmentTarFixture.isAvailable()) {
        fixtures.add(new Object[] { segmentTarFixture });
    }
    FileBlobStore fbs = new FileBlobStore(getTestDir("fbs1").getAbsolutePath());
    fbs.setReferenceKeyPlainText("foobar");
    FileStore fileStoreWithFBS = FileStoreBuilder.fileStoreBuilder(getTestDir("tar2")).withBlobStore(fbs).withMaxFileSize(256).withMemoryMapping(true).build();
    SegmentNodeStore snsWithFBS = SegmentNodeStoreBuilders.builder(fileStoreWithFBS).build();
    SegmentTarFixture segmentTarFixtureFBS = new SegmentTarFixture(snsWithFBS);
    if (segmentTarFixtureFBS.isAvailable()) {
        fixtures.add(new Object[] { segmentTarFixtureFBS });
    }
    DocumentMongoFixture documentFixture = new DocumentMongoFixture(MongoUtils.URL, createBlobStore());
    if (documentFixture.isAvailable()) {
        fixtures.add(new Object[] { documentFixture });
    }
    return fixtures;
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) DocumentMongoFixture(org.apache.jackrabbit.oak.fixture.DocumentMongoFixture) FileBlobStore(org.apache.jackrabbit.oak.spi.blob.FileBlobStore) SegmentTarFixture(org.apache.jackrabbit.oak.segment.fixture.SegmentTarFixture) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) File(java.io.File)

Example 2 with DocumentMongoFixture

use of org.apache.jackrabbit.oak.fixture.DocumentMongoFixture in project jackrabbit-oak by apache.

the class LargeOperationIT method fixtures.

@Parameterized.Parameters
public static Collection<Object[]> fixtures() throws Exception {
    List<Object[]> fixtures = Lists.newArrayList();
    SegmentTarFixture segmentFixture = new SegmentTarFixture();
    if (segmentFixture.isAvailable()) {
        fixtures.add(new Object[] { segmentFixture, SEGMENT_SCALES });
    }
    DocumentMongoFixture documentFixture = new DocumentMongoFixture();
    if (documentFixture.isAvailable()) {
        fixtures.add(new Object[] { documentFixture, MONGO_SCALES });
    }
    return fixtures;
}
Also used : DocumentMongoFixture(org.apache.jackrabbit.oak.fixture.DocumentMongoFixture) SegmentTarFixture(org.apache.jackrabbit.oak.segment.fixture.SegmentTarFixture)

Example 3 with DocumentMongoFixture

use of org.apache.jackrabbit.oak.fixture.DocumentMongoFixture in project jackrabbit-oak by apache.

the class NonLocalObservationIT method getFixture.

@Override
protected NodeStoreFixture getFixture() {
    /**
     * Fixes the cluster use case plus allowing to control the cache sizes.
     * In theory other users of DocumentMongoFixture might have similar
     * test cases - but keeping it simple for now - thus going via subclass.
     */
    return new DocumentMongoFixture() {

        private String dbName = System.currentTimeMillis() + "-NonLocalObservationIT";

        /**
         * keep a reference to the node stores so that the db only gets closed after the last nodeStore was closed
         */
        private Set<NodeStore> nodeStores = new HashSet<NodeStore>();

        /**
         * This is not implemented in the super class at all.
         * <ul>
         *  <li>use a specific suffix to make sure we have our own, new db and clean it up after the test</li>
         *  <li>properly drop that db created above in dispose</li>
         *  <li>use only 32MB (vs default of 256MB) memory to ensure we're not going OOM just because of this (which happens with the default)</li>
         *  <li>disable the persistent cache for the same reason</li>
         * </ul>
         */
        @Override
        public NodeStore createNodeStore(int clusterNodeId) {
            try {
                DocumentMK.Builder builder = new DocumentMK.Builder();
                // keep this one low to avoid OOME
                builder.memoryCacheSize(32 * 1024 * 1024);
                // turn this one off to avoid OOME
                builder.setPersistentCache(null);
                builder.setMongoDB(createClient(), dbName);
                DocumentNodeStore ns = builder.getNodeStore();
                nodeStores.add(ns);
                return ns;
            } catch (Exception e) {
                throw new AssumptionViolatedException("Mongo instance is not available", e);
            }
        }

        @Override
        public void dispose(NodeStore nodeStore) {
            super.dispose(nodeStore);
            nodeStores.remove(nodeStore);
            if (nodeStores.size() == 0) {
                try (MongoClient c = createClient()) {
                    c.dropDatabase(dbName);
                } catch (Exception e) {
                    log.error("dispose: Can't close Mongo", e);
                }
            }
        }

        @Override
        public String toString() {
            return "NonLocalObservationIT's DocumentMongoFixture flavour";
        }
    };
}
Also used : MongoClient(com.mongodb.MongoClient) HashSet(java.util.HashSet) Set(java.util.Set) DocumentNodeStore(org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) AssumptionViolatedException(org.junit.AssumptionViolatedException) DocumentMongoFixture(org.apache.jackrabbit.oak.fixture.DocumentMongoFixture) DocumentMK(org.apache.jackrabbit.oak.plugins.document.DocumentMK) DocumentNodeStore(org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore) RepositoryException(javax.jcr.RepositoryException) AssumptionViolatedException(org.junit.AssumptionViolatedException)

Aggregations

DocumentMongoFixture (org.apache.jackrabbit.oak.fixture.DocumentMongoFixture)3 SegmentTarFixture (org.apache.jackrabbit.oak.segment.fixture.SegmentTarFixture)2 MongoClient (com.mongodb.MongoClient)1 File (java.io.File)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 RepositoryException (javax.jcr.RepositoryException)1 DocumentMK (org.apache.jackrabbit.oak.plugins.document.DocumentMK)1 DocumentNodeStore (org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore)1 SegmentNodeStore (org.apache.jackrabbit.oak.segment.SegmentNodeStore)1 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)1 FileBlobStore (org.apache.jackrabbit.oak.spi.blob.FileBlobStore)1 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)1 AssumptionViolatedException (org.junit.AssumptionViolatedException)1