jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1538893 - in /jackrabbit/oak/trunk: oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/NodeStoreFixture.java oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakRepositoryFixture.java
Date Tue, 05 Nov 2013 07:48:14 GMT
Author: mreutegg
Date: Tue Nov  5 07:48:14 2013
New Revision: 1538893

URL: http://svn.apache.org/r1538893
Log:
OAK-1080: MongoMK: improved concurrency
- NodeStoreFixture for MongoNodeStore

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/NodeStoreFixture.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakRepositoryFixture.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/NodeStoreFixture.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/NodeStoreFixture.java?rev=1538893&r1=1538892&r2=1538893&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/NodeStoreFixture.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/NodeStoreFixture.java
Tue Nov  5 07:48:14 2013
@@ -24,6 +24,7 @@ import java.io.IOException;
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
 import org.apache.jackrabbit.oak.plugins.mongomk.MongoMK;
 import org.apache.jackrabbit.oak.kernel.KernelNodeStore;
+import org.apache.jackrabbit.oak.plugins.mongomk.MongoNodeStore;
 import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore;
 import org.apache.jackrabbit.oak.plugins.segment.memory.MemoryStore;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
@@ -62,6 +63,20 @@ public abstract class NodeStoreFixture {
         }
     };
 
+    public static final NodeStoreFixture MONGO_NS = new NodeStoreFixture() {
+        @Override
+        public NodeStore createNodeStore() {
+            return new MongoMK.Builder().getNodeStore();
+        }
+
+        @Override
+        public void dispose(NodeStore nodeStore) {
+            if (nodeStore instanceof MongoNodeStore) {
+                ((MongoNodeStore) nodeStore).dispose();
+            }
+        }
+    };
+
     public static final NodeStoreFixture MK_IMPL = new NodeStoreFixture() {
         @Override
         public NodeStore createNodeStore() {

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakRepositoryFixture.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakRepositoryFixture.java?rev=1538893&r1=1538892&r2=1538893&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakRepositoryFixture.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakRepositoryFixture.java
Tue Nov  5 07:48:14 2013
@@ -24,6 +24,7 @@ import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
 import org.apache.jackrabbit.oak.plugins.mongomk.MongoMK;
+import org.apache.jackrabbit.oak.plugins.mongomk.MongoNodeStore;
 import org.apache.jackrabbit.oak.plugins.mongomk.util.MongoConnection;
 import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.jcr.Jcr;
@@ -118,6 +119,47 @@ public abstract class OakRepositoryFixtu
         };
     }
 
+    public static RepositoryFixture getMongoNS(
+            final String host, final int port, final String database,
+            final boolean dropDBAfterTest, final long cacheSize) {
+        return new OakRepositoryFixture("Oak-MongoNS") {
+            private String dbName = database != null ? database : unique;
+            private MongoNodeStore[] stores;
+            @Override
+            public Repository[] setUpCluster(int n) throws Exception {
+                Repository[] cluster = new Repository[n];
+                stores = new MongoNodeStore[cluster.length];
+                for (int i = 0; i < cluster.length; i++) {
+                    MongoConnection mongo =
+                            new MongoConnection(host, port, dbName);
+                    stores[i] = new MongoMK.Builder().
+                            setMongoDB(mongo.getDB()).
+                            memoryCacheSize(cacheSize).
+                            setClusterId(i).setLogging(false).getNodeStore();
+                    Oak oak = new Oak(stores[i]);
+                    cluster[i] = new Jcr(oak).createRepository();
+                }
+                return cluster;
+            }
+            @Override
+            public void tearDownCluster() {
+                for (MongoNodeStore store : stores) {
+                    store.dispose();
+                }
+                if (dropDBAfterTest) {
+                    try {
+                        MongoConnection mongo =
+                                new MongoConnection(host, port, dbName);
+                        mongo.getDB().dropDatabase();
+                        mongo.close();
+                    } catch (Exception e) {
+                        throw new RuntimeException(e);
+                    }
+                }
+            }
+        };
+    }
+
     public static RepositoryFixture getSegment(
             final String host, final int port, final int cacheSize) {
         return new OakRepositoryFixture("Oak-Segment") {



Mime
View raw message