jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r727426 - in /jackrabbit/branches/1.5: ./ jackrabbit-core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/ jackrabbit-core/src/test/java/org/apache/jackrabbit/...
Date Wed, 17 Dec 2008 16:20:28 GMT
Author: jukka
Date: Wed Dec 17 08:20:27 2008
New Revision: 727426

URL: http://svn.apache.org/viewvc?rev=727426&view=rev
Log:
1.5: Merged revision 727402 (JCR-1838). Updated relevant component versions to 1.5.1-SNAPSHOT.

Modified:
    jackrabbit/branches/1.5/   (props changed)
    jackrabbit/branches/1.5/jackrabbit-core/pom.xml
    jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java
    jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java
    jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java
    jackrabbit/branches/1.5/jackrabbit-jca/pom.xml
    jackrabbit/branches/1.5/jackrabbit-standalone/pom.xml
    jackrabbit/branches/1.5/jackrabbit-webapp/pom.xml

Propchange: jackrabbit/branches/1.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec 17 08:20:27 2008
@@ -1,2 +1,2 @@
 /jackrabbit/branches/1.3:631261
-/jackrabbit/trunk:703899-704158,704165,704167,704324,704358,704361,704864,704933,704939,705010,705033,705243,705496,705522,705579,705925,705932,705934,705937-705938,705961,706242,706273,706285-706286,706562,706606,706649,706655,706660,706697,706918,707303-707304,707307,707310,707630,708206,708598,708609,708613,708619,708634,708840,708863,708909,708929,708943,709115,709142,709207,709211,710047,711238,711566-711567,711595,711841-711843,712984-712985,713037,713059,713065,713072,713076,713162,713214,713956,713958,713964,713971,713975,714034,718218,718249-718250,718371,718376,718566,718632,718981,719225,719282,719575-719577,719579,719585-719586,719588,719592,720455,720484,720492,720524,720533,720540,720673,720679,720687,720784,720940,720969,721186,721191,721194,721235,721387-721389,721470,721495,722068-722069,722463,722465,722467,722470,722825,723281,723346,723728,723784,724300,724387,725292,727376,727388,727390,727395,727397
+/jackrabbit/trunk:703899-704158,704165,704167,704324,704358,704361,704864,704933,704939,705010,705033,705243,705496,705522,705579,705925,705932,705934,705937-705938,705961,706242,706273,706285-706286,706562,706606,706649,706655,706660,706697,706918,707303-707304,707307,707310,707630,708206,708598,708609,708613,708619,708634,708840,708863,708909,708929,708943,709115,709142,709207,709211,710047,711238,711566-711567,711595,711841-711843,712984-712985,713037,713059,713065,713072,713076,713162,713214,713956,713958,713964,713971,713975,714034,718218,718249-718250,718371,718376,718566,718632,718981,719225,719282,719575-719577,719579,719585-719586,719588,719592,720455,720484,720492,720524,720533,720540,720673,720679,720687,720784,720940,720969,721186,721191,721194,721235,721387-721389,721470,721495,722068-722069,722463,722465,722467,722470,722825,723281,723346,723728,723784,724300,724387,725292,727376,727388,727390,727395,727397,727402

Modified: jackrabbit/branches/1.5/jackrabbit-core/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-core/pom.xml?rev=727426&r1=727425&r2=727426&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-core/pom.xml (original)
+++ jackrabbit/branches/1.5/jackrabbit-core/pom.xml Wed Dec 17 08:20:27 2008
@@ -34,6 +34,7 @@
   </parent>
   <artifactId>jackrabbit-core</artifactId>
   <name>Jackrabbit Core</name>
+  <version>1.5.1-SNAPSHOT</version>
   <description>Jackrabbit content repository implementation</description>
 
   <build>

Modified: jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java?rev=727426&r1=727425&r2=727426&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java
Wed Dec 17 08:20:27 2008
@@ -165,6 +165,8 @@
         File temporary = null;
         try {
             temporary = newTemporaryFile();
+            DataIdentifier tempId = new DataIdentifier(temporary.getName());
+            usesIdentifier(tempId);
             // Copy the stream to the temporary file and calculate the
             // stream length and the message digest of the stream
             long length = 0;
@@ -211,7 +213,9 @@
                     throw new IOException(DIGEST + " collision: " + file);
                 }
             }
