jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r704933 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src: main/java/org/apache/jackrabbit/jcr2spi/ main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ test/java/org/apache/jackrabbit/jcr2spi/lock/
Date Wed, 15 Oct 2008 14:53:49 GMT
Author: angela
Date: Wed Oct 15 07:53:48 2008
New Revision: 704933

URL: http://svn.apache.org/viewvc?rev=704933&view=rev
Log:
JCR-1798: Avoid individual Item reloading upon Session/Item.refresh(true)
JCR-1809: Avoid extra round trip to the SPI upon Node.getNode and Session.getItem

Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/SessionScopedLockTest.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java?rev=704933&r1=704932&r2=704933&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
Wed Oct 15 07:53:48 2008
@@ -251,7 +251,7 @@
                 // from the 'server'.
                 // Note, that with Observation-CacheBehaviour no manuel refresh
                 // is required. changes get pushed automatically.
-                state.getHierarchyEntry().reload(true, true);
+                state.getHierarchyEntry().invalidate(true);
             }
         } else {
             // check status of item state
@@ -413,7 +413,7 @@
         // check status of this item for read operation
         if (state.getStatus() == Status.INVALIDATED) {
             // refresh to get current status from persistent storage
-            state.getHierarchyEntry().reload(false, false);
+            state.getHierarchyEntry().reload(false);
         }
         // now check if valid
         if (!state.isValid()) {

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java?rev=704933&r1=704932&r2=704933&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
Wed Oct 15 07:53:48 2008
@@ -743,6 +743,12 @@
             itemState = ((NodeImpl) version).getItemState();
         } else {
             Path p = getQPath(version.getPath());
+            Path parentPath = p.getAncestor(1);
+            HierarchyEntry parentEntry = getHierarchyManager().lookup(parentPath);
+            if (parentEntry != null) {
+                // make sure the parent entry is up to date
+                parentEntry.invalidate(false);
+            }
             itemState = getHierarchyManager().getItemState(p);
         }
         return (NodeState) itemState;

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java?rev=704933&r1=704932&r2=704933&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java
Wed Oct 15 07:53:48 2008
@@ -147,7 +147,7 @@
      * resulting in inconsistent entries.
      *
      * @param childNodeInfos
-     * @see HierarchyEntry#reload(boolean, boolean) that ignores items with
+     * @see HierarchyEntry#reload(boolean) that ignores items with
      * pending changes.
      * @see org.apache.jackrabbit.jcr2spi.operation.AddNode
      * @see org.apache.jackrabbit.jcr2spi.operation.Move
@@ -165,7 +165,14 @@
                 ln = internalAddAfter(entry, ci.getIndex(), prevLN);
             } else if (prevLN != null) {
                 // assert correct order of existing
-                reorderAfter(ln, prevLN);
+                if (prevLN != ln) {
+                    reorderAfter(ln, prevLN);
+                } else {
+                    // there was an existing entry but it's the same as the one
+                    // created/retrieved before. getting here indicates that
+                    // the SPI implementation provided invalid childNodeInfos.
+                    log.error("ChildInfo iterator contains multiple entries with the same
name|index or uniqueID -> ignore ChildNodeInfo.");
+                }
             }
             prevLN = ln;
         }
@@ -446,7 +453,7 @@
                 entriesByName.reorder(insertName, insertLN, position);
             }
             // reorder in linked list
-            entries.reorderNode(insertLN, afterLN.getNextLinkNode());
+            entries.reorderNode(insertLN, currentAfter);
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java?rev=704933&r1=704932&r2=704933&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java
Wed Oct 15 07:53:48 2008
@@ -110,10 +110,11 @@
     public void setItemState(ItemState state);
 
     /**
-     * Invalidates the underlying <code>ItemState</code> if available. If the
-     * <code>recursive</code> flag is true, the hierarchy is traverses and
-     * {@link #invalidate(boolean)} is called on all child entries.<br>
-     * Note, that in contrast to {@link HierarchyEntry#reload(boolean, boolean)}
+     * Invalidates the underlying <code>ItemState</code> if available and if
it
+     * is not transiently modified. If the <code>recursive</code> flag is true,
+     * the hierarchy is traverses and {@link #invalidate(boolean)} is called on
+     * all child entries.<br>
+     * Note, that in contrast to {@link HierarchyEntry#reload(boolean)}
      * this method only sets the status of this item state to {@link
      * Status#INVALIDATED} and does not acutally update it with the persistent
      * state in the repository.
@@ -131,15 +132,12 @@
 
     /**
      * Reloads this hierarchy entry and the corresponding ItemState, if this
-     * entry has already been resolved. If '<code>keepChanges</code>' is true,
-     * states with transient changes are left untouched in order to detect stale
-     * item states. Otherwise this state gets its data reloaded from the
-     * persistent storage. If '<code>recursive</code>' the complete hierarchy
-     * below this entry is reloaded as well.
+     * entry has already been resolved. If '<code>recursive</code>' the complete
+     * hierarchy below this entry is reloaded as well.
      *
-     * @param keepChanges
+     * @param recursive
      */
