[jbosscache-commits] JBoss Cache SVN: r7196 - in core/trunk/src/main/java/org/jboss/cache: mvcc and 1 other directory.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Nov 25 07:21:15 EST 2008


Author: manik.surtani at jboss.com
Date: 2008-11-25 07:21:15 -0500 (Tue, 25 Nov 2008)
New Revision: 7196

Modified:
   core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyCacheLoaderInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java
Log:
Improvements in logging
By default all new nodes do not have their data loaded flags set

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java	2008-11-25 11:48:32 UTC (rev 7195)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java	2008-11-25 12:21:15 UTC (rev 7196)
@@ -270,7 +270,7 @@
          ctx.getLookedUpNodes().remove(fqn);
          n = null;
       }
-      boolean mustLoad = mustLoad(n, key, allKeys || isMove, shouldLoadIfNodeIsNull);
+      boolean mustLoad = mustLoad(fqn, n, key, allKeys || isMove, shouldLoadIfNodeIsNull);
 
       if (trace) log.trace("load element " + fqn + " mustLoad=" + mustLoad);
 
@@ -392,11 +392,11 @@
       node.setChildrenLoaded(true);
    }
 
-   private boolean mustLoad(NodeSPI n, Object key, boolean allKeys, boolean shouldLoadIfNodeIsNull)
+   private boolean mustLoad(Fqn fqn, NodeSPI n, Object key, boolean allKeys, boolean shouldLoadIfNodeIsNull)
    {
       if (n == null)
       {
-         if (trace) log.trace("Node null.  Must load? " + shouldLoadIfNodeIsNull);
+         if (trace) log.trace("Node [" + fqn + "] is null in memory.  Must load? " + shouldLoadIfNodeIsNull);
          return shouldLoadIfNodeIsNull;
       }
 
@@ -404,7 +404,10 @@
       if (!n.isValid()) // && configuration.getNodeLockingScheme().isVersionedScheme())
       {
          // attempt to load again; this only happens if we have tombstones lying around, or we are using invalidation.
-         if (trace) log.trace("loading again from cache loader since in-memory node is marked as invalid");
+         if (trace)
+         {
+            log.trace("Loading node [" + fqn + "] again from cache loader since in-memory node is marked as invalid");
+         }
          return true;
       }
 
@@ -414,20 +417,22 @@
          // if we are not looking for a specific key don't bother loading!
          if (key == null)
          {
-            if (trace) log.trace("don't load, key requested is null");
+            if (trace) log.trace("Don't load [" + fqn + "], key requested is null");
             return false;
          }
          if (n.getKeysDirect().contains(key))
          {
-            if (trace) log.trace("don't load, already have necessary key in memory");
+            if (trace) log.trace("Don't load [" + fqn + "], already have necessary key in memory");
             return false;
          }
       }
       if (!n.isDataLoaded())
       {
-         if (trace) log.trace("must load, uninitialized");
+         if (trace) log.trace("Must load node [" + fqn + "], uninitialized");
          return true;
       }
+
+      if (trace) log.trace("Don't load node [" + fqn + "], by default");
       return false;
    }
 
@@ -468,10 +473,10 @@
 
    private Map loadData(InvocationContext ctx, Fqn fqn) throws Exception
    {
-
+      if (trace) log.trace("Attempting to load data for " + fqn);
       Map nodeData = loader.get(fqn);
       boolean nodeExists = (nodeData != null);
-      if (trace) log.trace("nodeExists " + nodeExists);
+      if (trace) log.trace("Node " + fqn + " exists? " + nodeExists);
       if (nodeExists) recordNodeLoaded(ctx, fqn);
       if (getStatisticsEnabled())
       {

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyCacheLoaderInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyCacheLoaderInterceptor.java	2008-11-25 11:48:32 UTC (rev 7195)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyCacheLoaderInterceptor.java	2008-11-25 12:21:15 UTC (rev 7196)
@@ -279,7 +279,7 @@
          {
             throw new TimeoutException("Unable to acquire lock on " + fqn + ". Lock info: " + lockManager.printLockInfo(n));
          }
-         mustLoad = mustLoad(n, key, allKeys || isMove);
+         mustLoad = mustLoad(fqn, n, key, allKeys || isMove);
       }
       finally
       {
@@ -413,11 +413,11 @@
       node.setChildrenLoaded(true);
    }
 
-   private boolean mustLoad(NodeSPI n, Object key, boolean allKeys)
+   private boolean mustLoad(Fqn fqn, NodeSPI n, Object key, boolean allKeys)
    {
       if (n == null)
       {
-         if (trace) log.trace("must load, node null");
+         if (trace) log.trace("Node [" + fqn + "] is null in memory.  Must load? true");
          return true;
       }
 
@@ -425,7 +425,10 @@
       if (!n.isValid() && configuration.getNodeLockingScheme().isVersionedScheme())
       {
          // attempt to load again; this only happens if we have tombstones lying around, or we are using invalidation.
-         if (trace) log.trace("loading again from cache loader since in-memory node is marked as invalid");
+         if (trace)
+         {
+            log.trace("Loading node [" + fqn + "] again from cache loader since in-memory node is marked as invalid");
+         }
          return true;
       }
 
@@ -435,20 +438,22 @@
          // if we are not looking for a specific key don't bother loading!
          if (key == null)
          {
-            if (trace) log.trace("don't load, key requested is null");
+            if (trace) log.trace("Don't load [" + fqn + "], key requested is null");
             return false;
          }
          if (n.getKeysDirect().contains(key))
          {
-            if (trace) log.trace("don't load, already have necessary key in memory");
+            if (trace) log.trace("Don't load [" + fqn + "], already have necessary key in memory");
             return false;
          }
       }
       if (!n.isDataLoaded())
       {
-         if (trace) log.trace("must Load, uninitialized");
+         if (trace) log.trace("Must load node [" + fqn + "], uninitialized");
          return true;
       }
+
+      if (trace) log.trace("Don't load node [" + fqn + "], by default");
       return false;
    }
 
@@ -563,10 +568,10 @@
 
    private Map loadData(InvocationContext ctx, Fqn fqn) throws Exception
    {
-
+      if (trace) log.trace("Attempting to load data for " + fqn);
       Map nodeData = loader.get(fqn);
       boolean nodeExists = (nodeData != null);
-      if (trace) log.trace("nodeExists " + nodeExists);
+      if (trace) log.trace("Node " + fqn + " exists? " + nodeExists);
       if (nodeExists) recordNodeLoaded(ctx, fqn);
       if (getStatisticsEnabled())
       {

Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java	2008-11-25 11:48:32 UTC (rev 7195)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java	2008-11-25 12:21:15 UTC (rev 7196)
@@ -101,6 +101,10 @@
    public InternalNode<K, V> createInternalNode(Fqn fqn)
    {
       UnversionedNode<K, V> un = new UnversionedNode<K, V>(fqn, cache, lockChildForInsertRemove);
+
+      // always assume that new nodes don't have their data loaded, unless root.
+      if (!fqn.isRoot()) un.setDataLoaded(false);
+
       return useRepeatableRead ? un : new NodeReference<K, V>(un);
    }
 




More information about the jbosscache-commits mailing list