[jbosscache-commits] JBoss Cache SVN: r6260 - in core/trunk/src: test/java/org/jboss/cache/mgmt and 1 other directory.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Jul 15 05:14:05 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-07-15 05:14:04 -0400 (Tue, 15 Jul 2008)
New Revision: 6260

Modified:
   core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
   core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtTestBase.java
Log:
Suppress cache loading when not needed

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java	2008-07-15 08:54:23 UTC (rev 6259)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java	2008-07-15 09:14:04 UTC (rev 6260)
@@ -92,7 +92,7 @@
    {
       if (command.getFqn() != null)
       {
-         loadIfNeeded(ctx, command.getFqn(), null, false, true, false, false, false, false);
+         loadIfNeeded(ctx, command.getFqn(), null, false, true, false, false, false, false, false);
       }
       return invokeNextInterceptor(ctx, command);
    }
@@ -102,7 +102,7 @@
    {
       if (command.getFqn() != null)
       {
-         loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, useCacheStore, !useCacheStore, false, false, false);
+         loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, useCacheStore, !useCacheStore, false, false, false, true);
       }
       return invokeNextInterceptor(ctx, command);
    }
@@ -120,9 +120,9 @@
       {
          if (command.getTo() != null)
          {
-            loadIfNeeded(ctx, command.getTo(), null, false, false, true, false, true, false);
+            loadIfNeeded(ctx, command.getTo(), null, false, false, true, false, true, false, true);
          }
-         loadIfNeeded(ctx, command.getFqn(), null, false, false, true, true, true, false);
+         loadIfNeeded(ctx, command.getFqn(), null, false, false, true, true, true, false, true);
       }
       return invokeNextInterceptor(ctx, command);
    }
@@ -132,7 +132,7 @@
    {
       if (command.getFqn() != null)
       {
-         loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, false, true, false, false, false);
+         loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, false, true, false, false, false, true);
       }
       return invokeNextInterceptor(ctx, command);
    }
@@ -143,7 +143,7 @@
    {
       if (command.getFqn() != null)
       {
-         loadIfNeeded(ctx, command.getFqn(), null, false, false, true, false, false, true);
+         loadIfNeeded(ctx, command.getFqn(), null, false, false, true, false, false, true, true);
       }
       return invokeNextInterceptor(ctx, command);
    }
@@ -154,7 +154,7 @@
       Fqn fqn = command.getFqn();
       if (fqn != null)
       {
-         loadIfNeeded(ctx, fqn, null, false, false, false, false, false, true);
+         loadIfNeeded(ctx, fqn, null, false, false, false, false, false, true, true);
          NodeSPI n = dataContainer.peek(fqn, true, true);
          loadChildren(fqn, n, false, false, ctx);
       }
@@ -167,7 +167,7 @@
    {
       if (command.getFqn() != null)
       {
-         loadIfNeeded(ctx, command.getFqn(), null, true, false, true, false, false, false);
+         loadIfNeeded(ctx, command.getFqn(), null, true, false, true, false, false, false, true);
       }
       return invokeNextInterceptor(ctx, command);
    }
@@ -177,7 +177,7 @@
    {
       if (command.getFqn() != null)
       {
-         loadIfNeeded(ctx, command.getFqn(), null, true, false, true, false, false, false);
+         loadIfNeeded(ctx, command.getFqn(), null, true, false, true, false, false, false, true);
       }
       return invokeNextInterceptor(ctx, command);
    }
@@ -214,7 +214,7 @@
    {
       if (configuration.getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC && command.getFqn() != null)
       {
-         loadIfNeeded(ctx, command.getFqn(), null, false, false, false, false, false, false);
+         loadIfNeeded(ctx, command.getFqn(), null, false, false, false, false, false, false, false);
       }
       return invokeNextInterceptor(ctx, command);
    }
@@ -224,7 +224,7 @@
    {
       if (command.getFqn() != null && !useCacheStore)
       {
-         loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, false, false, false, false, false);
+         loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, false, false, false, false, false, true);
       }
       return invokeNextInterceptor(ctx, command);
    }
@@ -235,12 +235,12 @@
       Fqn fqn = command.getFqn();
       if (fqn != null && !useCacheStore)
       {
-         loadIfNeeded(ctx, fqn, null, false, true, false, false, false, false);
+         loadIfNeeded(ctx, fqn, null, false, true, false, false, false, false, true);
       }
       return invokeNextInterceptor(ctx, command);
    }
 
-   private void loadIfNeeded(InvocationContext ctx, Fqn fqn, Object key, boolean allKeys, boolean initNode, boolean acquireWriteLock, boolean recursive, boolean isMove, boolean bypassLoadingData) throws Throwable
+   private void loadIfNeeded(InvocationContext ctx, Fqn fqn, Object key, boolean allKeys, boolean initNode, boolean acquireWriteLock, boolean recursive, boolean isMove, boolean bypassLoadingData, boolean shouldLoadIfNodeIsNull) throws Throwable
    {
       NodeSPI n = helper.wrapNodeForReading(ctx, fqn);
       if (n instanceof NullMarkerNode)
@@ -248,7 +248,7 @@
          ctx.getLookedUpNodes().remove(fqn);
          n = null;
       }
-      boolean mustLoad = mustLoad(n, key, allKeys || isMove);
+      boolean mustLoad = mustLoad(n, key, allKeys || isMove, shouldLoadIfNodeIsNull);
 
       if (trace) log.trace("load element " + fqn + " mustLoad=" + mustLoad);
 
@@ -355,12 +355,12 @@
       node.setChildrenLoaded(true);
    }
 
-   private boolean mustLoad(NodeSPI n, Object key, boolean allKeys)
+   private boolean mustLoad(NodeSPI n, Object key, boolean allKeys, boolean shouldLoadIfNodeIsNull)
    {
       if (n == null)
       {
-         if (trace) log.trace("must load, node null");
-         return true;
+         if (trace) log.trace("Node null.  Must load? " + shouldLoadIfNodeIsNull);
+         return shouldLoadIfNodeIsNull;
       }
 
       // check this first!!!

Modified: core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtTestBase.java	2008-07-15 08:54:23 UTC (rev 6259)
+++ core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtTestBase.java	2008-07-15 09:14:04 UTC (rev 6260)
@@ -6,15 +6,13 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.config.CacheLoaderConfig;
 import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.parsing.XmlConfigurationParser;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import static org.jboss.cache.factories.UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig;
 import org.jboss.cache.loader.CacheLoader;
 import org.jboss.cache.loader.DummyInMemoryCacheLoader;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
-import org.w3c.dom.Element;
-import static org.jboss.cache.factories.UnitTestCacheConfigurationFactory.*;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -94,8 +92,9 @@
 
    private CacheSPI<String, Object> createCache() throws Exception
    {
-      CacheFactory<String, Object> instance = new DefaultCacheFactory();
+      CacheFactory<String, Object> instance = new DefaultCacheFactory<String, Object>();
       Configuration c = new Configuration();
+      c.setNodeLockingScheme(NodeLockingScheme.MVCC);
       c.setCacheMode(Configuration.CacheMode.LOCAL);
       c.setCacheLoaderConfig(getCacheLoaderConfig());
       c.setExposeManagementStatistics(true);




More information about the jbosscache-commits mailing list