jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1528400 - in /jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak: benchmark/BenchmarkRunner.java fixture/OakRepositoryFixture.java
Date Wed, 02 Oct 2013 09:53:07 GMT
Author: mreutegg
Date: Wed Oct  2 09:53:07 2013
New Revision: 1528400

URL: http://svn.apache.org/r1528400
Log:
OAK-1061: Add option for database name

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

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java?rev=1528400&r1=1528399&r2=1528400&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
Wed Oct  2 09:53:07 2013
@@ -43,6 +43,10 @@ public class BenchmarkRunner {
                 .withRequiredArg().defaultsTo("localhost");
         OptionSpec<Integer> port = parser.accepts("port", "MongoDB port")
                 .withRequiredArg().ofType(Integer.class).defaultsTo(27017);
+        OptionSpec<String> dbName = parser.accepts("db", "MongoDB database")
+                .withRequiredArg();
+        OptionSpec<Boolean> dropDBAfterTest = parser.accepts("dropDBAfterTest", "Whether
to drop the MongoDB database after the test")
+                .withOptionalArg().ofType(Boolean.class).defaultsTo(true);
         OptionSpec<Boolean> mmap = parser.accepts("mmap", "TarMK memory mapping")
                 .withOptionalArg().ofType(Boolean.class)
                 .defaultsTo("64".equals(System.getProperty("sun.arch.data.model")));
@@ -70,7 +74,9 @@ public class BenchmarkRunner {
                 OakRepositoryFixture.getDefault(
                         base.value(options), cacheSize * MB),
                 OakRepositoryFixture.getMongo(
-                        host.value(options), port.value(options), cacheSize * MB),
+                        host.value(options), port.value(options),
+                        dbName.value(options), dropDBAfterTest.value(options),
+                        cacheSize * MB),
                 OakRepositoryFixture.getSegment(
                         host.value(options), port.value(options), cacheSize * MB),
                 OakRepositoryFixture.getTar(

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=1528400&r1=1528399&r2=1528400&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
Wed Oct  2 09:53:07 2013
@@ -79,8 +79,10 @@ public abstract class OakRepositoryFixtu
     }
 
     public static RepositoryFixture getMongo(
-            final String host, final int port, final long cacheSize) {
+            final String host, final int port, final String database,
+            final boolean dropDBAfterTest, final long cacheSize) {
         return new OakRepositoryFixture("Oak-Mongo") {
+            private String dbName = database != null ? database : unique;
             private MongoMK[] kernels;
             @Override
             public Repository[] setUpCluster(int n) throws Exception {
@@ -88,10 +90,10 @@ public abstract class OakRepositoryFixtu
                 kernels = new MongoMK[cluster.length];
                 for (int i = 0; i < cluster.length; i++) {
                     MongoConnection mongo =
-                            new MongoConnection(host, port, unique);
+                            new MongoConnection(host, port, dbName);
                     kernels[i] = new MongoMK.Builder().
                             setMongoDB(mongo.getDB()).
-                            setClusterId(i).open();
+                            setClusterId(i).setLogging(false).open();
                     Oak oak = new Oak(new KernelNodeStore(kernels[i], cacheSize));
                     cluster[i] = new Jcr(oak).createRepository();
                 }
@@ -102,13 +104,15 @@ public abstract class OakRepositoryFixtu
                 for (MongoMK kernel : kernels) {
                     kernel.dispose();
                 }
-                try {
-                    MongoConnection mongo =
-                            new MongoConnection(host, port, unique);
-                    mongo.getDB().dropDatabase();
-                    mongo.close();
-                } catch (Exception e) {
-                    throw new RuntimeException(e);
+                if (dropDBAfterTest) {
+                    try {
+                        MongoConnection mongo =
+                                new MongoConnection(host, port, dbName);
+                        mongo.getDB().dropDatabase();
+                        mongo.close();
+                    } catch (Exception e) {
+                        throw new RuntimeException(e);
+                    }
                 }
             }
         };



Mime
View raw message