jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1447728 - in /jackrabbit/oak/trunk/oak-run: pom.xml src/main/java/org/apache/jackrabbit/oak/benchmark/Benchmark.java src/main/java/org/apache/jackrabbit/oak/fixture/OakRepositoryFixture.java
Date Tue, 19 Feb 2013 14:15:50 GMT
Author: jukka
Date: Tue Feb 19 14:15:50 2013
New Revision: 1447728

URL: http://svn.apache.org/r1447728
Log:
OAK-641: Improved benchmark tooling

Add more Oak fixtures

Modified:
    jackrabbit/oak/trunk/oak-run/pom.xml
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/Benchmark.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakRepositoryFixture.java

Modified: jackrabbit/oak/trunk/oak-run/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/pom.xml?rev=1447728&r1=1447727&r2=1447728&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-run/pom.xml Tue Feb 19 14:15:50 2013
@@ -120,11 +120,21 @@
       <version>${project.version}</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>oak-mongomk</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
       <groupId>com.h2database</groupId>
       <artifactId>h2</artifactId>
       <version>1.3.158</version>
     </dependency>
     <dependency>
+      <groupId>org.mongodb</groupId>
+      <artifactId>mongo-java-driver</artifactId>
+      <version>2.7.1</version>
+    </dependency>
+    <dependency>
       <groupId>org.apache.jackrabbit</groupId>
       <artifactId>jackrabbit-jcr-server</artifactId>
       <version>${jackrabbit.version}</version>

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/Benchmark.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/Benchmark.java?rev=1447728&r1=1447727&r2=1447728&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/Benchmark.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/Benchmark.java
Tue Feb 19 14:15:50 2013
@@ -36,7 +36,11 @@ public class Benchmark {
     private static final Map<String, RepositoryFixture> FIXTURES =
             ImmutableMap.<String, RepositoryFixture>builder()
             .put("Jackrabbit", new JackrabbitRepositoryFixture())
-            .put("Oak-Memory", new OakRepositoryFixture())
+            .put("Oak-Memory", OakRepositoryFixture.getMemory())
+            .put("Oak-Default", OakRepositoryFixture.getDefault())
+            .put("Oak-Mongo", OakRepositoryFixture.getMongo())
+            .put("Oak-NewMongo", OakRepositoryFixture.getNewMongo())
+            .put("Oak-Segment", OakRepositoryFixture.getSegment())
             .build();
 
     private static final Map<String, AbstractTest> TESTS =

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=1447728&r1=1447727&r2=1447728&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 Feb 19 14:15:50 2013
@@ -16,25 +16,142 @@
  */
 package org.apache.jackrabbit.oak.fixture;
 
+import java.io.File;
+
 import javax.jcr.Repository;
 
+import org.apache.commons.io.FileUtils;
+import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.mk.core.MicroKernelImpl;
+import org.apache.jackrabbit.mongomk.impl.MongoConnection;
+import org.apache.jackrabbit.mongomk.impl.MongoMicroKernel;
+import org.apache.jackrabbit.mongomk.impl.MongoNodeStore;
+import org.apache.jackrabbit.mongomk.impl.blob.MongoBlobStore;
+import org.apache.jackrabbit.mongomk.prototype.MongoMK;
 import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.jcr.Jcr;
+import org.apache.jackrabbit.oak.plugins.segment.MongoStore;
+import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore;
+import org.apache.jackrabbit.oak.plugins.segment.SegmentStore;
+
+import com.mongodb.Mongo;
+
+public abstract class OakRepositoryFixture implements RepositoryFixture {
+
+    public static RepositoryFixture getMemory() {
+        return new OakRepositoryFixture() {
+            @Override
+            public void setUpCluster(Repository[] cluster) throws Exception {
+                MicroKernel kernel = new MicroKernelImpl();
+                for (int i = 0; i < cluster.length; i++) {
+                    Oak oak = new Oak(kernel);
+                    cluster[i] = new Jcr(oak).createRepository();
+                }
+            }
+        };
+    }
+
+    public static RepositoryFixture getDefault() {
+        return new OakRepositoryFixture() {
+            private File file = new File("oak-benchmark-microkernel");
+            private MicroKernelImpl[] kernels;
+            @Override
+            public void setUpCluster(Repository[] cluster) throws Exception {
+                kernels = new MicroKernelImpl[cluster.length];
+                for (int i = 0; i < cluster.length; i++) {
+                    kernels[i] = new MicroKernelImpl(file.getName());
+                    cluster[i] = new Jcr(kernels[i]).createRepository();
+                }
+            }
+            @Override
+            public void tearDownCluster(Repository[] cluster) {
+                for (MicroKernelImpl kernel : kernels) {
+                    kernel.dispose();
+                }
+                FileUtils.deleteQuietly(file);
+            }
+        };
+    }
 
-public class OakRepositoryFixture implements RepositoryFixture {
+    public static RepositoryFixture getMongo() {
+        return new OakRepositoryFixture() {
+            private MongoConnection mongo;
+            private MongoMicroKernel[] kernels;
+            @Override
+            public void setUpCluster(Repository[] cluster) throws Exception {
+                mongo = new MongoConnection(
+                        "127.0.0.1", 27017, "oak-benchmark-mongo");
+                kernels = new MongoMicroKernel[cluster.length];
+                for (int i = 0; i < cluster.length; i++) {
+                    kernels[i] = new MongoMicroKernel(
+                            mongo,
+                            new MongoNodeStore(mongo.getDB()),
+                            new MongoBlobStore(mongo.getDB()));
+                    cluster[i] = new Jcr(kernels[i]).createRepository();
+                }
+            }
+            @Override
+            public void tearDownCluster(Repository[] cluster) {
+                for (MongoMicroKernel kernel : kernels) {
+                    kernel.dispose();
+                }
+                mongo.getDB().dropDatabase();
+                mongo.close();
+            }
+        };
+    }
+
+    public static RepositoryFixture getNewMongo() {
+        return new OakRepositoryFixture() {
+            private MongoConnection mongo;
+            private MongoMK[] kernels;
+            @Override
+            public void setUpCluster(Repository[] cluster) throws Exception {
+                mongo = new MongoConnection(
+                        "127.0.0.1", 27017, "oak-benchmark-newmongo");
+                kernels = new MongoMK[cluster.length];
+                for (int i = 0; i < cluster.length; i++) {
+                    kernels[i] = new MongoMK(mongo.getDB(), i);
+                    cluster[i] = new Jcr(kernels[i]).createRepository();
+                }
+            }
+            @Override
+            public void tearDownCluster(Repository[] cluster) {
+                for (MongoMK kernel : kernels) {
+                    kernel.dispose();
+                }
+                mongo.getDB().dropDatabase();
+                mongo.close();
+            }
+        };
+    }
+
+    public static RepositoryFixture getSegment() {
+        return new OakRepositoryFixture() {
+            private Mongo mongo;
+            @Override
+            public void setUpCluster(Repository[] cluster) throws Exception {
+                mongo = new Mongo();
+                for (int i = 0; i < cluster.length; i++) {
+                    SegmentStore store = new MongoStore(
+                            mongo.getDB("oak-benchmark-segment"));
+                    Oak oak = new Oak(new SegmentNodeStore(store));
+                    cluster[i] = new Jcr(oak).createRepository();
+                }
+            }
+            @Override
+            public void tearDownCluster(Repository[] cluster) {
+                mongo.getDB("oak-benchmark-segment").dropDatabase();
+                mongo.close();
+            }
+        };
+    }
 
     @Override
     public boolean isAvailable() {
         return true;
     }
 
-    @Override
-    public void setUpCluster(Repository[] cluster) throws Exception {
-        Oak oak = new Oak();
-        for (int i = 0; i < cluster.length; i++) {
-            cluster[i] = new Jcr(oak).createRepository();
-        }
-    }
 
     @Override
     public void syncRepositoryCluster(Repository... nodes) {



Mime
View raw message