jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r544244 - in /jackrabbit/branches/1.3/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java test/java/org/apache/jackrabbit/core/ConcurrentVersioningTest.java
Date Mon, 04 Jun 2007 20:21:49 GMT
Author: jukka
Date: Mon Jun  4 13:21:48 2007
New Revision: 544244

URL: http://svn.apache.org/viewvc?view=rev&rev=544244
Log:
1.3: Merged revisions 533152 and 533162 (JCR-672)

Added:
    jackrabbit/branches/1.3/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningTest.java
      - copied, changed from r533152, jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningTest.java
Modified:
    jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java

Modified: jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?view=diff&rev=544244&r1=544243&r2=544244
==============================================================================
--- jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
(original)
+++ jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Mon Jun  4 13:21:48 2007
@@ -701,6 +701,11 @@
                 /* Let the shared item listeners know about the change */
                 shared.persisted();
 
+                // downgrade to read lock
+                acquireReadLock();
+                rwLock.writeLock().release();
+                holdingWriteLock = false;
+
                 /* notify virtual providers about node references */
                 for (int i = 0; i < virtualNodeReferences.length; i++) {
                     List virtualRefs = virtualNodeReferences[i];
@@ -711,11 +716,6 @@
                         }
                     }
                 }
-
-                // downgrade to read lock
-                acquireReadLock();
-                rwLock.writeLock().release();
-                holdingWriteLock = false;
 
                 /* dispatch the events */
                 events.dispatch();

Copied: jackrabbit/branches/1.3/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningTest.java
(from r533152, jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.3/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningTest.java?view=diff&rev=544244&p1=jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningTest.java&r1=533152&p2=jackrabbit/branches/1.3/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningTest.java&r2=544244
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningTest.java
(original)
+++ jackrabbit/branches/1.3/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningTest.java
Mon Jun  4 13:21:48 2007
@@ -21,6 +21,10 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Node;
+import javax.jcr.version.Version;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Random;
 
 /**
  * <code>ConcurrentVersioningTest</code> contains test cases that run version
@@ -37,7 +41,7 @@
      * The total number of operations to execute. E.g. number of checkins
      * performed by the threads.
      */
-    private static final int NUM_OPERATIONS = 100;
+    private static final int NUM_OPERATIONS = 200;
 
     public void testConcurrentAddVersionable() throws RepositoryException {
         runTask(new Task() {
@@ -88,6 +92,33 @@
                         n.checkin();
                         n.checkout();
                     }
+                } finally {
+                    session.logout();
+                }
+            }
+        }, CONCURRENCY);
+    }
+
+    public void testConcurrentRestore() throws RepositoryException {
+        runTask(new Task() {
+            public void execute(Session session, Node test) throws RepositoryException {
+                try {
+                    Node n = test.addNode("test");
+                    n.addMixin(mixVersionable);
+                    session.save();
+                    // create 3 version
+                    List versions = new ArrayList();
+                    for (int i = 0; i < 3; i++) {
+                        n.checkout();
+                        versions.add(n.checkin());
+                    }
+                    // do random restores
+                    Random rand = new Random();
+                    for (int i = 0; i < NUM_OPERATIONS / CONCURRENCY; i++) {
+                        Version v = (Version) versions.get(rand.nextInt(versions.size()));
+                        n.restore(v, true);
+                    }
+                    n.checkout();
                 } finally {
                     session.logout();
                 }



Mime
View raw message