[jboss-cvs] JBossAS SVN: r76715 - in projects/cluster/hibernate-jbc-cacheprovider/trunk/src: test/java/org/jboss/hibernate/jbc/cacheprovider/functional and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Aug 6 11:28:57 EDT 2008


Author: galder.zamarreno at jboss.com
Date: 2008-08-06 11:28:57 -0400 (Wed, 06 Aug 2008)
New Revision: 76715

Added:
   projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/CacheProperties.java
Modified:
   projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/JBCCache.java
   projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/OptimisticJBCCache.java
   projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/OptimisticTreeCacheProviderHook.java
   projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/SecondLevelCacheUtil.java
   projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/TreeCacheProviderHook.java
   projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/CacheTestCaseBase.java
   projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/DualNodeTestCaseBase.java
   projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/PessimisticEntityReplicationTest.java
   projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/optimistic-treecache.xml
   projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/pessimistic-treecache.xml
   projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/util/TestCacheInstanceManager.java
Log:
[JBCLUSTER-206] Local puts only implemented. Changed configurations to READ_COMMITTED. Pessimistic entity replication test still needs work as with default local puts only fails.

Added: projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/CacheProperties.java
===================================================================
--- projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/CacheProperties.java	                        (rev 0)
+++ projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/CacheProperties.java	2008-08-06 15:28:57 UTC (rev 76715)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.hibernate.jbc.cacheprovider;
+
+import java.util.Properties;
+
+/**
+ * CacheProperties.
+ * 
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+public class CacheProperties
+{
+   /**
+    * Name of the Hibernate configuration property used to provide
+    * the ObjectName of the JBoss Cache instance.
+    */
+   public static final String HIBERNATE_CACHE_OBJECT_NAME_PROPERTY = "hibernate.treecache.mbean.object_name";
+   
+   /**
+    * Default ObjectName for the JBoss Cache instance that will be used
+    * if {@link HIBERNATE_CACHE_OBJECT_NAME_PROPERTY} is not provided.
+    */
+   public static final String DEFAULT_CACHE_OBJECT_NAME = "jboss.cache:service=TreeCache";
+   
+   public static final String HIBERNATE_CACHE_REGION_PREFIX_PROPERTY = "hibernate.cache.region_prefix";
+   
+   public static final String HIBERNATE_CACHE_QUERYCACHE_LOCAL_WRITES_ONLY_PROPERTY = "hibernate.treecache.querycache.local.writes.only";
+   
+   public static final String DEFAULT_QUERYCACHE_LOCAL_WRITES_ONLY = "true";
+   
+   public static final String HIBERNATE_CACHE_LOCAL_PUTS_ONLY_PROPERTY = "hibernate.treecache.local.puts.only";
+   
+   public static final String DEFAULT_LOCAL_PUTS_ONLY = "true";
+   
+   private final String cacheObjectName;
+   
+   private final String cacheRegionPrefix;
+
+   private final boolean queryCacheLocalWritesOnly;
+   
+   private final boolean localPutsOnly;
+   
+   public CacheProperties(Properties properties)
+   {
+      String name = properties.getProperty(HIBERNATE_CACHE_OBJECT_NAME_PROPERTY);
+      cacheObjectName = name != null ? name : DEFAULT_CACHE_OBJECT_NAME;
+      
+      cacheRegionPrefix = properties.getProperty(HIBERNATE_CACHE_REGION_PREFIX_PROPERTY);
+      
+      queryCacheLocalWritesOnly = new Boolean(properties.getProperty(
+            HIBERNATE_CACHE_QUERYCACHE_LOCAL_WRITES_ONLY_PROPERTY, 
+            DEFAULT_QUERYCACHE_LOCAL_WRITES_ONLY)).booleanValue();
+      
+      localPutsOnly = new Boolean(properties.getProperty(
+            HIBERNATE_CACHE_LOCAL_PUTS_ONLY_PROPERTY, 
+            DEFAULT_LOCAL_PUTS_ONLY)).booleanValue();
+   }
+
+   public String getCacheObjectName()
+   {
+      return cacheObjectName;
+   }
+
+   public String getCacheRegionPrefix()
+   {
+      return cacheRegionPrefix;
+   }
+
+   public boolean isQueryCacheLocalWritesOnly()
+   {
+      return queryCacheLocalWritesOnly;
+   }
+
+   public boolean isLocalPutsOnly()
+   {
+      return localPutsOnly;
+   }
+}

