jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r122850 - in incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: nodetype version version/persistence
Date Mon, 20 Dec 2004 14:11:33 GMT
Author: tripod
Date: Mon Dec 20 06:11:31 2004
New Revision: 122850

URL: http://svn.apache.org/viewcvs?view=rev&rev=122850
Log:
- fixing deadlock in persistence version manager
- fixing issues with frozen version histories
Modified:
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalFrozenNodeImpl.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml?view=diff&rev=122850&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml&r1=122849&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml&r2=122850
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml
Mon Dec 20 06:11:31 2004
@@ -312,5 +312,10 @@
             <supertype>nt:unstructured</supertype>
         </supertypes>
     </nodeType>
+    <nodeType name="rep:frozenVersionHistory" mixin="false" orderableChildNodes="true">
+        <supertypes>
+            <supertype>nt:unstructured</supertype>
+        </supertypes>
+    </nodeType>
 
 </nodeTypes>

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java?view=diff&rev=122850&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java&r1=122849&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java&r2=122850
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
Mon Dec 20 06:11:31 2004
@@ -207,10 +207,11 @@
                     VirtualNodeState parent = getNodeState(new NodeId(fn.getParent().getId()));
                     state = createNodeState(
                             parent,
-                            VersionManager.NODENAME_FROZEN,
+                            fn.getName(),
                             id.getUUID(),
                             NodeTypeRegistry.NT_FROZEN_VERSIONABLE_CHILD);
-                    mapFrozenNode(state, fn);
+                    state.setPropertyValue(VersionManager.PROPNAME_BASE_VERSION, InternalValue.create(UUID.fromString(fn.getBaseVersionId())));
+                    state.setPropertyValue(VersionManager.PROPNAME_VERSION_HISTORY, InternalValue.create(UUID.fromString(fn.getVersionHistoryId())));
                 } else {
                     // not found, throw
                     throw new NoSuchItemStateException(id.toString());
@@ -358,23 +359,6 @@
         for (int i=0; i<nodes.length; i++) {
             state.addChildNodeEntry(nodes[i].getName(), nodes[i].getId());
         }
-        return state;
-    }
-
-    /**
-     * maps a frozen node
-     * @param state
-     * @param node
-     * @return
-     * @throws RepositoryException
-     */
-    private VirtualNodeState mapFrozenNode(VirtualNodeState state,
-                                           InternalFrozenVersionHistory node)
-            throws RepositoryException {
-
-        // map properties
-        state.setPropertyValue(VersionManager.PROPNAME_BASE_VERSION, InternalValue.create(node.getBaseVersionId()));
-        state.setPropertyValue(VersionManager.PROPNAME_VERSION_HISTORY, InternalValue.create(node.getVersionHistoryId()));
         return state;
     }
 

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java?view=diff&rev=122850&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java&r1=122849&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java&r2=122850
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
Mon Dec 20 06:11:31 2004
@@ -236,7 +236,7 @@
      * @return
      * @throws RepositoryException
      */
-    public synchronized Version checkin(NodeImpl node) throws RepositoryException {
+    public Version checkin(NodeImpl node) throws RepositoryException {
         InternalVersion version = vMgr.checkin(node);
         return (Version) node.getSession().getNodeByUUID(version.getId());
     }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalFrozenNodeImpl.java
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalFrozenNodeImpl.java?view=diff&rev=122850&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalFrozenNodeImpl.java&r1=122849&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalFrozenNodeImpl.java&r2=122850
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalFrozenNodeImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalFrozenNodeImpl.java
Mon Dec 20 06:11:31 2004
@@ -289,11 +289,11 @@
                     case OnParentVersionAction.VERSION:
                         if (child.isNodeType(NodeTypeRegistry.MIX_VERSIONABLE)) {
                             // create frozen versionable child
-                            PersistentNode newChild = node.addNode(child.getQName(), NodeTypeRegistry.NT_FROZEN_VERSIONABLE_CHILD);
+                            PersistentNode newChild = node.addNode(child.getQName(), NativePVM.NT_REP_FROZEN_HISTORY);
                             newChild.setPropertyValue(VersionManager.PROPNAME_VERSION_HISTORY,
-                                    InternalValue.create(UUID.fromString(child.getVersionHistory().getUUID())));
+                                    InternalValue.create(child.getVersionHistory().getUUID()));
                             newChild.setPropertyValue(VersionManager.PROPNAME_BASE_VERSION,
-                                    InternalValue.create(UUID.fromString(child.getBaseVersion().getUUID())));
+                                    InternalValue.create(child.getBaseVersion().getUUID()));
                             break;
                         }
                         // else copy

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java?view=diff&rev=122850&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java&r1=122849&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java&r2=122850
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java
Mon Dec 20 06:11:31 2004
@@ -49,6 +49,8 @@
  * <p>
  * on startup, the entire structure is traversed, in order to get a mapping
  * from real to persistent uuids.
