jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r604211 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle: ./ util/
Date Fri, 14 Dec 2007 15:24:14 GMT
Author: tripod
Date: Fri Dec 14 07:23:58 2007
New Revision: 604211

URL: http://svn.apache.org/viewvc?rev=604211&view=rev
Log:
JCR-832 BundleDBPersistenceManager does not free blobStore resources

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java?rev=604211&r1=604210&r2=604211&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
Fri Dec 14 07:23:58 2007
@@ -42,6 +42,7 @@
 import org.apache.jackrabbit.core.persistence.bundle.util.BundleCache;
 import org.apache.jackrabbit.core.persistence.bundle.util.LRUNodeIdCache;
 import org.apache.jackrabbit.core.persistence.bundle.util.HashMapIndex;
+import org.apache.jackrabbit.core.persistence.bundle.util.BundleBinding;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.name.NameConstants;
 
@@ -392,6 +393,12 @@
     protected abstract void store(NodeReferences refs)
             throws ItemStateException;
 
+    /**
+     * Returns the bundle binding that is used for serializing the bundles.
+     * @return the bundle binding
+     */
+    protected abstract BundleBinding getBinding();
+
     //-------------------------------------------------< PersistenceManager >---
 
     /**
@@ -536,7 +543,7 @@
         while (iter.hasNext()) {
             ItemState state = (ItemState) iter.next();
             if (state.isNode()) {
-                NodePropBundle bundle = new NodePropBundle((NodeState) state);
+                NodePropBundle bundle = new NodePropBundle(getBinding(), (NodeState) state);
                 modified.put(state.getId(), bundle);
             }
         }
@@ -682,6 +689,7 @@
      */
     private void deleteBundle(NodePropBundle bundle) throws ItemStateException {
         destroyBundle(bundle);
+        bundle.removeAllProperties();
         bundles.remove(bundle.getId());
         missing.put(bundle.getId());
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java?rev=604211&r1=604210&r2=604211&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
Fri Dec 14 07:23:58 2007
@@ -580,6 +580,13 @@
     }
 
     /**
+     * {@inheritDoc}
+     */
+    protected BundleBinding getBinding() {
+        return binding;
+    }
+
+    /**
      * Creates a suitable blobstore
      * @return a blobstore
      * @throws Exception if an unspecified error occurs
@@ -1036,8 +1043,6 @@
     protected synchronized void destroyBundle(NodePropBundle bundle) throws ItemStateException
{
         try {
             connectionManager.executeStmt(bundleDeleteSQL, getKey(bundle.getId().getUUID()));
-            // also delete all
-            bundle.removeAllProperties();
         } catch (Exception e) {
             if (e instanceof NoSuchItemStateException) {
                 throw (NoSuchItemStateException) e;
@@ -1086,13 +1091,13 @@
     }
 
     /**
+     * {@inheritDoc}
+     *
      * This method uses shared <code>PreparedStatements</code>, which must
      * be used strictly sequentially. Because this method synchronizes on the
      * persistence manager instance, there is no need to synchronize on the
      * shared statement. If the method would not be synchronized, the shared
      * statement must be synchronized.
-     *
-     * @see AbstractPersistenceManager#store(NodeReferences)
      */
     public synchronized void store(NodeReferences refs) throws ItemStateException {
         if (!initialized) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java?rev=604211&r1=604210&r2=604211&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java
Fri Dec 14 07:23:58 2007
@@ -212,6 +212,13 @@
     /**
      * {@inheritDoc}
      */
+    protected BundleBinding getBinding() {
+        return binding;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public synchronized void close() throws Exception {
         if (!initialized) {
             throw new IllegalStateException("not initialized");

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java?rev=604211&r1=604210&r2=604211&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java
Fri Dec 14 07:23:58 2007
@@ -63,6 +63,7 @@
      * @param blobStore the blobstore for retrieving blobs
      * @param nsIndex the namespace index
      * @param nameIndex the name index
+     * @param dataStore the data store
      */
     public BundleBinding(ErrorHandling errorHandling, BLOBStore blobStore,
                          StringIndex nsIndex, StringIndex nameIndex, DataStore dataStore)
{
@@ -80,7 +81,7 @@
     public NodePropBundle readBundle(DataInputStream in, NodeId id)
             throws IOException {
 
-        NodePropBundle bundle = new NodePropBundle(id);
+        NodePropBundle bundle = new NodePropBundle(this, id);
 
         // read version and primary type...special handling
         int index = in.readInt();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java?rev=604211&r1=604210&r2=604211&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java
Fri Dec 14 07:23:58 2007
@@ -93,6 +93,7 @@
      * @param blobStore the blobstore
      * @param nsIndex the namespace index
      * @param nameIndex the name index
+     * @param dataStore the data store
      */
     public ItemStateBinding(ErrorHandling errorHandling,
                             BLOBStore blobStore,
@@ -122,6 +123,14 @@
      */
     public void setMinBlobSize(long minBlobSize) {
         this.minBlobSize = minBlobSize;
+    }
+
+    /**
+     * Returns the blob store that is assosiated with this binding.
+     * @return the blob store
+     */
+    public BLOBStore getBlobStore() {
+        return blobStore;
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java?rev=604211&r1=604210&r2=604211&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java
Fri Dec 14 07:23:58 2007
@@ -28,6 +28,7 @@
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.PropertyId;
 import org.apache.jackrabbit.core.persistence.PersistenceManager;
+import org.apache.jackrabbit.core.persistence.util.BLOBStore;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.state.NodeState;
@@ -35,6 +36,8 @@
 import org.apache.jackrabbit.core.nodetype.PropDefId;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.name.NameConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * This Class provides a simple structure to hold the nodestate and related
@@ -46,6 +49,16 @@
     static final String CVS_ID = "$URL$ $Rev$ $Date$";
 
     /**
+     * default logger
+     */
+    private static Logger log = LoggerFactory.getLogger(NodePropBundle.class);
+
+    /**
+     * the bundle binding that handles this bundle
+     */
+    private final BundleBinding binding;
+
+    /**
      * the node id
      */
     private final NodeId id;
@@ -102,18 +115,21 @@
 
     /**
      * Creates a "new" bundle with the given id
+     * @param binding the bundle binding
      * @param id the node id
      */
-    public NodePropBundle(NodeId id) {
+    public NodePropBundle(BundleBinding binding, NodeId id) {
+        this.binding = binding;
         this.id = id;
     }
 
     /**
      * Creates a bundle from the given state
+     * @param binding the bundle binding
      * @param state the node state
      */
-    public NodePropBundle(NodeState state) {
-        this((NodeId) state.getId());
+    public NodePropBundle(BundleBinding binding, NodeState state) {
+        this(binding, (NodeId) state.getId());
         update(state);
     }
 
@@ -346,7 +362,7 @@
     public void addProperty(PropertyState state) {
         PropertyEntry old = (PropertyEntry) properties.put(state.getName(), new PropertyEntry(state));
         if (old != null) {
-            old.destroy();
+            old.destroy(binding.getBlobStore());
         }
     }
 
@@ -407,7 +423,7 @@
     public void removeProperty(Name name) {
         PropertyEntry pe = (PropertyEntry) properties.remove(name);
         if (pe != null) {
-            pe.destroy();
+            pe.destroy(binding.getBlobStore());
         }
     }
 
@@ -678,18 +694,22 @@
 
         /**
          * Destroys this property state and deletes temporary blob file values.
+         * @param blobStore the blobstore that will destroy the blobs
          */
-        private void destroy() {
-            if (type == PropertyType.BINARY) {
-                // destroy binary property values
-                for (int i=0; i<values.length; i++) {
-                    values[i].getBLOBFileValue().delete(true);
+        private void destroy(BLOBStore blobStore) {
+            // delete blobs if needed
+            if (blobIds != null) {
+                for (int i=0; i<blobIds.length; i++) {
+                    if (blobIds[i] != null) {
+                        try {
+                            blobStore.remove(blobIds[i]);
+                            log.debug("removed blob {}", blobIds[i]);
+                        } catch (Exception e) {
+                            log.error("Ingoring error while removing blob {}", blobIds[i],
e);
+                        }
+                    }
                 }
             }
         }
-
-
     }
-
-
 }



Mime
View raw message