jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1569277 - in /jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak: benchmark/BenchmarkRunner.java fixture/OakRepositoryFixture.java
Date Tue, 18 Feb 2014 11:27:23 GMT
Author: mreutegg
Date: Tue Feb 18 11:27:23 2014
New Revision: 1569277

URL: http://svn.apache.org/r1569277
Log:
OAK-1428: Change Oak-Mongo fixture to DocumentNodeStore

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=1569277&r1=1569276&r2=1569277&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
Tue Feb 18 11:27:23 2014
@@ -89,6 +89,10 @@ public class BenchmarkRunner {
                         host.value(options), port.value(options),
                         dbName.value(options), dropDBAfterTest.value(options),
                         cacheSize * MB),
+                OakRepositoryFixture.getMongoMK(
+                        host.value(options), port.value(options),
+                        dbName.value(options), dropDBAfterTest.value(options),
+                        cacheSize * MB),
                 OakRepositoryFixture.getSegment(
                         host.value(options), port.value(options), cacheSize),
                 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=1569277&r1=1569276&r2=1569277&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 18 11:27:23 2014
@@ -89,80 +89,31 @@ public abstract class OakRepositoryFixtu
     public static RepositoryFixture getMongo(
             final String host, final int port, final String database,
             final boolean dropDBAfterTest, final long cacheSize) {
+        return getMongo("Oak-Mongo", false, host, port, database,
+                dropDBAfterTest, cacheSize);
+    }
 
-        return new OakRepositoryFixture("Oak-Mongo") {
-            private String dbName = database != null ? database : unique;
-            private DocumentMK[] kernels;
-            private BlobStore blobStore;
-
-            private BlobStore getBlobStore() {
-                BlobStoreConfiguration config =
-                        BlobStoreConfiguration.newInstance().loadFromSystemProps();
-                try {
-                    blobStore =
-                            BlobStoreHelper.create(config).orNull();
-                } catch (Exception e) {
-                    throw new RuntimeException(e);
-                }
-
-                return blobStore;
-            }
-
-            @Override
-            protected Repository[] internalSetUpCluster(int n) throws Exception {
-                Repository[] cluster = new Repository[n];
-                kernels = new DocumentMK[cluster.length];
-                for (int i = 0; i < cluster.length; i++) {
-                    MongoConnection mongo =
-                            new MongoConnection(host, port, dbName);
-                    BlobStore blobStore = getBlobStore();
-                    DocumentMK.Builder mkBuilder = new DocumentMK.Builder().
-                            setMongoDB(mongo.getDB()).
-                            setClusterId(i).setLogging(false);
-                    if (blobStore != null) {
-                            mkBuilder.setBlobStore(blobStore);
-                    }
-                    kernels[i] = mkBuilder.open();
-                    Oak oak = new Oak(new KernelNodeStore(kernels[i], cacheSize));
-                    cluster[i] = new Jcr(oak).createRepository();
-                }
-                return cluster;
-            }
-
-            @Override
-            public void tearDownCluster() {
-                super.tearDownCluster();
-                for (DocumentMK kernel : kernels) {
-                    kernel.dispose();
-                }
-                if (dropDBAfterTest) {
-                    try {
-                        MongoConnection mongo =
-                                new MongoConnection(host, port, dbName);
-                        mongo.getDB().dropDatabase();
-                        mongo.close();
-                        if (blobStore instanceof CloudBlobStore) {
-                            ((CloudBlobStore) blobStore).deleteBucket();
-                        } else if (blobStore instanceof DataStoreBlobStore) {
-                            ((DataStoreBlobStore) blobStore).clearInUse();
-                            ((DataStoreBlobStore) blobStore).deleteAllOlderThan(
-                                    System.currentTimeMillis() + 10000000);
-                        }
-                    } catch (Exception e) {
-                        throw new RuntimeException(e);
-                    }
-                }
-            }
-        };
+    public static RepositoryFixture getMongoMK(
+            final String host, final int port, final String database,
+            final boolean dropDBAfterTest, final long cacheSize) {
+        return getMongo("Oak-MongoMK", true, host, port, database,
+                dropDBAfterTest, cacheSize);
     }
 
     public static RepositoryFixture getMongoNS(
             final String host, final int port, final String database,
             final boolean dropDBAfterTest, final long cacheSize) {
+        return getMongo("Oak-MongoNS", false, host, port, database,
+                dropDBAfterTest, cacheSize);
+    }
 
-        return new OakRepositoryFixture("Oak-MongoNS") {
+    private static RepositoryFixture getMongo(String name, final boolean useMK,
+            final String host, final int port, final String database,
+            final boolean dropDBAfterTest, final long cacheSize) {
+
+        return new OakRepositoryFixture(name) {
             private String dbName = database != null ? database : unique;
-            private DocumentNodeStore[] stores;
+            private DocumentMK[] kernels;
             private BlobStore blobStore;
 
             private BlobStore getBlobStore() {
@@ -181,21 +132,25 @@ public abstract class OakRepositoryFixtu
             @Override
             protected Repository[] internalSetUpCluster(int n) throws Exception {
                 Repository[] cluster = new Repository[n];
-                stores = new DocumentNodeStore[cluster.length];
+                kernels = new DocumentMK[cluster.length];
                 for (int i = 0; i < cluster.length; i++) {
                     MongoConnection mongo =
                             new MongoConnection(host, port, dbName);
                     BlobStore blobStore = getBlobStore();
-                    DocumentMK.Builder mkBuilder =
-                            new DocumentMK.Builder().
+                    DocumentMK.Builder mkBuilder = new DocumentMK.Builder().
                             setMongoDB(mongo.getDB()).
                             memoryCacheSize(cacheSize).
                             setClusterId(i).setLogging(false);
                     if (blobStore != null) {
-                        mkBuilder.setBlobStore(blobStore);
+                            mkBuilder.setBlobStore(blobStore);
+                    }
+                    kernels[i] = mkBuilder.open();
+                    Oak oak;
+                    if (useMK) {
+                        oak = new Oak(new KernelNodeStore(kernels[i], cacheSize));
+                    } else {
+                        oak = new Oak(kernels[i].getNodeStore());
                     }
-                    stores[i] = mkBuilder.getNodeStore();             
-                    Oak oak = new Oak(stores[i]);
                     cluster[i] = new Jcr(oak).createRepository();
                 }
                 return cluster;
@@ -204,8 +159,8 @@ public abstract class OakRepositoryFixtu
             @Override
             public void tearDownCluster() {
                 super.tearDownCluster();
-                for (DocumentNodeStore store : stores) {
-                    store.dispose();
+                for (DocumentMK kernel : kernels) {
+                    kernel.dispose();
                 }
                 if (dropDBAfterTest) {
                     try {



Mime
View raw message