You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by mr...@apache.org on 2014/01/09 11:31:57 UTC

svn commit: r1556779 - /jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakRepositoryFixture.java

Author: mreutegg
Date: Thu Jan  9 10:31:56 2014
New Revision: 1556779

URL: http://svn.apache.org/r1556779
Log:
OAK-1313: Process does not exit after benchmark run

Modified:
    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/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=1556779&r1=1556778&r2=1556779&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 Jan  9 10:31:56 2014
@@ -21,6 +21,7 @@ import java.io.File;
 import javax.jcr.Repository;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.jackrabbit.api.JackrabbitRepository;
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
 import org.apache.jackrabbit.oak.plugins.mongomk.MongoMK;
@@ -41,7 +42,7 @@ public abstract class OakRepositoryFixtu
     public static RepositoryFixture getMemory(final long cacheSize) {
         return new OakRepositoryFixture("Oak-Memory") {
             @Override
-            public Repository[] setUpCluster(int n) throws Exception {
+            protected Repository[] internalSetUpCluster(int n) throws Exception {
                 Repository[] cluster = new Repository[n];
                 MicroKernel kernel = new MicroKernelImpl();
                 for (int i = 0; i < cluster.length; i++) {
@@ -58,7 +59,7 @@ public abstract class OakRepositoryFixtu
         return new OakRepositoryFixture("Oak-Default") {
             private MicroKernelImpl[] kernels;
             @Override
-            public Repository[] setUpCluster(int n) throws Exception {
+            protected Repository[] internalSetUpCluster(int n) throws Exception {
                 Repository[] cluster = new Repository[n];
                 kernels = new MicroKernelImpl[cluster.length];
                 for (int i = 0; i < cluster.length; i++) {
@@ -71,6 +72,7 @@ public abstract class OakRepositoryFixtu
             }
             @Override
             public void tearDownCluster() {
+                super.tearDownCluster();
                 for (MicroKernelImpl kernel : kernels) {
                     kernel.dispose();
                 }
@@ -86,7 +88,7 @@ public abstract class OakRepositoryFixtu
             private String dbName = database != null ? database : unique;
             private MongoMK[] kernels;
             @Override
-            public Repository[] setUpCluster(int n) throws Exception {
+            protected Repository[] internalSetUpCluster(int n) throws Exception {
                 Repository[] cluster = new Repository[n];
                 kernels = new MongoMK[cluster.length];
                 for (int i = 0; i < cluster.length; i++) {
@@ -102,6 +104,7 @@ public abstract class OakRepositoryFixtu
             }
             @Override
             public void tearDownCluster() {
+                super.tearDownCluster();
                 for (MongoMK kernel : kernels) {
                     kernel.dispose();
                 }
@@ -126,7 +129,7 @@ public abstract class OakRepositoryFixtu
             private String dbName = database != null ? database : unique;
             private MongoNodeStore[] stores;
             @Override
-            public Repository[] setUpCluster(int n) throws Exception {
+            protected Repository[] internalSetUpCluster(int n) throws Exception {
                 Repository[] cluster = new Repository[n];
                 stores = new MongoNodeStore[cluster.length];
                 for (int i = 0; i < cluster.length; i++) {
@@ -143,6 +146,7 @@ public abstract class OakRepositoryFixtu
             }
             @Override
             public void tearDownCluster() {
+                super.tearDownCluster();
                 for (MongoNodeStore store : stores) {
                     store.dispose();
                 }
@@ -166,7 +170,7 @@ public abstract class OakRepositoryFixtu
             private SegmentStore[] stores;
             private MongoClient mongo;
             @Override
-            public Repository[] setUpCluster(int n) throws Exception {
+            protected Repository[] internalSetUpCluster(int n) throws Exception {
                 Repository[] cluster = new Repository[n];
                 stores = new SegmentStore[cluster.length];
                 mongo = new MongoClient(host, port);
@@ -179,6 +183,7 @@ public abstract class OakRepositoryFixtu
             }
             @Override
             public void tearDownCluster() {
+                super.tearDownCluster();
                 for (SegmentStore store : stores) {
                     store.close();
                 }
@@ -194,7 +199,7 @@ public abstract class OakRepositoryFixtu
         return new OakRepositoryFixture("Oak-Tar") {
             private SegmentStore[] stores;
             @Override
-            public Repository[] setUpCluster(int n) throws Exception {
+            protected Repository[] internalSetUpCluster(int n) throws Exception {
                 Repository[] cluster = new Repository[n];
                 stores = new FileStore[cluster.length];
                 for (int i = 0; i < cluster.length; i++) {
@@ -208,6 +213,7 @@ public abstract class OakRepositoryFixtu
             }
             @Override
             public void tearDownCluster() {
+                super.tearDownCluster();
                 for (SegmentStore store : stores) {
                     store.close();
                 }
@@ -220,6 +226,8 @@ public abstract class OakRepositoryFixtu
 
     protected final String unique;
 
+    private Repository[] cluster;
+
     protected OakRepositoryFixture(String name) {
         this.name = name;
         this.unique = String.format("%s-%d", name, System.currentTimeMillis());
@@ -230,6 +238,11 @@ public abstract class OakRepositoryFixtu
         return true;
     }
 
+    @Override
+    public final Repository[] setUpCluster(int n) throws Exception {
+        cluster = internalSetUpCluster(n);
+        return cluster;
+    }
 
     @Override
     public void syncRepositoryCluster(Repository... nodes) {
@@ -238,7 +251,13 @@ public abstract class OakRepositoryFixtu
 
     @Override
     public void tearDownCluster() {
-        // nothing to do by default
+        if (cluster != null) {
+            for (Repository repo : cluster) {
+                if (repo instanceof JackrabbitRepository) {
+                    ((JackrabbitRepository) repo).shutdown();
+                }
+            }
+        }
     }
 
     @Override
@@ -246,4 +265,5 @@ public abstract class OakRepositoryFixtu
         return name;
     }
 
+    protected abstract Repository[] internalSetUpCluster(int n) throws Exception;
 }



Re: svn commit: r1556779 - /jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakRepositoryFixture.java

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Thu, Jan 9, 2014 at 10:04 AM, Michael Dürig <md...@apache.org> wrote:
> What's the purpose of having a shutdown method then?
>
> JackrabbitRepository.shutdown() clearly states: "This method [...]
> <em>must</em> therefore be called by the client application once the
> repository instance is no longer used."

The shutdown() method is troublesome for various reasons [1,2,3]. As
suggested in JCR-2958, I'd opt to deprecate it in the API and have Oak
implement it as a no-op.

[1] https://issues.apache.org/jira/browse/JCR-2958
[2] http://markmail.org/message/dsqyv3rafo4j5xea
[3] http://markmail.org/message/ghfqwhivipkxakwh

BR,

Jukka Zitting

Re: svn commit: r1556779 - /jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakRepositoryFixture.java

Posted by Michael Dürig <md...@apache.org>.

On 9.1.14 4:00 , Marcel Reutegger wrote:
>> On Thu, Jan 9, 2014 at 5:31 AM,  <mr...@apache.org> wrote:
>>> +                if (repo instanceof JackrabbitRepository) {
>>> +                    ((JackrabbitRepository) repo).shutdown();
>>> +                }
>>
>> This looks ugly. It would be nice if the JCR repository wrapper around
>>   was stateless, i.e. could simply be collected as normal garbage when
>> no longer used.
>
> yes, this would indeed be cleaner and require to revisit the changes
> for OAK-941. those changes actually introduced the issue with a
> scheduled executor that needs to be shut down.

What's the purpose of having a shutdown method then?

JackrabbitRepository.shutdown() clearly states: "This method [...] 
<em>must</em> therefore be called by the client application once the 
repository instance is no longer used."

Michael

>
> regards
>   marcel
>

Re: svn commit: r1556779 - /jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakRepositoryFixture.java

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Thu, Jan 9, 2014 at 10:00 AM, Marcel Reutegger <mr...@adobe.com> wrote:
> yes, this would indeed be cleaner and require to revisit the changes
> for OAK-941. those changes actually introduced the issue with a
> scheduled executor that needs to be shut down.

Right. One potential solution would be to expose just a single MBean
that uses TabularData to return information about all the currently
active sessions (sorted by lifetime). Then we wouldn't need to limit
the output to just long-lived sessions, and wouldn't have to worry
about excessive service registrations or extra background tasks.

BR,

Jukka Zitting

RE: svn commit: r1556779 - /jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakRepositoryFixture.java

Posted by Marcel Reutegger <mr...@adobe.com>.
> On Thu, Jan 9, 2014 at 5:31 AM,  <mr...@apache.org> wrote:
> > +                if (repo instanceof JackrabbitRepository) {
> > +                    ((JackrabbitRepository) repo).shutdown();
> > +                }
> 
> This looks ugly. It would be nice if the JCR repository wrapper around
>  was stateless, i.e. could simply be collected as normal garbage when
> no longer used.

yes, this would indeed be cleaner and require to revisit the changes
for OAK-941. those changes actually introduced the issue with a
scheduled executor that needs to be shut down.

regards
 marcel

Re: svn commit: r1556779 - /jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakRepositoryFixture.java

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Thu, Jan 9, 2014 at 5:31 AM,  <mr...@apache.org> wrote:
> +                if (repo instanceof JackrabbitRepository) {
> +                    ((JackrabbitRepository) repo).shutdown();
> +                }

This looks ugly. It would be nice if the JCR repository wrapper around
 was stateless, i.e. could simply be collected as normal garbage when
no longer used.

BR,

Jukka Zitting