jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpfis...@apache.org
Subject svn commit: r475276 - /jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java
Date Wed, 15 Nov 2006 15:55:48 GMT
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);
+                }
+            }
         }
     }
 



Mime
View raw message