Modified: projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/JBCCache.java
===================================================================
--- projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/JBCCache.java	2008-08-06 14:28:41 UTC (rev 76714)
+++ projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/JBCCache.java	2008-08-06 15:28:57 UTC (rev 76715)
@@ -56,41 +56,45 @@
 	private final String regionName;
 	private final Fqn regionFqn;
 	private final TransactionManager transactionManager;
-    private boolean localWritesOnly;
-
+   private boolean queryCacheLocalWritesOnly;
+   
+   private final CacheProperties cacheProperties;
+	
 	public JBCCache(org.jboss.cache.TreeCache cache, String regionName, 
-                    String regionPrefix, TransactionManager transactionManager) 
-	throws CacheException {
+	      CacheProperties cacheProperties, TransactionManager transactionManager) 
+	      throws CacheException 
+   {
 		this.cache = cache;
 		this.regionName = regionName;
-        this.regionFqn = Fqn.fromString(SecondLevelCacheUtil.createRegionFqn(regionName, regionPrefix));
+		this.cacheProperties = cacheProperties;
+      this.regionFqn = Fqn.fromString(SecondLevelCacheUtil.createRegionFqn(regionName, this.cacheProperties.getCacheRegionPrefix()));
 		this.transactionManager = transactionManager;
-        if (cache.getUseRegionBasedMarshalling())
-        {           
-           localWritesOnly = StandardQueryCache.class.getName().equals(regionName);
+      if (cache.getUseRegionBasedMarshalling())
+      {           
+         queryCacheLocalWritesOnly = StandardQueryCache.class.getName().equals(regionName) && this.cacheProperties.isQueryCacheLocalWritesOnly();
            
-           boolean fetchState = cache.getFetchInMemoryState();
-           try
-           {
-              // We don't want a state transfer for the StandardQueryCache,
-              // as it can include classes from multiple scoped classloaders
-              if (localWritesOnly)
-                 cache.setFetchInMemoryState(false);
-              
-              // We always activate
-              activateCacheRegion(regionFqn.toString());
-           }
-           finally
-           {
-              // Restore the normal state transfer setting
-              if (localWritesOnly)
-                 cache.setFetchInMemoryState(fetchState);              
-           }
-        }
-        else
-        {
-           log.debug("TreeCache is not configured for region based marshalling");
-        }
+         boolean fetchState = cache.getFetchInMemoryState();
+         try
+         {
+            // We don't want a state transfer for the StandardQueryCache,
+            // as it can include classes from multiple scoped classloaders
+            if (queryCacheLocalWritesOnly)
+               cache.setFetchInMemoryState(false);
+            
+            // We always activate
+            activateCacheRegion(regionFqn.toString());
+         }
+         finally
+         {
+            // Restore the normal state transfer setting
+            if (queryCacheLocalWritesOnly)
+               cache.setFetchInMemoryState(fetchState);              
+         }
+      }
+      else
+      {
+         log.debug("TreeCache is not configured for region based marshalling");
+      }
 	}
 
 	public Object get(Object key) throws CacheException {
@@ -114,7 +118,7 @@
 
 	public void update(Object key, Object value) throws CacheException {
 		try {
-            if (localWritesOnly) {
+            if (queryCacheLocalWritesOnly) {
                Option option = new Option();
                option.setCacheModeLocal(true);
                cache.put( new Fqn( regionFqn, key ), ITEM, value, option );
@@ -131,7 +135,7 @@
 	public void put(Object key, Object value) throws CacheException {
 		Transaction tx = suspend();
 		try {
-           if (localWritesOnly) {
+           if (queryCacheLocalWritesOnly || cacheProperties.isLocalPutsOnly()) {
               Option option = new Option();
               option.setCacheModeLocal(true);
               // Overloaded method isn't available, so have to use InvocationContext
@@ -185,7 +189,7 @@
 
 	public void remove(Object key) throws CacheException {
 		try {
-           if (localWritesOnly) {
+           if (queryCacheLocalWritesOnly) {
               Option option = new Option();
               option.setCacheModeLocal(true);
               cache.remove( new Fqn( regionFqn, key ), option );

Modified: projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/OptimisticJBCCache.java
===================================================================
--- projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/OptimisticJBCCache.java	2008-08-06 14:28:41 UTC (rev 76714)
+++ projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/OptimisticJBCCache.java	2008-08-06 15:28:57 UTC (rev 76715)
@@ -58,40 +58,43 @@
 	private final String regionName;
 	private final Fqn regionFqn;
 	private OptimisticCacheSource source;
-    private boolean localWritesOnly;
+   private boolean queryCacheLocalWritesOnly;
+   
+   private final CacheProperties cacheProperties;
 
-	public OptimisticJBCCache(org.jboss.cache.TreeCache cache, 
-                              String regionName, String regionPrefix)
-	throws CacheException {
-		this.cache = cache;
+	public OptimisticJBCCache(org.jboss.cache.TreeCache cache, String regionName,
+	      CacheProperties cacheProperties) throws CacheException 
+	{
+	   this.cache = cache;
 		this.regionName = regionName;
-        this.regionFqn = Fqn.fromString(SecondLevelCacheUtil.createRegionFqn(regionName, regionPrefix));
-        if (cache.getUseRegionBasedMarshalling())
-        {           
-           localWritesOnly = StandardQueryCache.class.getName().equals(regionName);
+		this.cacheProperties = cacheProperties;
+      this.regionFqn = Fqn.fromString(SecondLevelCacheUtil.createRegionFqn(regionName, this.cacheProperties.getCacheRegionPrefix()));
+      if (cache.getUseRegionBasedMarshalling())
+      {           
+         queryCacheLocalWritesOnly = StandardQueryCache.class.getName().equals(regionName) && this.cacheProperties.isQueryCacheLocalWritesOnly();
            
-           boolean fetchState = cache.getFetchInMemoryState();
-           try
-           {
-              // We don't want a state transfer for the StandardQueryCache,
-              // as it can include classes from multiple scoped classloaders
-              if (localWritesOnly)
-                 cache.setFetchInMemoryState(false);
+         boolean fetchState = cache.getFetchInMemoryState();
+         try
+         {
+            // We don't want a state transfer for the StandardQueryCache,
+            // as it can include classes from multiple scoped classloaders
+            if (queryCacheLocalWritesOnly)
+               cache.setFetchInMemoryState(false);
               
-              // We always activate
-              activateCacheRegion(regionFqn.toString());
-           }
-           finally
-           {
-              // Restore the normal state transfer setting
-              if (localWritesOnly)
-                 cache.setFetchInMemoryState(fetchState);              
-           }
-        }
-        else
-        {
-           log.debug("TreeCache is not configured for region based marshalling");
-        }
+            // We always activate
+            activateCacheRegion(regionFqn.toString());
+         }
+         finally
+         {
+            // Restore the normal state transfer setting
+            if (queryCacheLocalWritesOnly)
+               cache.setFetchInMemoryState(fetchState);              
+         }
+      }
+      else
+      {
+         log.debug("TreeCache is not configured for region based marshalling");
+      }
 	}
 
 
@@ -112,7 +115,7 @@
 			                 ? new DataVersionAdapter( currentVersion, previousVersion, source.getVersionComparator(), source.toString() )
 			                 : NonLockingDataVersion.INSTANCE;
 			option.setDataVersion( dv );
-            option.setCacheModeLocal(localWritesOnly);
+         option.setCacheModeLocal(queryCacheLocalWritesOnly);
 			cache.put( new Fqn( regionFqn, key ), ITEM, value, option );
 		}
 		catch ( Exception e ) {
@@ -125,7 +128,7 @@
 			Option option = new Option();
 			option.setFailSilently( true );
 			option.setDataVersion( NonLockingDataVersion.INSTANCE );
-            option.setCacheModeLocal(localWritesOnly);
+         option.setCacheModeLocal(queryCacheLocalWritesOnly);
 			cache.remove( new Fqn( regionFqn, key ), "ITEM", option );
 
 			option = new Option();
@@ -134,7 +137,7 @@
 			                 ? new DataVersionAdapter( currentVersion, currentVersion, source.getVersionComparator(), source.toString() )
 			                 : NonLockingDataVersion.INSTANCE;
 			option.setDataVersion( dv );
-            option.setCacheModeLocal(localWritesOnly);
+         option.setCacheModeLocal(queryCacheLocalWritesOnly);
 			cache.put( new Fqn( regionFqn, key ), ITEM, value, option );
 		}
 		catch (Exception e) {
@@ -170,7 +173,7 @@
 		try {
 			Option option = new Option();
 			option.setDataVersion( NonLockingDataVersion.INSTANCE );
-            option.setCacheModeLocal(localWritesOnly);
+         option.setCacheModeLocal(queryCacheLocalWritesOnly);
 			cache.put( new Fqn( regionFqn, key ), ITEM, value, option );
 		}
 		catch (Exception e) {
@@ -185,7 +188,7 @@
 			Option option = new Option();
 			option.setFailSilently( true );
 			option.setDataVersion( NonLockingDataVersion.INSTANCE );
-            option.setCacheModeLocal(localWritesOnly);
+         option.setCacheModeLocal(queryCacheLocalWritesOnly);
 			cache.put( new Fqn( regionFqn, key ), ITEM, value, option );
 		}
 		catch (TimeoutException te) {
@@ -204,7 +207,7 @@
 			if ( cache.get( new Fqn( regionFqn, key ), ITEM ) != null ) {
 				Option option = new Option();
 				option.setDataVersion( NonLockingDataVersion.INSTANCE );
-                option.setCacheModeLocal(localWritesOnly);
+                option.setCacheModeLocal(queryCacheLocalWritesOnly);
 				cache.remove( new Fqn( regionFqn, key ), option );
 			}
 			else {
@@ -220,7 +223,7 @@
 		try {
 			Option option = new Option();
 			option.setDataVersion( NonLockingDataVersion.INSTANCE );
-            option.setCacheModeLocal(localWritesOnly);
+            option.setCacheModeLocal(queryCacheLocalWritesOnly);
 			cache.remove( regionFqn, option );
 		}
 		catch (Exception e) {

Modified: projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/OptimisticTreeCacheProviderHook.java
===================================================================
--- projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/OptimisticTreeCacheProviderHook.java	2008-08-06 14:28:41 UTC (rev 76714)
+++ projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/OptimisticTreeCacheProviderHook.java	2008-08-06 15:28:57 UTC (rev 76715)
@@ -22,6 +22,8 @@
  * 
  * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
  * @author Brian Stansberry
+ * @deprecated TreeCacheProviderHook supports both optimistic and pessimistic 
+ *             cache configurations.
  */
 public class OptimisticTreeCacheProviderHook extends TreeCacheProviderHook 
 {

Modified: projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/SecondLevelCacheUtil.java
===================================================================
--- projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/SecondLevelCacheUtil.java	2008-08-06 14:28:41 UTC (rev 76714)
+++ projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/SecondLevelCacheUtil.java	2008-08-06 15:28:57 UTC (rev 76715)
@@ -34,8 +34,6 @@
  */
 public class SecondLevelCacheUtil
 {
-   public static final String HIBERNATE_CACHE_REGION_PREFIX = "hibernate.cache.region_prefix";
-      
    public static String createRegionFqn(String regionName, String regionPrefix)
    {
       String escaped = null;

Modified: projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/TreeCacheProviderHook.java
===================================================================
--- projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/TreeCacheProviderHook.java	2008-08-06 14:28:41 UTC (rev 76714)
+++ projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/TreeCacheProviderHook.java	2008-08-06 15:28:57 UTC (rev 76715)
@@ -53,20 +53,7 @@
 public class TreeCacheProviderHook 
    extends org.hibernate.cache.TreeCacheProvider
    implements CacheProvider
-{
-   /**
-    * Name of the Hibernate configuration property used to provide
-    * the ObjectName of the JBoss Cache instance.
-    */
-   public static final String HIBERNATE_CACHE_OBJECT_NAME_PROPERTY = 
-      "hibernate.treecache.mbean.object_name";
-   
-   /**
-    * Default ObjectName for the JBoss Cache instance that will be used
-    * if {@link HIBERNATE_CACHE_OBJECT_NAME_PROPERTY} is not provided.
-    */
-   public static final String DEFAULT_MBEAN_OBJECT_NAME = "jboss.cache:service=TreeCache";
-   
+{   
    private static final Logger log = Logger.getLogger(TreeCacheProviderHook.class);
    
    private org.jboss.cache.TreeCache cache;
@@ -85,16 +72,16 @@
     */
    public Cache buildCache(String regionName, Properties properties) throws CacheException
    {
-      String regionPrefix = properties.getProperty("hibernate.cache.region_prefix");
+      CacheProperties cacheProperties = new CacheProperties(properties);
       
       if (optimistic)
       {
-         return new OptimisticJBCCache(cache, regionName, regionPrefix);
+         return new OptimisticJBCCache(cache, regionName, cacheProperties);
       }
       else
       {
          /* removed dependency on ejb3's TxUtil */
-         return new JBCCache(cache, regionName, regionPrefix, getTransactionManager(properties));
+         return new JBCCache(cache, regionName, cacheProperties, getTransactionManager(properties));
       }
    }
 
@@ -120,14 +107,11 @@
     */
    public void start(Properties properties)
    {
+      CacheProperties cacheProperties = new CacheProperties(properties);
+      
       try
       {
-         String cacheName = (String) properties.get(HIBERNATE_CACHE_OBJECT_NAME_PROPERTY);
-         if (cacheName == null)
-         {
-            cacheName = DEFAULT_MBEAN_OBJECT_NAME;
-         }
-         ObjectName mbeanObjectName = new ObjectName(cacheName);
+         ObjectName mbeanObjectName = new ObjectName(cacheProperties.getCacheObjectName());
          TreeCacheMBean mbean = (TreeCacheMBean) MBeanProxyExt.create(TreeCacheMBean.class, mbeanObjectName, MBeanServerLocator.locateJBoss());
          cache = mbean.getInstance();
          if ("OPTIMISTIC".equals(cache.getNodeLockingScheme()))

Modified: projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/CacheTestCaseBase.java
===================================================================
--- projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/CacheTestCaseBase.java	2008-08-06 14:28:41 UTC (rev 76714)
+++ projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/CacheTestCaseBase.java	2008-08-06 15:28:57 UTC (rev 76715)
@@ -39,6 +39,7 @@
 import org.hibernate.transaction.TransactionManagerLookupFactory;
 import org.jboss.cache.PropertyConfigurator;
 import org.jboss.cache.TreeCache;
+import org.jboss.hibernate.jbc.cacheprovider.CacheProperties;
 import org.jboss.hibernate.jbc.cacheprovider.TreeCacheProviderHook;
 import org.jboss.hibernate.jbc.cacheprovider.functional.util.DualNodeTestUtil;
 import org.jboss.hibernate.jbc.cacheprovider.functional.util.TestCacheInstanceManager;
@@ -121,7 +122,7 @@
      */
     protected void configureCacheFactory(Configuration cfg)
     {
-       cfg.setProperty(TreeCacheProviderHook.HIBERNATE_CACHE_OBJECT_NAME_PROPERTY, 
+       cfg.setProperty(CacheProperties.HIBERNATE_CACHE_OBJECT_NAME_PROPERTY, 
           TestCacheInstanceManager.CACHE_MBEAN_NAME_STARTS_WITH + TestCacheInstanceManager.SINGLE);;
     }
 

Modified: projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/DualNodeTestCaseBase.java
===================================================================
--- projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/DualNodeTestCaseBase.java	2008-08-06 14:28:41 UTC (rev 76714)
+++ projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/DualNodeTestCaseBase.java	2008-08-06 15:28:57 UTC (rev 76715)
@@ -21,6 +21,7 @@
 import org.hibernate.dialect.Dialect;
 import org.hibernate.engine.SessionFactoryImplementor;
 import org.hibernate.junit.functional.ExecutionEnvironment;
+import org.jboss.hibernate.jbc.cacheprovider.CacheProperties;
 import org.jboss.hibernate.jbc.cacheprovider.TreeCacheProviderHook;
 import org.jboss.hibernate.jbc.cacheprovider.functional.util.DualNodeConnectionProviderImpl;
 import org.jboss.hibernate.jbc.cacheprovider.functional.util.DualNodeJtaTransactionManagerImpl;
@@ -76,7 +77,7 @@
    {
       cfg.setProperty(DualNodeTestUtil.NODE_ID_PROP, 
                       DualNodeTestUtil.LOCAL);
-      cfg.setProperty(TreeCacheProviderHook.HIBERNATE_CACHE_OBJECT_NAME_PROPERTY, 
+      cfg.setProperty(CacheProperties.HIBERNATE_CACHE_OBJECT_NAME_PROPERTY, 
             TestCacheInstanceManager.CACHE_MBEAN_NAME_STARTS_WITH + DualNodeTestUtil.LOCAL);
    }
    /**
@@ -88,7 +89,7 @@
    {
       cfg.setProperty(DualNodeTestUtil.NODE_ID_PROP, 
                       DualNodeTestUtil.REMOTE);
-      cfg.setProperty(TreeCacheProviderHook.HIBERNATE_CACHE_OBJECT_NAME_PROPERTY, 
+      cfg.setProperty(CacheProperties.HIBERNATE_CACHE_OBJECT_NAME_PROPERTY, 
             TestCacheInstanceManager.CACHE_MBEAN_NAME_STARTS_WITH + DualNodeTestUtil.REMOTE);
    }
    

Modified: projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/PessimisticEntityReplicationTest.java
===================================================================
--- projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/PessimisticEntityReplicationTest.java	2008-08-06 14:28:41 UTC (rev 76714)
+++ projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/PessimisticEntityReplicationTest.java	2008-08-06 15:28:57 UTC (rev 76715)
@@ -69,12 +69,6 @@
       super(name, TreeCache.REPL_SYNC);
    }
 
-//   @Override
-//   protected Class getCacheRegionFactory()
-//   {
-//      return TestJBossCacheRegionFactory.class;
-//   }
-
    @Override
    protected boolean getUseQueryCache()
    {
@@ -84,36 +78,14 @@
    @Override
    protected void configureCacheFactory(Configuration cfg)
    {
-//      cfg.setProperty(MultiplexingCacheInstanceManager.ENTITY_CACHE_RESOURCE_PROP, 
-//                      getEntityCacheConfigName());
       cfg.setProperty(Environment.CACHE_PROVIDER_CONFIG, PessimisticJBossCacheTest.JBC_CONFIG);
       cfg.setProperty(Environment.CACHE_PROVIDER, PessimisticJBossCacheTest.JBC_CACHE_PROVIDER);      
    }
-
-//   /**
-//    * Configure the local cache overriding this method. 
-//    * */
-//   @Override
-//   protected TreeCache createRegisterStartTreeCache(Configuration cfg, String location, int cacheMode)
-//   {
-//      super.createRegisterStartTreeCache(cfg, "Local", TreeCache.REPL_SYNC);
-//   }
-//
-//   protected TreeCache createRegisterStartRemoteTreeCache(Configuration cfg, String location, int cacheMode)
-//   {
-//      super.createRegisterStartTreeCache(cfg, "Remote", TreeCache.REPL_SYNC);
-//   }   
    
-//   protected String getEntityCacheConfigName() {
-//       return "pessimistic-shared";
-//   }
-   
    public void testAll() throws Exception
    {
       System.out.println("*** " + getName());
       
-//      CacheManager localManager = TestCacheInstanceManager.getTestCacheManager(DualNodeTestUtil.LOCAL);
-//      Cache localCache = localManager.getCache(getEntityCacheConfigName(), true);
       // Bind a listener to the "local" cache
       // Our region factory makes its CacheManager available to us
       TreeCache localCache = TestCacheInstanceManager.getTreeCache(DualNodeTestUtil.LOCAL);
@@ -121,8 +93,6 @@
       localCache.addTreeCacheListener(localListener);
       TransactionManager localTM = localCache.getTransactionManager();
       
-//      CacheManager remoteManager = TestCacheInstanceManager.getTestCacheManager(DualNodeTestUtil.REMOTE);
-//      Cache remoteCache = remoteManager.getCache(getEntityCacheConfigName(), true);
       // Bind a listener to the "remote" cache
       TreeCache remoteCache = TestCacheInstanceManager.getTreeCache(DualNodeTestUtil.REMOTE);
       MyListener remoteListener = new MyListener();

Modified: projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/optimistic-treecache.xml
===================================================================
--- projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/optimistic-treecache.xml	2008-08-06 14:28:41 UTC (rev 76714)
+++ projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/optimistic-treecache.xml	2008-08-06 15:28:57 UTC (rev 76715)
@@ -67,8 +67,13 @@
          READ_COMMITTED
          READ_UNCOMMITTED
          NONE
+         
+         Once a tx reads an item from the 2nd Level Cache, Hibernate caches it 
+         in the Session object and doesn't need to go back to the 2LC for that 
+         same object. So READ_COMMITTED should be enough. There's no benefit 
+         using REPEATABLE_READ.
       -->
-      <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
+      <attribute name="IsolationLevel">READ_COMMITTED</attribute>
 
       <!--
          Valid modes are LOCAL

Modified: projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/pessimistic-treecache.xml
===================================================================
--- projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/pessimistic-treecache.xml	2008-08-06 14:28:41 UTC (rev 76714)
+++ projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/pessimistic-treecache.xml	2008-08-06 15:28:57 UTC (rev 76715)
@@ -56,8 +56,13 @@
          READ_COMMITTED
          READ_UNCOMMITTED
          NONE
+         
+         Once a tx reads an item from the 2nd Level Cache, Hibernate caches it 
+         in the Session object and doesn't need to go back to the 2LC for that 
+         same object. So READ_COMMITTED should be enough. There's no benefit 
+         using REPEATABLE_READ.
       -->
-      <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
+      <attribute name="IsolationLevel">READ_COMMITTED</attribute>
 
       <!--
          Valid modes are LOCAL

Modified: projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/util/TestCacheInstanceManager.java
===================================================================
--- projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/util/TestCacheInstanceManager.java	2008-08-06 14:28:41 UTC (rev 76714)
+++ projects/cluster/hibernate-jbc-cacheprovider/trunk/src/test/java/org/jboss/hibernate/jbc/cacheprovider/functional/util/TestCacheInstanceManager.java	2008-08-06 15:28:57 UTC (rev 76715)
@@ -38,6 +38,7 @@
 import org.hibernate.transaction.TransactionManagerLookupFactory;
 import org.jboss.cache.PropertyConfigurator;
 import org.jboss.cache.TreeCache;
+import org.jboss.hibernate.jbc.cacheprovider.CacheProperties;
 import org.jboss.hibernate.jbc.cacheprovider.TreeCacheProviderHook;
 import org.jboss.logging.Logger;
 
@@ -59,7 +60,7 @@
    
    public static final String SINGLE = "single";
    
-   public static final String CACHE_MBEAN_NAME_STARTS_WITH = TreeCacheProviderHook.DEFAULT_MBEAN_OBJECT_NAME + ",id=";
+   public static final String CACHE_MBEAN_NAME_STARTS_WITH = CacheProperties.DEFAULT_CACHE_OBJECT_NAME + ",id=";
     
    public static TreeCache getTreeCache(String name) 
    {
@@ -142,7 +143,13 @@
    {
       try
       {
-         TreeCache cache = new TreeCache();
+         TreeCache cache = new TreeCache()
+         {
+            @Override
+            protected void registerChannelInJmx()
+            {
+            }
+         };
          PropertyConfigurator config = new PropertyConfigurator();
          config.configure(cache, cfg.getProperty(Environment.CACHE_PROVIDER_CONFIG));
          cache.setCacheMode(cacheMode);




More information about the jboss-cvs-commits mailing list