[jboss-cvs] JBossAS SVN: r76778 - projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Aug 7 14:54:58 EDT 2008


Author: bstansberry at jboss.com
Date: 2008-08-07 14:54:58 -0400 (Thu, 07 Aug 2008)
New Revision: 76778

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
Log:
[JBCLUSTER-206] Timestamps cache updates can't be local; enhance configurability of local-only query cache

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-07 18:35:50 UTC (rev 76777)
+++ projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/JBCCache.java	2008-08-07 18:54:58 UTC (rev 76778)
@@ -33,6 +33,7 @@
 import org.hibernate.cache.Cache;
 import org.hibernate.cache.CacheException;
 import org.hibernate.cache.StandardQueryCache;
+import org.hibernate.cache.UpdateTimestampsCache;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.config.Option;
 import org.jboss.cache.lock.TimeoutException;
@@ -57,6 +58,7 @@
 	private final Fqn regionFqn;
 	private final TransactionManager transactionManager;
    private boolean queryCacheLocalWritesOnly;
+   private boolean localPutsOnly;
    
    private final CacheProperties cacheProperties;
 	
@@ -67,12 +69,14 @@
 		this.cache = cache;
 		this.regionName = regionName;
 		this.cacheProperties = cacheProperties;
-      this.regionFqn = Fqn.fromString(SecondLevelCacheUtil.createRegionFqn(regionName, this.cacheProperties.getCacheRegionPrefix()));
+        this.regionFqn = Fqn.fromString(SecondLevelCacheUtil.createRegionFqn(regionName, this.cacheProperties.getCacheRegionPrefix()));
 		this.transactionManager = transactionManager;
+		
+		this.queryCacheLocalWritesOnly = this.cacheProperties.isQueryCacheLocalWritesOnly() && regionName.contains(StandardQueryCache.class.getName());
+		this.localPutsOnly = this.cacheProperties.isLocalPutsOnly() && (regionName.contains(UpdateTimestampsCache.class.getName()) == false);
+		
       if (cache.getUseRegionBasedMarshalling())
-      {           
-         queryCacheLocalWritesOnly = StandardQueryCache.class.getName().equals(regionName) && this.cacheProperties.isQueryCacheLocalWritesOnly();
-           
+      {
          boolean fetchState = cache.getFetchInMemoryState();
          try
          {
@@ -95,6 +99,8 @@
       {
          log.debug("TreeCache is not configured for region based marshalling");
       }
+      
+      this.localPutsOnly = this.cacheProperties.isLocalPutsOnly() && (regionName.contains(UpdateTimestampsCache.class.getName()) == false);
 	}
 
 	public Object get(Object key) throws CacheException {
@@ -135,7 +141,7 @@
 	public void put(Object key, Object value) throws CacheException {
 		Transaction tx = suspend();
 		try {
-           if (queryCacheLocalWritesOnly || cacheProperties.isLocalPutsOnly()) {
+           if (queryCacheLocalWritesOnly || localPutsOnly) {
               Option option = new Option();
               option.setCacheModeLocal(true);
               // Overloaded method isn't available, so have to use InvocationContext

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-07 18:35:50 UTC (rev 76777)
+++ projects/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/OptimisticJBCCache.java	2008-08-07 18:54:58 UTC (rev 76778)
@@ -31,6 +31,7 @@
 import org.hibernate.cache.OptimisticCache;
 import org.hibernate.cache.OptimisticCacheSource;
 import org.hibernate.cache.StandardQueryCache;
+import org.hibernate.cache.UpdateTimestampsCache;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.optimistic.DataVersion;
 import org.jboss.cache.config.Option;
@@ -59,6 +60,7 @@
 	private final Fqn regionFqn;
 	private OptimisticCacheSource source;
    private boolean queryCacheLocalWritesOnly;
+   private boolean localPutsOnly;
    
    private final CacheProperties cacheProperties;
 
@@ -69,10 +71,12 @@
 		this.regionName = regionName;
 		this.cacheProperties = cacheProperties;
       this.regionFqn = Fqn.fromString(SecondLevelCacheUtil.createRegionFqn(regionName, this.cacheProperties.getCacheRegionPrefix()));
+      
+      this.queryCacheLocalWritesOnly = this.cacheProperties.isQueryCacheLocalWritesOnly() && regionName.contains(StandardQueryCache.class.getName());
+      this.localPutsOnly = this.cacheProperties.isLocalPutsOnly() && (regionName.contains(UpdateTimestampsCache.class.getName()) == false);
+      
       if (cache.getUseRegionBasedMarshalling())
-      {           
-         queryCacheLocalWritesOnly = StandardQueryCache.class.getName().equals(regionName) && this.cacheProperties.isQueryCacheLocalWritesOnly();
-           
+      {
          boolean fetchState = cache.getFetchInMemoryState();
          try
          {
@@ -128,7 +132,7 @@
 			Option option = new Option();
 			option.setFailSilently( true );
 			option.setDataVersion( NonLockingDataVersion.INSTANCE );
-         option.setCacheModeLocal(queryCacheLocalWritesOnly);
+            option.setCacheModeLocal(queryCacheLocalWritesOnly || localPutsOnly);
 			cache.remove( new Fqn( regionFqn, key ), "ITEM", option );
 
 			option = new Option();
@@ -137,7 +141,7 @@
 			                 ? new DataVersionAdapter( currentVersion, currentVersion, source.getVersionComparator(), source.toString() )
 			                 : NonLockingDataVersion.INSTANCE;
 			option.setDataVersion( dv );
-         option.setCacheModeLocal(queryCacheLocalWritesOnly);
+            option.setCacheModeLocal(queryCacheLocalWritesOnly || localPutsOnly);
 			cache.put( new Fqn( regionFqn, key ), ITEM, value, option );
 		}
 		catch (Exception e) {
@@ -188,7 +192,7 @@
 			Option option = new Option();
 			option.setFailSilently( true );
 			option.setDataVersion( NonLockingDataVersion.INSTANCE );
-         option.setCacheModeLocal(queryCacheLocalWritesOnly);
+            option.setCacheModeLocal(queryCacheLocalWritesOnly || localPutsOnly);
 			cache.put( new Fqn( regionFqn, key ), ITEM, value, option );
 		}
 		catch (TimeoutException te) {




More information about the jboss-cvs-commits mailing list