+ * <p>
+ * todo: the persistence is not synchronized yet and could lead to multi-threading issues
  */
 public class NativePVM implements PersistentVersionManager {
 
@@ -108,6 +110,11 @@
     protected static final QName NT_REP_FROZEN = new QName(NamespaceRegistryImpl.NS_REP_URI,
"frozen");
 
     /**
+     * the nodetype name of a persistent frozen history
+     */
+    protected static final QName NT_REP_FROZEN_HISTORY = new QName(NamespaceRegistryImpl.NS_REP_URI,
"frozenVersionHistory");
+
+    /**
      * the persistent root node of the version histories
      */
     private final PersistentNode historyRoot;
@@ -212,8 +219,10 @@
             throws ItemStateException, RepositoryException {
         PersistentId id = new PersistentId(realUUID, state);
         if (id.type != PersistentId.TYPE_UNDEFINED) {
-            idsByExternal.put(id.externalId, id);
-            idsByInternal.put(id.internalId, id);
+            synchronized(idsByExternal) {
+                idsByExternal.put(id.externalId, id);
+                idsByInternal.put(id.internalId, id);
+            }
             if (id.type == PersistentId.TYPE_HISTORY) {
                 histories.add(id.externalId);
             }
@@ -227,7 +236,9 @@
      * @return
      */
     private PersistentId getIdByExternal(String uuid) {
-        return (PersistentId) idsByExternal.get(uuid);
+        synchronized(idsByExternal) {
+            return (PersistentId) idsByExternal.get(uuid);
+        }
     }
 
     /**
@@ -246,8 +257,10 @@
      * @return
      */
     private PersistentId getIdByExternal(String uuid, int type) {
-        PersistentId id = (PersistentId) idsByExternal.get(uuid);
-        return id != null && id.type == type ? id : null;
+        synchronized(idsByExternal) {
+            PersistentId id = (PersistentId) idsByExternal.get(uuid);
+            return id != null && id.type == type ? id : null;
+        }
     }
 
     /**
@@ -257,7 +270,7 @@
      * @return the newly created version history.
      * @throws RepositoryException
      */
-    public synchronized InternalVersionHistory createVersionHistory(NodeImpl node)
+    public InternalVersionHistory createVersionHistory(NodeImpl node)
             throws RepositoryException {
 
         // create deep path
@@ -292,7 +305,7 @@
      * @return
      * @throws RepositoryException
      */
-    public synchronized InternalVersionHistory getVersionHistory(String histId)
+    public InternalVersionHistory getVersionHistory(String histId)
             throws RepositoryException {
 
         PersistentId pid = getIdByExternal(histId, PersistentId.TYPE_HISTORY);
@@ -305,7 +318,7 @@
      * @param histId
      * @return
      */
-    public synchronized boolean hasVersionHistory(String histId) {
+    public boolean hasVersionHistory(String histId) {
         return getIdByExternal(histId, PersistentId.TYPE_HISTORY) != null;
     }
 
@@ -315,7 +328,7 @@
      * @return
      * @throws RepositoryException
      */
-    public synchronized Iterator getVersionHistoryIds() throws RepositoryException {
+    public Iterator getVersionHistoryIds() throws RepositoryException {
         return histories.iterator();
     }
 
@@ -325,7 +338,7 @@
      * @return
      * @throws RepositoryException
      */
-    public synchronized int getNumVersionHistories() throws RepositoryException {
+    public int getNumVersionHistories() throws RepositoryException {
         return histories.size();
     }
 
@@ -336,7 +349,7 @@
      * @return
      * @throws RepositoryException
      */
-    public synchronized InternalVersion getVersion(String histId, String versionId)
+    public InternalVersion getVersion(String histId, String versionId)
             throws RepositoryException {
         InternalVersionHistory history = getVersionHistory(histId);
         return history.getVersion(versionId);
@@ -349,7 +362,7 @@
      * @return
      * @throws RepositoryException
      */
-    public synchronized InternalVersion getVersion(String versionId)
+    public InternalVersion getVersion(String versionId)
             throws RepositoryException {
 
         PersistentId pid = getIdByExternal(versionId, PersistentId.TYPE_VERSION);
@@ -362,7 +375,7 @@
      * @param versionId
      * @return
      */
-    public synchronized boolean hasVersion(String versionId) {
+    public boolean hasVersion(String versionId) {
         return getIdByExternal(versionId, PersistentId.TYPE_VERSION) != null;
     }
 
@@ -371,7 +384,7 @@
      * @param externalId
      * @return
      */
-    public synchronized boolean hasItem(String externalId) {
+    public boolean hasItem(String externalId) {
         return getIdByExternal(externalId) != null;
     }
 
@@ -381,7 +394,7 @@
      * @return
      * @throws RepositoryException
      */
-    public synchronized InternalVersionItem getItemByExternal(String externalId)
+    public InternalVersionItem getItemByExternal(String externalId)
             throws RepositoryException {
         PersistentId pid = getIdByExternal(externalId);
         return pid==null ? null : getItem(pid);
@@ -393,7 +406,7 @@
      * @return
      * @throws RepositoryException
      */
-    public synchronized InternalVersionItem getItemByInternal(String internalId)
+    public InternalVersionItem getItemByInternal(String internalId)
             throws RepositoryException {
         PersistentId pid = getIdByInternal(internalId);
         return pid==null ? null : getItem(pid);
@@ -405,7 +418,7 @@
      * @return
      * @throws RepositoryException
      */
-    synchronized private InternalVersionItem getItem(PersistentId pid)
+    private InternalVersionItem getItem(PersistentId pid)
             throws RepositoryException {
 
         InternalVersionItem item =(InternalVersionItem) items.get(pid);
@@ -440,7 +453,7 @@
      * @throws RepositoryException
      * @see javax.jcr.Node#checkin()
      */
-    public synchronized InternalVersion checkin(NodeImpl node) throws RepositoryException
{
+    public InternalVersion checkin(NodeImpl node) throws RepositoryException {
         // assuming node is versionable and checkout (check in nodeimpl)
         // To create a new version of a versionable node N, the client calls N.checkin.
         // This causes the following series of events:
@@ -501,7 +514,7 @@
         private static final int TYPE_HISTORY = 1;
         private static final int TYPE_VERSION = 2;
         private static final int TYPE_FROZEN = 3;
-        private static final int TYPE_FROZEN_HISTORY = 3;
+        private static final int TYPE_FROZEN_HISTORY = 4;
 
         /** the type of the persistent node */
         private final int type;
@@ -530,7 +543,7 @@
                 // ignore given externalid, and generate new one
                 this.externalId = UUID.randomUUID().toString();
                 type = TYPE_FROZEN;
-            } else if (state.getNodeTypeName().equals(NodeTypeRegistry.NT_FROZEN_VERSIONABLE_CHILD))
{
+            } else if (state.getNodeTypeName().equals(NT_REP_FROZEN_HISTORY)) {
                 // ignore given externalid, and generate new one
                 this.externalId = UUID.randomUUID().toString();
                 type = TYPE_FROZEN_HISTORY;

Mime
View raw message