Author: galder.zamarreno(a)jboss.com
Date: 2010-01-25 11:23:59 -0500 (Mon, 25 Jan 2010)
New Revision: 18618
Modified:
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/CollectionRegionImpl.java
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/EntityRegionImpl.java
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseGeneralDataRegion.java
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseTransactionalDataRegion.java
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/query/QueryResultsRegionImpl.java
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/timestamp/TimestampsRegionImpl.java
Log:
Individual regions currently use the same implementation as InfinispanRegionFactory for
the next timestamp. Get them to actually call InfinispanRegionFactory to make it easier
for users to provide diff implementations if desired.
Modified:
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java
===================================================================
---
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java 2010-01-25
15:47:02 UTC (rev 18617)
+++
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java 2010-01-25
16:23:59 UTC (rev 18618)
@@ -162,7 +162,7 @@
log.debug("Building collection cache region [" + regionName +
"]");
Cache cache = getCache(regionName, COLLECTION_KEY, properties);
CacheAdapter cacheAdapter = CacheAdapterImpl.newInstance(cache);
- CollectionRegionImpl region = new CollectionRegionImpl(cacheAdapter, regionName,
metadata, transactionManager);
+ CollectionRegionImpl region = new CollectionRegionImpl(cacheAdapter, regionName,
metadata, transactionManager, this);
region.start();
return region;
}
@@ -172,7 +172,7 @@
if (log.isDebugEnabled()) log.debug("Building entity cache region [" +
regionName + "]");
Cache cache = getCache(regionName, ENTITY_KEY, properties);
CacheAdapter cacheAdapter = CacheAdapterImpl.newInstance(cache);
- EntityRegionImpl region = new EntityRegionImpl(cacheAdapter, regionName, metadata,
transactionManager);
+ EntityRegionImpl region = new EntityRegionImpl(cacheAdapter, regionName, metadata,
transactionManager, this);
region.start();
return region;
}
@@ -185,7 +185,7 @@
log.debug("Building query results cache region [" + regionName +
"]");
String cacheName = typeOverrides.get(QUERY_KEY).getCacheName();
CacheAdapter cacheAdapter =
CacheAdapterImpl.newInstance(manager.getCache(cacheName));
- QueryResultsRegionImpl region = new QueryResultsRegionImpl(cacheAdapter,
regionName, properties, transactionManager);
+ QueryResultsRegionImpl region = new QueryResultsRegionImpl(cacheAdapter,
regionName, properties, transactionManager, this);
region.start();
return region;
}
@@ -198,7 +198,7 @@
log.debug("Building timestamps cache region [" + regionName +
"]");
String cacheName = typeOverrides.get(TIMESTAMPS_KEY).getCacheName();
CacheAdapter cacheAdapter =
CacheAdapterImpl.newInstance(manager.getCache(cacheName));
- TimestampsRegionImpl region = new TimestampsRegionImpl(cacheAdapter, regionName,
transactionManager);
+ TimestampsRegionImpl region = new TimestampsRegionImpl(cacheAdapter, regionName,
transactionManager, this);
region.start();
return region;
}
Modified:
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/CollectionRegionImpl.java
===================================================================
---
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/CollectionRegionImpl.java 2010-01-25
15:47:02 UTC (rev 18617)
+++
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/CollectionRegionImpl.java 2010-01-25
16:23:59 UTC (rev 18618)
@@ -5,6 +5,7 @@
import org.hibernate.cache.CacheDataDescription;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.CollectionRegion;
+import org.hibernate.cache.RegionFactory;
import org.hibernate.cache.access.AccessType;
import org.hibernate.cache.access.CollectionRegionAccessStrategy;
import org.hibernate.cache.infinispan.access.PutFromLoadValidator;
@@ -20,8 +21,9 @@
@Listener
public class CollectionRegionImpl extends BaseTransactionalDataRegion implements
CollectionRegion {
- public CollectionRegionImpl(CacheAdapter cacheAdapter, String name,
CacheDataDescription metadata, TransactionManager transactionManager) {
- super(cacheAdapter, name, metadata, transactionManager);
+ public CollectionRegionImpl(CacheAdapter cacheAdapter, String name,
CacheDataDescription metadata,
+ TransactionManager transactionManager, RegionFactory factory) {
+ super(cacheAdapter, name, metadata, transactionManager, factory);
}
public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType)
throws CacheException {
Modified:
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/EntityRegionImpl.java
===================================================================
---
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/EntityRegionImpl.java 2010-01-25
15:47:02 UTC (rev 18617)
+++
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/EntityRegionImpl.java 2010-01-25
16:23:59 UTC (rev 18618)
@@ -5,6 +5,7 @@
import org.hibernate.cache.CacheDataDescription;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.EntityRegion;
+import org.hibernate.cache.RegionFactory;
import org.hibernate.cache.access.AccessType;
import org.hibernate.cache.access.EntityRegionAccessStrategy;
import org.hibernate.cache.infinispan.access.PutFromLoadValidator;
@@ -20,8 +21,9 @@
@Listener
public class EntityRegionImpl extends BaseTransactionalDataRegion implements EntityRegion
{
- public EntityRegionImpl(CacheAdapter cacheAdapter, String name, CacheDataDescription
metadata, TransactionManager transactionManager) {
- super(cacheAdapter, name, metadata, transactionManager);
+ public EntityRegionImpl(CacheAdapter cacheAdapter, String name, CacheDataDescription
metadata,
+ TransactionManager transactionManager, RegionFactory factory) {
+ super(cacheAdapter, name, metadata, transactionManager, factory);
}
public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws
CacheException {
Modified:
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseGeneralDataRegion.java
===================================================================
---
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseGeneralDataRegion.java 2010-01-25
15:47:02 UTC (rev 18617)
+++
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseGeneralDataRegion.java 2010-01-25
16:23:59 UTC (rev 18618)
@@ -4,6 +4,7 @@
import org.hibernate.cache.CacheException;
import org.hibernate.cache.GeneralDataRegion;
+import org.hibernate.cache.RegionFactory;
import org.hibernate.cache.infinispan.util.CacheAdapter;
/**
@@ -15,8 +16,8 @@
*/
public abstract class BaseGeneralDataRegion extends BaseRegion implements
GeneralDataRegion {
- public BaseGeneralDataRegion(CacheAdapter cacheAdapter, String name,
TransactionManager transactionManager) {
- super(cacheAdapter, name, transactionManager);
+ public BaseGeneralDataRegion(CacheAdapter cacheAdapter, String name,
TransactionManager transactionManager, RegionFactory factory) {
+ super(cacheAdapter, name, transactionManager, factory);
}
public void evict(Object key) throws CacheException {
Modified:
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java
===================================================================
---
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java 2010-01-25
15:47:02 UTC (rev 18617)
+++
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java 2010-01-25
16:23:59 UTC (rev 18618)
@@ -14,6 +14,7 @@
import org.hibernate.cache.CacheException;
import org.hibernate.cache.Region;
+import org.hibernate.cache.RegionFactory;
import org.hibernate.cache.infinispan.util.AddressAdapter;
import org.hibernate.cache.infinispan.util.AddressAdapterImpl;
import org.hibernate.cache.infinispan.util.CacheAdapter;
@@ -48,14 +49,16 @@
protected final boolean replication;
protected final Object invalidationMutex = new Object();
protected final AtomicReference<InvalidateState> invalidateState = new
AtomicReference<InvalidateState>(InvalidateState.VALID);
+ private final RegionFactory factory;
- public BaseRegion(CacheAdapter cacheAdapter, String name, TransactionManager
transactionManager) {
+ public BaseRegion(CacheAdapter cacheAdapter, String name, TransactionManager
transactionManager, RegionFactory factory) {
this.cacheAdapter = cacheAdapter;
this.name = name;
this.transactionManager = transactionManager;
this.replication = cacheAdapter.isClusteredReplication();
this.address = this.cacheAdapter.getAddress();
this.cacheAdapter.addListener(this);
+ this.factory = factory;
}
public void start() {
@@ -126,7 +129,7 @@
}
public long nextTimestamp() {
- return System.currentTimeMillis() / 100;
+ return factory.nextTimestamp();
}
public Map toMap() {
Modified:
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseTransactionalDataRegion.java
===================================================================
---
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseTransactionalDataRegion.java 2010-01-25
15:47:02 UTC (rev 18617)
+++
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseTransactionalDataRegion.java 2010-01-25
16:23:59 UTC (rev 18618)
@@ -3,6 +3,7 @@
import javax.transaction.TransactionManager;
import org.hibernate.cache.CacheDataDescription;
+import org.hibernate.cache.RegionFactory;
import org.hibernate.cache.TransactionalDataRegion;
import org.hibernate.cache.infinispan.util.CacheAdapter;
@@ -17,8 +18,8 @@
private final CacheDataDescription metadata;
- public BaseTransactionalDataRegion(CacheAdapter cacheAdapter, String name,
CacheDataDescription metadata, TransactionManager transactionManager) {
- super(cacheAdapter, name, transactionManager);
+ public BaseTransactionalDataRegion(CacheAdapter cacheAdapter, String name,
CacheDataDescription metadata, TransactionManager transactionManager, RegionFactory
factory) {
+ super(cacheAdapter, name, transactionManager, factory);
this.metadata = metadata;
}
Modified:
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/query/QueryResultsRegionImpl.java
===================================================================
---
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/query/QueryResultsRegionImpl.java 2010-01-25
15:47:02 UTC (rev 18617)
+++
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/query/QueryResultsRegionImpl.java 2010-01-25
16:23:59 UTC (rev 18618)
@@ -7,6 +7,7 @@
import org.hibernate.cache.CacheException;
import org.hibernate.cache.QueryResultsRegion;
+import org.hibernate.cache.RegionFactory;
import org.hibernate.cache.infinispan.impl.BaseTransactionalDataRegion;
import org.hibernate.cache.infinispan.util.CacheAdapter;
import org.hibernate.cache.infinispan.util.CacheHelper;
@@ -22,9 +23,8 @@
public class QueryResultsRegionImpl extends BaseTransactionalDataRegion implements
QueryResultsRegion {
private boolean localOnly;
- public QueryResultsRegionImpl(CacheAdapter cacheAdapter, String name, Properties
properties, TransactionManager transactionManager) {
- super(cacheAdapter, name, null, transactionManager);
-
+ public QueryResultsRegionImpl(CacheAdapter cacheAdapter, String name, Properties
properties, TransactionManager transactionManager, RegionFactory factory) {
+ super(cacheAdapter, name, null, transactionManager, factory);
// If Infinispan is using INVALIDATION for query cache, we don't want to
propagate changes.
// We use the Timestamps cache to manage invalidation
localOnly = cacheAdapter.isClusteredInvalidation();
Modified:
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/timestamp/TimestampsRegionImpl.java
===================================================================
---
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/timestamp/TimestampsRegionImpl.java 2010-01-25
15:47:02 UTC (rev 18617)
+++
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/timestamp/TimestampsRegionImpl.java 2010-01-25
16:23:59 UTC (rev 18618)
@@ -8,6 +8,7 @@
import javax.transaction.TransactionManager;
import org.hibernate.cache.CacheException;
+import org.hibernate.cache.RegionFactory;
import org.hibernate.cache.TimestampsRegion;
import org.hibernate.cache.infinispan.impl.BaseGeneralDataRegion;
import org.hibernate.cache.infinispan.util.CacheAdapter;
@@ -32,8 +33,8 @@
private Map localCache = new ConcurrentHashMap();
- public TimestampsRegionImpl(CacheAdapter cacheAdapter, String name, TransactionManager
transactionManager) {
- super(cacheAdapter, name, transactionManager);
+ public TimestampsRegionImpl(CacheAdapter cacheAdapter, String name, TransactionManager
transactionManager, RegionFactory factory) {
+ super(cacheAdapter, name, transactionManager, factory);
cacheAdapter.addListener(this);
populateLocalCache();
}