You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by dp...@apache.org on 2006/11/15 16:55:48 UTC

svn commit: r475276 - /jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java

Author: dpfister
Date: Wed Nov 15 07:55:47 2006
New Revision: 475276

URL: http://svn.apache.org/viewvc?view=rev&rev=475276
Log:
Optimization: ignore notifications for states that are not in the cache
   (which btw caused a lot of warnings in the logs, too)

Modified:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java?view=diff&rev=475276&r1=475275&r2=475276
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java (original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java Wed Nov 15 07:55:47 2006
@@ -350,18 +350,23 @@
      * {@inheritDoc}
      */
     public void nodeAdded(NodeState state, QName name, int index, NodeId id) {
-        try {
-            Path path = Path.create(getPath(state.getNodeId()), name, index, true);
-            insert(path, id);
-        } catch (PathNotFoundException e) {
-            log.warn("Unable to get path of node " + state.getNodeId()
-                    + ", event ignored.");
-        } catch (MalformedPathException e) {
-            log.warn("Unable to create path of " + id, e);
-        } catch (ItemNotFoundException e) {
-            log.warn("Unable to get path of " + state.getNodeId(), e);
-        } catch (RepositoryException e) {
-            log.warn("Unable to get path of " + state.getNodeId(), e);
+        // Optimization: ignore notifications for nodes that are not in the cache
+        synchronized (cacheMonitor) {
+            if (idCache.containsKey(state.getNodeId())) {
+                try {
+                    Path path = Path.create(getPath(state.getNodeId()), name, index, true);
+                    insert(path, id);
+                } catch (PathNotFoundException e) {
+                    log.warn("Unable to get path of node " + state.getNodeId()
+                            + ", event ignored.");
+                } catch (MalformedPathException e) {
+                    log.warn("Unable to create path of " + id, e);
+                } catch (ItemNotFoundException e) {
+                    log.warn("Unable to find item " + state.getNodeId(), e);
+                } catch (RepositoryException e) {
+                    log.warn("Unable to get path of " + state.getNodeId(), e);
+                }
+            }
         }
     }
 
@@ -396,18 +401,23 @@
      * {@inheritDoc}
      */
     public void nodeRemoved(NodeState state, QName name, int index, NodeId id) {
-        try {
-            Path path = Path.create(getPath(state.getNodeId()), name, index, true);
-            remove(path, id);
-        } catch (PathNotFoundException e) {
-            log.warn("Unable to get path of node " + state.getNodeId()
-                    + ", event ignored.");
-        } catch (MalformedPathException e) {
-            log.warn("Unable to create path of " + id, e);
-        } catch (ItemNotFoundException e) {
-            log.warn("Unable to get path of " + state.getNodeId(), e);
-        } catch (RepositoryException e) {
-            log.warn("Unable to get path of " + state.getNodeId(), e);
+        // Optimization: ignore notifications for nodes that are not in the cache
+        synchronized (cacheMonitor) {
+            if (idCache.containsKey(state.getNodeId())) {
+                try {
+                    Path path = Path.create(getPath(state.getNodeId()), name, index, true);
+                    remove(path, id);
+                } catch (PathNotFoundException e) {
+                    log.warn("Unable to get path of node " + state.getNodeId()
+                            + ", event ignored.");
+                } catch (MalformedPathException e) {
+                    log.warn("Unable to create path of " + id, e);
+                } catch (ItemNotFoundException e) {
+                    log.warn("Unable to get path of " + state.getNodeId(), e);
+                } catch (RepositoryException e) {
+                    log.warn("Unable to get path of " + state.getNodeId(), e);
+                }
+            }
         }
     }