-
+            // this will also make sure that
+            // tempId is not garbage collected until here
+            inUse.remove(tempId);
             return new FileDataRecord(identifier, file);
         } catch (NoSuchAlgorithmException e) {
             throw new DataStoreException(DIGEST + " not available", e);
@@ -275,8 +279,9 @@
         int count = 0;
         if (file.isFile() && file.exists() && file.canWrite()) {
             synchronized (this) {
+                String fileName = file.getName();
                 if (file.lastModified() < min) {
-                    DataIdentifier id = new DataIdentifier(file.getName());
+                    DataIdentifier id = new DataIdentifier(fileName);
                     if (!inUse.containsKey(id)) {
                         file.delete();
                         count++;

Modified: jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java?rev=727426&r1=727425&r2=727426&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java
Wed Dec 17 08:20:27 2008
@@ -43,6 +43,7 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.WeakHashMap;
@@ -276,6 +277,11 @@
      * All data identifiers that are currently in use are in this set until they are garbage
collected.
      */
     protected Map inUse = Collections.synchronizedMap(new WeakHashMap());
+    
+    /**
+     * The temporary identifiers that are currently in use.
+     */
+    protected List temporaryInUse = Collections.synchronizedList(new ArrayList());
 
     /**
      * {@inheritDoc}
@@ -284,8 +290,8 @@
         ResultSet rs = null;
         TempFileInputStream fileInput = null;
         ConnectionRecoveryManager conn = getConnection();
+        String id = null, tempId = null;
         try {
-            String id = null, tempId = null;
             long now;
             for (int i = 0; i < ConnectionRecoveryManager.TRIALS; i++) {
                 try {
@@ -309,6 +315,7 @@
                 log.error(msg);
                 throw new DataStoreException(msg);
             }
+            temporaryInUse.add(tempId);
             MessageDigest digest = getDigest();
             DigestInputStream dIn = new DigestInputStream(stream, digest);
             TrackingInputStream in = new TrackingInputStream(dIn);
@@ -366,6 +373,9 @@
         } catch (Exception e) {
             throw convert("Can not insert new record", e);
         } finally {
+            if (tempId != null) {
+                temporaryInUse.remove(tempId);
+            }
             DatabaseHelper.closeSilently(rs);
             putBack(conn);
             if (fileInput != null) {
@@ -398,13 +408,19 @@
     public synchronized int deleteAllOlderThan(long min) throws DataStoreException {
         ConnectionRecoveryManager conn = getConnection();
         try {
-            Iterator it = new ArrayList(inUse.keySet()).iterator();
-            while (it.hasNext()) {
+            ArrayList touch = new ArrayList();
+            for (Iterator it = new ArrayList(inUse.keySet()).iterator(); it.hasNext();) {
                 DataIdentifier identifier = (DataIdentifier) it.next();
                 if (identifier != null) {
-                    touch(identifier, 0);
+                    touch.add(identifier.toString());
                 }
             }
+            touch.addAll(temporaryInUse);
+            Iterator it = touch.iterator();
+            while (it.hasNext()) {
+                String key = (String) it.next();
+                updateLastModifiedDate(key, 0);
+            }
             // DELETE FROM DATASTORE WHERE LAST_MODIFIED<?
             PreparedStatement prep = conn.executeStmt(deleteOlderSQL, new Long[]{new Long(min)});
             return prep.getUpdateCount();
@@ -671,6 +687,10 @@
      */
     long touch(DataIdentifier identifier, long lastModified) throws DataStoreException {
         usesIdentifier(identifier);
+        return updateLastModifiedDate(identifier.toString(), lastModified);
+    }
+
+    private long updateLastModifiedDate(String key, long lastModified) throws DataStoreException
{
         if (lastModified < minModifiedDate) {
             long now = System.currentTimeMillis();
             Long n = new Long(now);
@@ -678,7 +698,7 @@
             try {
                 // UPDATE DATASTORE SET LAST_MODIFIED = ? WHERE ID = ? AND LAST_MODIFIED
< ?
                 conn.executeStmt(updateLastModifiedSQL, new Object[]{
-                        n, identifier.toString(), n
+                        n, key, n
                 });
                 return now;
             } catch (Exception e) {

Modified: jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java?rev=727426&r1=727425&r2=727426&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java
Wed Dec 17 08:20:27 2008
@@ -22,11 +22,11 @@
 import org.apache.jackrabbit.test.AbstractJCRTest;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import EDU.oswego.cs.dl.util.concurrent.SynchronousChannel;
 
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Iterator;
-
 import javax.jcr.Credentials;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
@@ -41,6 +41,61 @@
     /** logger instance */
     private static final Logger LOG = LoggerFactory.getLogger(GarbageCollectorTest.class);
 
+    public void testConcurrentGC() throws Exception {
+        Node root = testRootNode;
+        Session session = root.getSession();
+        RepositoryImpl rep = (RepositoryImpl) session.getRepository();
+        if (rep.getDataStore() == null) {
+            LOG.info("testConcurrentGC skipped. Data store is not used.");
+            return;
+        }
+        final SynchronousChannel sync = new SynchronousChannel();
+        final Node node = root.addNode("slowBlob");
+        new Thread() {
+            public void run() {
+                try {
+                    node.setProperty("slowBlob", new InputStream() {
+                        int pos = 0;
+                        public int read() throws IOException {
+                            pos++;
+                            if (pos < 10000) {
+                                return pos % 80 == 0 ? '\n' : '.';
+                            } else if (pos == 10000) {
+                                try {
+                                    sync.put("x");
+                                    // deleted
+                                    sync.take();
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+                                return 'x';
+                            }
+                            return -1;
+                        }
+                    });
+                    node.getSession().save();
+                    sync.put("saved");
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }.start();
+        assertEquals("x", sync.take());
+        GarbageCollector gc = ((SessionImpl) session).createDataStoreGarbageCollector();
+        gc.scan();
+        gc.stopScan();
+        gc.deleteUnused();
+        sync.put("deleted");
+        assertEquals("saved", sync.take());
+        InputStream in = node.getProperty("slowBlob").getStream();
+        for (int pos = 1; pos < 10000; pos++) {
+            int expected = pos % 80 == 0 ? '\n' : '.';
+            assertEquals(expected, in.read());
+        }
+        assertEquals('x', in.read());
+        in.close();
+    }
+
     public void testGC() throws Exception {
         Node root = testRootNode;
         Session session = root.getSession();

Modified: jackrabbit/branches/1.5/jackrabbit-jca/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jca/pom.xml?rev=727426&r1=727425&r2=727426&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jca/pom.xml (original)
+++ jackrabbit/branches/1.5/jackrabbit-jca/pom.xml Wed Dec 17 08:20:27 2008
@@ -35,6 +35,7 @@
   <artifactId>jackrabbit-jca</artifactId>
   <packaging>rar</packaging>
   <name>Jackrabbit JCA Resource Adapter</name>
+  <version>1.5.1-SNAPSHOT</version>
   <!--
     Keep the description on a single line. Otherwise Maven might generate
     a corrupted MANIFEST.MF (see http://jira.codehaus.org/browse/MJAR-4)
@@ -121,7 +122,7 @@
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>
       <artifactId>jackrabbit-core</artifactId>
-      <version>1.5.0</version>
+      <version>1.5.1-SNAPSHOT</version>
       <exclusions>
         <exclusion>
           <groupId>commons-logging</groupId>

Modified: jackrabbit/branches/1.5/jackrabbit-standalone/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-standalone/pom.xml?rev=727426&r1=727425&r2=727426&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-standalone/pom.xml (original)
+++ jackrabbit/branches/1.5/jackrabbit-standalone/pom.xml Wed Dec 17 08:20:27 2008
@@ -90,7 +90,7 @@
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>
       <artifactId>jackrabbit-webapp</artifactId>
-      <version>1.5.0</version>
+      <version>1.5.1-SNAPSHOT</version>
       <type>jar</type>
     </dependency>
     <dependency>

Modified: jackrabbit/branches/1.5/jackrabbit-webapp/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-webapp/pom.xml?rev=727426&r1=727425&r2=727426&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-webapp/pom.xml (original)
+++ jackrabbit/branches/1.5/jackrabbit-webapp/pom.xml Wed Dec 17 08:20:27 2008
@@ -56,7 +56,7 @@
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>
       <artifactId>jackrabbit-core</artifactId>
-      <version>1.5.0</version>
+      <version>1.5.1-SNAPSHOT</version>
       <exclusions>
         <exclusion>
           <groupId>commons-logging</groupId>



Mime
View raw message