-    public void reload(boolean keepChanges, boolean recursive);
+    public void reload(boolean recursive);
 
     /**
      * Traverses the hierarchy and marks all available item states as transiently

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java?rev=704933&r1=704932&r2=704933&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java
Wed Oct 15 07:53:48 2008
@@ -104,7 +104,7 @@
             }
         } else if (state.getStatus() == Status.INVALIDATED) {
             // completely reload this entry, but don't reload recursively
-            reload(false, false);
+            reload(false);
         }
         return state;
     }
@@ -235,9 +235,11 @@
      * @see HierarchyEntry#invalidate(boolean)
      */
     public void invalidate(boolean recursive) {
-        ItemState state = internalGetItemState();
-        if (state != null) {
+        if (getStatus() == Status.EXISTING) {
+            ItemState state = internalGetItemState();
             state.setStatus(Status.INVALIDATED);
+        } else {
+            log.debug("Skip invalidation for HierarchyEntry " + name + " with status " +
Status.getName(getStatus()));
         }
     }
 
@@ -287,9 +289,9 @@
 
     /**
      * {@inheritDoc}
-     * @see HierarchyEntry#reload(boolean, boolean)
+     * @see HierarchyEntry#reload(boolean)
      */
-    public void reload(boolean keepChanges, boolean recursive) {
+    public void reload(boolean recursive) {
         int status = getStatus();
         if (status == Status._UNDEFINED_) {
             // unresolved: entry will be loaded and validated upon resolution.
@@ -337,7 +339,7 @@
         // if during recursive removal an invalidated entry is found, reload
         // it in order to determine the current status.
         if (state.getStatus() == Status.INVALIDATED) {
-            reload(false, false);
+            reload(false);
         }
 
         switch (state.getStatus()) {

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java?rev=704933&r1=704932&r2=704933&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
Wed Oct 15 07:53:48 2008
@@ -190,11 +190,11 @@
      * traversed and reloaded. Otherwise only this entry and the direct
      * decendants are reloaded.
      *
-     * @see HierarchyEntry#reload(boolean, boolean)
+     * @see HierarchyEntry#reload(boolean)
      */
-    public void reload(boolean keepChanges, boolean recursive) {
+    public void reload(boolean recursive) {
         // reload this entry
-        super.reload(keepChanges, recursive);
+        super.reload(recursive);
 
         // reload all children unless 'recursive' is false and the reload above
         // did not cause this entry to be removed -> therefore check status.
@@ -202,7 +202,7 @@
             // recursivly reload all entries including props that are in the attic.
             for (Iterator it = getAllChildEntries(true); it.hasNext();) {
                 HierarchyEntry ce = (HierarchyEntry) it.next();
-                ce.reload(keepChanges, recursive);
+                ce.reload(recursive);
             }
         }
     }
@@ -394,6 +394,12 @@
                 return entry.properties.get(name);
             } else {
                 // no valid entry
+                // -> if cnes are complete -> assume that it doesn't exist.
+                //    refresh will bring up new entries added in the mean time
+                //    on the persistent layer.
+                if (entry.childNodeEntries.isComplete()) {
+                    throw new PathNotFoundException(path.toString());
+                }
                 // -> check for moved child entry in node-attic
                 // -> check if child points to a removed/moved sns
                 List siblings = entry.childNodeEntries.get(name);
@@ -532,7 +538,7 @@
 
         if (cne == null && loadIfNotFound
                 && !containsAtticChild(entries, nodeName, index)
-                && Status.NEW != getStatus()) {
+                && !childNodeEntries.isComplete()) {
             PathFactory pf = factory.getPathFactory();
             NodeId cId = factory.getIdFactory().createNodeId(getWorkspaceId(), pf.create(nodeName,
index));
             cne = loadNodeEntry(cId);

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java?rev=704933&r1=704932&r2=704933&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java
Wed Oct 15 07:53:48 2008
@@ -45,6 +45,10 @@
         testRoot2.save();
 
         Lock lock2 = lockedNode2.lock(false, isSessionScoped());
+
+        // force reloading of the testroot in order to be aware of the
+        // locked noded added by another session
+        testRootNode.refresh(false);
         Node n2 = (Node) superuser.getItem(lockedNode2.getPath());
         try {
             String lockToken = lock2.getLockToken();

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/SessionScopedLockTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/SessionScopedLockTest.java?rev=704933&r1=704932&r2=704933&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/SessionScopedLockTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/SessionScopedLockTest.java
Wed Oct 15 07:53:48 2008
@@ -61,6 +61,9 @@
         lockedNode2.addMixin(mixLockable);
         testRoot2.save();
 
+        // force reloading of the testroot in order to be aware of the
+        // locked noded added by another session
+        testRootNode.refresh(false);
         Node n2 = (Node) superuser.getItem(lockedNode2.getPath());
 
         // remove lock implicit by logout lock-holding session



Mime
View raw message