jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1478285 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/ oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/
Date Thu, 02 May 2013 06:48:34 GMT
Author: jukka
Date: Thu May  2 06:48:33 2013
New Revision: 1478285

URL: http://svn.apache.org/r1478285
Log:
OAK-788: File backend for the SegmentMK

In FileStore.close(), clear out references to the buffers and trigger garbage collection in
an attempt to drop the mmap() references to the dataNNNNN.tar files

Improve the SegmentMK fixtures

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java
    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/JackrabbitRepositoryFixture.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakRepositoryFixture.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java?rev=1478285&r1=1478284&r2=1478285&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java
Thu May  2 06:48:33 2013
@@ -84,6 +84,12 @@ public class FileStore implements Segmen
 
     public void close() {
         rw.force();
+
+        segments.clear();
+        rw = null;
+        ro = null;
+
+        System.gc();
     }
 
     private boolean loadSegments() throws IOException {

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=1478285&r1=1478284&r2=1478285&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
Thu May  2 06:48:33 2013
@@ -38,6 +38,9 @@ public class BenchmarkRunner {
 
     public static void main(String[] args) throws Exception {
         OptionParser parser = new OptionParser();
+        OptionSpec<File> base = parser.accepts("base", "Base directory")
+                .withRequiredArg().ofType(File.class)
+                .defaultsTo(new File("target"));
         OptionSpec<String> host = parser.accepts("host", "MongoDB host")
                 .withRequiredArg().defaultsTo("localhost");
         OptionSpec<Integer> port = parser.accepts("port", "MongoDB port")
@@ -51,14 +54,16 @@ public class BenchmarkRunner {
         OptionSet options = parser.parse(args);
         int cacheSize = cache.value(options);
         RepositoryFixture[] allFixtures = new RepositoryFixture[] {
-                new JackrabbitRepositoryFixture(cacheSize),
+                new JackrabbitRepositoryFixture(
+                        base.value(options), cacheSize),
                 OakRepositoryFixture.getMemory(cacheSize * MB),
-                OakRepositoryFixture.getDefault(cacheSize * MB),
+                OakRepositoryFixture.getDefault(
+                        base.value(options), cacheSize * MB),
                 OakRepositoryFixture.getMongo(
                         host.value(options), port.value(options), cacheSize * MB),
                 OakRepositoryFixture.getSegment(
                         host.value(options), port.value(options), cacheSize * MB),
-                OakRepositoryFixture.getTar("data.tar")
+                OakRepositoryFixture.getTar(base.value(options))
         };
         Benchmark[] allBenchmarks = new Benchmark[] {
             new LoginTest(),

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/JackrabbitRepositoryFixture.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/JackrabbitRepositoryFixture.java?rev=1478285&r1=1478284&r2=1478285&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/JackrabbitRepositoryFixture.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/JackrabbitRepositoryFixture.java
Thu May  2 06:48:33 2013
@@ -23,21 +23,22 @@ import java.io.InputStream;
 import java.util.Properties;
 
 import javax.jcr.Repository;
-import javax.xml.transform.stream.StreamSource;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
-import org.apache.jackrabbit.core.config.RepositoryConfigurationParser;
 import org.xml.sax.InputSource;
 
 public class JackrabbitRepositoryFixture implements RepositoryFixture {
 
+    private final File base;
+
     private final int bundleCacheSize;
 
     private RepositoryImpl[] cluster;
 
-    public JackrabbitRepositoryFixture(int bundleCacheSize) {
+    public JackrabbitRepositoryFixture(File base, int bundleCacheSize) {
+        this.base = base;
         this.bundleCacheSize = bundleCacheSize;
     }
 
@@ -50,7 +51,7 @@ public class JackrabbitRepositoryFixture
     public Repository[] setUpCluster(int n) throws Exception {
         if (n == 1) {
             String name = "Jackrabbit-" + System.currentTimeMillis();
-            File directory = new File(name);
+            File directory = new File(base, name);
 
             Properties variables = new Properties(System.getProperties());
             variables.setProperty(

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=1478285&r1=1478284&r2=1478285&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
Thu May  2 06:48:33 2013
@@ -52,7 +52,8 @@ public abstract class OakRepositoryFixtu
         };
     }
 
-    public static RepositoryFixture getDefault(final long cacheSize) {
+    public static RepositoryFixture getDefault(
+            final File base, final long cacheSize) {
         return new OakRepositoryFixture("Oak-Default") {
             private MicroKernelImpl[] kernels;
             @Override
@@ -60,7 +61,8 @@ public abstract class OakRepositoryFixtu
                 Repository[] cluster = new Repository[n];
                 kernels = new MicroKernelImpl[cluster.length];
                 for (int i = 0; i < cluster.length; i++) {
-                    kernels[i] = new MicroKernelImpl(unique);
+                    kernels[i] = new MicroKernelImpl(
+                            new File(base, unique).getPath());
                     Oak oak = new Oak(new KernelNodeStore(kernels[i], cacheSize));
                     cluster[i] = new Jcr(oak).createRepository();
                 }
@@ -71,7 +73,7 @@ public abstract class OakRepositoryFixtu
                 for (MicroKernelImpl kernel : kernels) {
                     kernel.dispose();
                 }
-                FileUtils.deleteQuietly(new File(unique));
+                FileUtils.deleteQuietly(new File(base, unique));
             }
         };
     }
@@ -115,39 +117,52 @@ public abstract class OakRepositoryFixtu
     public static RepositoryFixture getSegment(
             final String host, final int port, final long cacheSize) {
         return new OakRepositoryFixture("Oak-Segment") {
+            private SegmentStore[] stores;
             private Mongo mongo;
             @Override
             public Repository[] setUpCluster(int n) throws Exception {
                 Repository[] cluster = new Repository[n];
+                stores = new FileStore[cluster.length];
                 mongo = new Mongo(host, port);
                 for (int i = 0; i < cluster.length; i++) {
-                    SegmentStore store =
-                            new MongoStore(mongo.getDB(unique), cacheSize);
-                    Oak oak = new Oak(new SegmentNodeStore(store));
+                    stores[i] = new MongoStore(mongo.getDB(unique), cacheSize);
+                    Oak oak = new Oak(new SegmentNodeStore(stores[i]));
                     cluster[i] = new Jcr(oak).createRepository();
                 }
                 return cluster;
             }
             @Override
             public void tearDownCluster() {
+                for (SegmentStore store : stores) {
+                    store.close();
+                }
                 mongo.getDB(unique).dropDatabase();
                 mongo.close();
             }
         };
     }
 
-    public static RepositoryFixture getTar(final String file) {
+    public static RepositoryFixture getTar(final File base) {
         return new OakRepositoryFixture("Oak-Tar") {
+            private SegmentStore[] stores;
             @Override
             public Repository[] setUpCluster(int n) throws Exception {
                 Repository[] cluster = new Repository[n];
+                stores = new FileStore[cluster.length];
                 for (int i = 0; i < cluster.length; i++) {
-                    SegmentStore store = new FileStore(file);
-                    Oak oak = new Oak(new SegmentNodeStore(store));
+                    stores[i] = new FileStore(new File(base, unique));
+                    Oak oak = new Oak(new SegmentNodeStore(stores[i]));
                     cluster[i] = new Jcr(oak).createRepository();
                 }
                 return cluster;
             }
+            @Override
+            public void tearDownCluster() {
+                for (SegmentStore store : stores) {
+                    store.close();
+                }
+                FileUtils.deleteQuietly(new File(base, unique));
+            }
         };
     }
 



Mime
View raw message