HHH-9695 Use non-transactional cache for immutable entities
This commit is contained in:
parent
4e2f7aeae4
commit
ccc83405c4
|
@ -6,20 +6,6 @@
|
|||
*/
|
||||
package org.hibernate.cache.infinispan;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.hibernate.boot.spi.SessionFactoryOptions;
|
||||
import org.hibernate.cache.CacheException;
|
||||
import org.hibernate.cache.infinispan.collection.CollectionRegionImpl;
|
||||
|
@ -43,7 +29,6 @@ import org.hibernate.cache.spi.TimestampsRegion;
|
|||
import org.hibernate.cache.spi.access.AccessType;
|
||||
import org.hibernate.internal.util.ClassLoaderHelper;
|
||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||
|
||||
import org.infinispan.AdvancedCache;
|
||||
import org.infinispan.commands.module.ModuleCommandFactory;
|
||||
import org.infinispan.commons.util.FileLookupFactory;
|
||||
|
@ -61,6 +46,20 @@ import org.infinispan.util.concurrent.IsolationLevel;
|
|||
import org.infinispan.util.logging.Log;
|
||||
import org.infinispan.util.logging.LogFactory;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* A {@link RegionFactory} for <a href="http://www.jboss.org/infinispan">Infinispan</a>-backed cache
|
||||
* regions.
|
||||
|
@ -133,6 +132,13 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
*/
|
||||
public static final String ENTITY_CACHE_RESOURCE_PROP = PREFIX + ENTITY_KEY + CONFIG_SUFFIX;
|
||||
|
||||
private static final String IMMUTABLE_ENTITY_KEY = "immutable-entity";
|
||||
|
||||
/**
|
||||
* Name of the configuration that should be used for immutable entity caches.
|
||||
*/
|
||||
public static final String IMMUTABLE_ENTITY_CACHE_RESOURCE_PROP = PREFIX + IMMUTABLE_ENTITY_KEY + CONFIG_SUFFIX;
|
||||
|
||||
private static final String COLLECTION_KEY = "collection";
|
||||
|
||||
/**
|
||||
|
@ -175,6 +181,11 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
*/
|
||||
public static final String DEF_ENTITY_RESOURCE = "entity";
|
||||
|
||||
/**
|
||||
* Default value for {@link #IMMUTABLE_ENTITY_CACHE_RESOURCE_PROP}.
|
||||
*/
|
||||
public static final String DEF_IMMUTABLE_ENTITY_RESOURCE = "immutable-entity";
|
||||
|
||||
/**
|
||||
* Default value for {@link #TIMESTAMPS_CACHE_RESOURCE_PROP}.
|
||||
*/
|
||||
|
@ -238,9 +249,9 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
public EntityRegion buildEntityRegion(String regionName, Properties properties, CacheDataDescription metadata)
|
||||
throws CacheException {
|
||||
if ( log.isDebugEnabled() ) {
|
||||
log.debug( "Building entity cache region [" + regionName + "]" );
|
||||
log.debugf( "Building entity cache region [%s] (mutable=%s, versioned=%s)", regionName, metadata.isMutable(), metadata.isVersioned());
|
||||
}
|
||||
final AdvancedCache cache = getCache( regionName, ENTITY_KEY, properties );
|
||||
final AdvancedCache cache = getCache( regionName, metadata.isMutable() ? ENTITY_KEY : IMMUTABLE_ENTITY_KEY, properties );
|
||||
final EntityRegionImpl region = new EntityRegionImpl( cache, regionName, metadata, this );
|
||||
startRegion( region, regionName );
|
||||
return region;
|
||||
|
@ -448,6 +459,9 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
final TypeOverrides entityOverrides = new TypeOverrides();
|
||||
entityOverrides.setCacheName(DEF_ENTITY_RESOURCE);
|
||||
typeOverrides.put( ENTITY_KEY, entityOverrides );
|
||||
final TypeOverrides immutableEntityOverrides = new TypeOverrides();
|
||||
immutableEntityOverrides.setCacheName( DEF_IMMUTABLE_ENTITY_RESOURCE );
|
||||
typeOverrides.put( IMMUTABLE_ENTITY_KEY, immutableEntityOverrides );
|
||||
final TypeOverrides collectionOverrides = new TypeOverrides();
|
||||
collectionOverrides.setCacheName( DEF_ENTITY_RESOURCE );
|
||||
typeOverrides.put( COLLECTION_KEY, collectionOverrides );
|
||||
|
@ -509,7 +523,7 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
}
|
||||
|
||||
private void defineGenericDataTypeCacheConfigurations(Properties properties) {
|
||||
final String[] defaultGenericDataTypes = new String[] {ENTITY_KEY, COLLECTION_KEY, TIMESTAMPS_KEY, QUERY_KEY};
|
||||
final String[] defaultGenericDataTypes = new String[] {ENTITY_KEY, IMMUTABLE_ENTITY_KEY, COLLECTION_KEY, TIMESTAMPS_KEY, QUERY_KEY};
|
||||
for ( String type : defaultGenericDataTypes ) {
|
||||
final TypeOverrides override = overrideStatisticsIfPresent( typeOverrides.get( type ), properties );
|
||||
final String cacheName = override.getCacheName();
|
||||
|
|
|
@ -6,16 +6,16 @@
|
|||
*/
|
||||
package org.hibernate.cache.infinispan;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.cache.CacheException;
|
||||
|
||||
import org.infinispan.configuration.cache.Configuration;
|
||||
import org.infinispan.configuration.cache.ConfigurationBuilder;
|
||||
import org.infinispan.eviction.EvictionStrategy;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* This class represents Infinispan cache parameters that can be configured via hibernate configuration properties
|
||||
* for either general entity/collection/query/timestamp data type caches and overrides for individual entity or
|
||||
|
@ -24,7 +24,7 @@ import org.infinispan.eviction.EvictionStrategy;
|
|||
* @author Galder Zamarreño
|
||||
* @since 3.5
|
||||
*/
|
||||
public class TypeOverrides {
|
||||
public class TypeOverrides implements Serializable {
|
||||
|
||||
private final Set<String> overridden = new HashSet<String>();
|
||||
|
||||
|
|
|
@ -46,7 +46,11 @@ public class EntityRegionImpl extends BaseTransactionalDataRegion implements Ent
|
|||
case READ_ONLY:
|
||||
return new ReadOnlyAccess( this );
|
||||
case TRANSACTIONAL:
|
||||
if (getCacheDataDescription().isMutable()) {
|
||||
return new TransactionalAccess(this);
|
||||
} else {
|
||||
return new ReadOnlyAccess(this);
|
||||
}
|
||||
default:
|
||||
throw new CacheException( "Unsupported access type [" + accessType.getExternalName() + "]" );
|
||||
}
|
||||
|
|
|
@ -26,6 +26,14 @@
|
|||
<expiration max-idle="100000" interval="5000"/>
|
||||
</invalidation-cache>
|
||||
|
||||
<!-- Default configuration for immutable entities -->
|
||||
<invalidation-cache name="immutable-entity" mode="SYNC" remote-timeout="20000">
|
||||
<locking isolation="READ_COMMITTED" concurrency-level="1000" acquire-timeout="15000" striping="false"/>
|
||||
<transaction mode="NONE"/>
|
||||
<eviction max-entries="10000" strategy="LRU"/>
|
||||
<expiration max-idle="100000" interval="5000"/>
|
||||
</invalidation-cache>
|
||||
|
||||
<!-- Default configuration is appropriate for entity/collection caching. -->
|
||||
<invalidation-cache name="entity-repeatable" mode="SYNC" remote-timeout="20000">
|
||||
<locking isolation="REPEATABLE_READ" concurrency-level="1000" acquire-timeout="15000" striping="false"/>
|
||||
|
|
|
@ -6,9 +6,6 @@
|
|||
*/
|
||||
package org.hibernate.test.cache.infinispan;
|
||||
|
||||
import java.util.Properties;
|
||||
import javax.transaction.TransactionManager;
|
||||
|
||||
import org.hibernate.boot.spi.SessionFactoryOptions;
|
||||
import org.hibernate.cache.CacheException;
|
||||
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
|
||||
|
@ -17,14 +14,13 @@ import org.hibernate.cache.infinispan.entity.EntityRegionImpl;
|
|||
import org.hibernate.cache.infinispan.query.QueryResultsRegionImpl;
|
||||
import org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl;
|
||||
import org.hibernate.cache.infinispan.tm.HibernateTransactionManagerLookup;
|
||||
import org.hibernate.cache.internal.CacheDataDescriptionImpl;
|
||||
import org.hibernate.cache.spi.CacheDataDescription;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform;
|
||||
import org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJtaPlatform;
|
||||
|
||||
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||
import org.hibernate.test.cache.infinispan.functional.SingleNodeTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||
import org.infinispan.AdvancedCache;
|
||||
import org.infinispan.configuration.cache.CacheMode;
|
||||
import org.infinispan.configuration.cache.Configuration;
|
||||
|
@ -34,13 +30,13 @@ import org.infinispan.eviction.EvictionStrategy;
|
|||
import org.infinispan.manager.DefaultCacheManager;
|
||||
import org.infinispan.manager.EmbeddedCacheManager;
|
||||
import org.infinispan.test.TestingUtil;
|
||||
import org.infinispan.transaction.TransactionMode;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import javax.transaction.TransactionManager;
|
||||
import java.util.Properties;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* InfinispanRegionFactoryTestCase.
|
||||
|
@ -49,6 +45,8 @@ import static org.junit.Assert.fail;
|
|||
* @since 3.5
|
||||
*/
|
||||
public class InfinispanRegionFactoryTestCase {
|
||||
private static CacheDataDescription MUTABLE_NON_VERSIONED = new CacheDataDescriptionImpl(true, false, null);
|
||||
private static CacheDataDescription IMMUTABLE_NON_VERSIONED = new CacheDataDescriptionImpl(false, false, null);
|
||||
|
||||
@Test
|
||||
public void testConfigurationProcessing() {
|
||||
|
@ -136,7 +134,7 @@ public class InfinispanRegionFactoryTestCase {
|
|||
assertFalse(factory.getDefinedConfigurations().contains(addresses));
|
||||
AdvancedCache cache;
|
||||
|
||||
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion(person, p, null);
|
||||
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion(person, p, MUTABLE_NON_VERSIONED);
|
||||
assertNotNull(factory.getTypeOverrides().get(person));
|
||||
assertTrue(factory.getDefinedConfigurations().contains(person));
|
||||
assertNull(factory.getTypeOverrides().get(address));
|
||||
|
@ -149,7 +147,7 @@ public class InfinispanRegionFactoryTestCase {
|
|||
assertEquals(30000, cacheCfg.expiration().maxIdle());
|
||||
assertFalse(cacheCfg.jmxStatistics().enabled());
|
||||
|
||||
region = (EntityRegionImpl) factory.buildEntityRegion(address, p, null);
|
||||
region = (EntityRegionImpl) factory.buildEntityRegion(address, p, MUTABLE_NON_VERSIONED);
|
||||
assertNotNull(factory.getTypeOverrides().get(person));
|
||||
assertTrue(factory.getDefinedConfigurations().contains(person));
|
||||
assertNull(factory.getTypeOverrides().get(address));
|
||||
|
@ -160,7 +158,7 @@ public class InfinispanRegionFactoryTestCase {
|
|||
assertEquals(20000, cacheCfg.eviction().maxEntries());
|
||||
assertFalse(cacheCfg.jmxStatistics().enabled());
|
||||
|
||||
region = (EntityRegionImpl) factory.buildEntityRegion(car, p, null);
|
||||
region = (EntityRegionImpl) factory.buildEntityRegion(car, p, MUTABLE_NON_VERSIONED);
|
||||
assertNotNull(factory.getTypeOverrides().get(person));
|
||||
assertTrue(factory.getDefinedConfigurations().contains(person));
|
||||
assertNull(factory.getTypeOverrides().get(address));
|
||||
|
@ -172,7 +170,7 @@ public class InfinispanRegionFactoryTestCase {
|
|||
assertFalse(cacheCfg.jmxStatistics().enabled());
|
||||
|
||||
CollectionRegionImpl collectionRegion = (CollectionRegionImpl)
|
||||
factory.buildCollectionRegion(addresses, p, null);
|
||||
factory.buildCollectionRegion(addresses, p, MUTABLE_NON_VERSIONED);
|
||||
assertNotNull(factory.getTypeOverrides().get(addresses));
|
||||
assertTrue(factory.getDefinedConfigurations().contains(person));
|
||||
assertNull(factory.getTypeOverrides().get(parts));
|
||||
|
@ -185,7 +183,7 @@ public class InfinispanRegionFactoryTestCase {
|
|||
assertEquals(35000, cacheCfg.expiration().maxIdle());
|
||||
assertFalse(cacheCfg.jmxStatistics().enabled());
|
||||
|
||||
collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion(parts, p, null);
|
||||
collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion(parts, p, MUTABLE_NON_VERSIONED);
|
||||
assertNotNull(factory.getTypeOverrides().get(addresses));
|
||||
assertTrue(factory.getDefinedConfigurations().contains(addresses));
|
||||
assertNull(factory.getTypeOverrides().get(parts));
|
||||
|
@ -196,7 +194,7 @@ public class InfinispanRegionFactoryTestCase {
|
|||
assertEquals(25000, cacheCfg.eviction().maxEntries());
|
||||
assertFalse(cacheCfg.jmxStatistics().enabled());
|
||||
|
||||
collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion(parts, p, null);
|
||||
collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion(parts, p, MUTABLE_NON_VERSIONED);
|
||||
assertNotNull(factory.getTypeOverrides().get(addresses));
|
||||
assertTrue(factory.getDefinedConfigurations().contains(addresses));
|
||||
assertNull(factory.getTypeOverrides().get(parts));
|
||||
|
@ -224,7 +222,7 @@ public class InfinispanRegionFactoryTestCase {
|
|||
InfinispanRegionFactory factory = createRegionFactory(p);
|
||||
try {
|
||||
factory.getCacheManager();
|
||||
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Address", p, null);
|
||||
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Address", p, MUTABLE_NON_VERSIONED);
|
||||
assertNull(factory.getTypeOverrides().get("com.acme.Address"));
|
||||
cache = region.getCache();
|
||||
Configuration cacheCfg = cache.getCacheConfiguration();
|
||||
|
@ -235,7 +233,7 @@ public class InfinispanRegionFactoryTestCase {
|
|||
assertEquals(100000, cacheCfg.expiration().maxIdle());
|
||||
|
||||
CollectionRegionImpl collectionRegion = (CollectionRegionImpl)
|
||||
factory.buildCollectionRegion("com.acme.Person.addresses", p, null);
|
||||
factory.buildCollectionRegion("com.acme.Person.addresses", p, MUTABLE_NON_VERSIONED);
|
||||
assertNull(factory.getTypeOverrides().get("com.acme.Person.addresses"));
|
||||
cache = collectionRegion.getCache();
|
||||
cacheCfg = cache.getCacheConfiguration();
|
||||
|
@ -264,7 +262,7 @@ public class InfinispanRegionFactoryTestCase {
|
|||
factory.getCacheManager();
|
||||
assertNotNull(factory.getTypeOverrides().get(person));
|
||||
assertFalse(factory.getDefinedConfigurations().contains(person));
|
||||
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion(person, p, null);
|
||||
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion(person, p, MUTABLE_NON_VERSIONED);
|
||||
assertNotNull(factory.getTypeOverrides().get(person));
|
||||
assertTrue(factory.getDefinedConfigurations().contains(person));
|
||||
AdvancedCache cache = region.getCache();
|
||||
|
@ -279,6 +277,23 @@ public class InfinispanRegionFactoryTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildImmutableEntityRegion() {
|
||||
AdvancedCache cache;
|
||||
Properties p = new Properties();
|
||||
InfinispanRegionFactory factory = createRegionFactory(p);
|
||||
try {
|
||||
factory.getCacheManager();
|
||||
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Address", p, IMMUTABLE_NON_VERSIONED);
|
||||
assertNull(factory.getTypeOverrides().get("com.acme.Address"));
|
||||
cache = region.getCache();
|
||||
Configuration cacheCfg = cache.getCacheConfiguration();
|
||||
assertEquals("Immutable entity should get non-transactional cache", TransactionMode.NON_TRANSACTIONAL, cacheCfg.transaction().transactionMode());
|
||||
} finally {
|
||||
factory.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = CacheException.class)
|
||||
public void testTimestampValidation() {
|
||||
Properties p = createProperties();
|
||||
|
@ -448,12 +463,12 @@ public class InfinispanRegionFactoryTestCase {
|
|||
try {
|
||||
EmbeddedCacheManager manager = factory.getCacheManager();
|
||||
assertTrue(manager.getCacheManagerConfiguration().globalJmxStatistics().enabled());
|
||||
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Address", p, null);
|
||||
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Address", p, MUTABLE_NON_VERSIONED);
|
||||
AdvancedCache cache = region.getCache();
|
||||
assertTrue(factory.getTypeOverrides().get("entity").isExposeStatistics());
|
||||
assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
|
||||
|
||||
region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Person", p, null);
|
||||
region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Person", p, MUTABLE_NON_VERSIONED);
|
||||
cache = region.getCache();
|
||||
assertTrue(factory.getTypeOverrides().get("com.acme.Person").isExposeStatistics());
|
||||
assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
|
||||
|
@ -476,7 +491,7 @@ public class InfinispanRegionFactoryTestCase {
|
|||
assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
|
||||
|
||||
CollectionRegionImpl collectionRegion = (CollectionRegionImpl)
|
||||
factory.buildCollectionRegion("com.acme.Person.addresses", p, null);
|
||||
factory.buildCollectionRegion("com.acme.Person.addresses", p, MUTABLE_NON_VERSIONED);
|
||||
cache = collectionRegion.getCache();
|
||||
assertTrue(factory.getTypeOverrides().get("collection").isExposeStatistics());
|
||||
assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
|
||||
|
@ -497,12 +512,12 @@ public class InfinispanRegionFactoryTestCase {
|
|||
p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "10000");
|
||||
InfinispanRegionFactory factory = createRegionFactory(p);
|
||||
try {
|
||||
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Address", p, null);
|
||||
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Address", p, MUTABLE_NON_VERSIONED);
|
||||
AdvancedCache cache = region.getCache();
|
||||
assertFalse(factory.getTypeOverrides().get("entity").isExposeStatistics());
|
||||
assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
|
||||
|
||||
region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Person", p, null);
|
||||
region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Person", p, MUTABLE_NON_VERSIONED);
|
||||
cache = region.getCache();
|
||||
assertFalse(factory.getTypeOverrides().get("com.acme.Person").isExposeStatistics());
|
||||
assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
|
||||
|
@ -524,7 +539,7 @@ public class InfinispanRegionFactoryTestCase {
|
|||
assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
|
||||
|
||||
CollectionRegionImpl collectionRegion = (CollectionRegionImpl)
|
||||
factory.buildCollectionRegion("com.acme.Person.addresses", p, null);
|
||||
factory.buildCollectionRegion("com.acme.Person.addresses", p, MUTABLE_NON_VERSIONED);
|
||||
cache = collectionRegion.getCache();
|
||||
assertFalse(factory.getTypeOverrides().get("collection").isExposeStatistics());
|
||||
assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
|
||||
|
|
|
@ -6,10 +6,9 @@
|
|||
*/
|
||||
package org.hibernate.test.cache.infinispan.collection;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.cache.CacheException;
|
||||
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
|
||||
import org.hibernate.cache.internal.CacheDataDescriptionImpl;
|
||||
import org.hibernate.cache.spi.CacheDataDescription;
|
||||
import org.hibernate.cache.spi.CollectionRegion;
|
||||
import org.hibernate.cache.spi.Region;
|
||||
|
@ -19,6 +18,8 @@ import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy;
|
|||
import org.hibernate.test.cache.infinispan.AbstractEntityCollectionRegionTestCase;
|
||||
import org.infinispan.AdvancedCache;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
|
@ -28,9 +29,11 @@ import static org.junit.Assert.fail;
|
|||
* @author Galder Zamarreño
|
||||
*/
|
||||
public class CollectionRegionImplTestCase extends AbstractEntityCollectionRegionTestCase {
|
||||
private static CacheDataDescription MUTABLE_NON_VERSIONED = new CacheDataDescriptionImpl(true, false, null);
|
||||
|
||||
@Override
|
||||
protected void supportedAccessTypeTest(RegionFactory regionFactory, Properties properties) {
|
||||
CollectionRegion region = regionFactory.buildCollectionRegion("test", properties, null);
|
||||
CollectionRegion region = regionFactory.buildCollectionRegion("test", properties, MUTABLE_NON_VERSIONED);
|
||||
assertNull("Got TRANSACTIONAL", region.buildAccessStrategy(AccessType.TRANSACTIONAL)
|
||||
.lockRegion());
|
||||
try {
|
||||
|
|
|
@ -6,10 +6,9 @@
|
|||
*/
|
||||
package org.hibernate.test.cache.infinispan.entity;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.cache.CacheException;
|
||||
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
|
||||
import org.hibernate.cache.internal.CacheDataDescriptionImpl;
|
||||
import org.hibernate.cache.spi.CacheDataDescription;
|
||||
import org.hibernate.cache.spi.EntityRegion;
|
||||
import org.hibernate.cache.spi.Region;
|
||||
|
@ -18,6 +17,8 @@ import org.hibernate.cache.spi.access.AccessType;
|
|||
import org.hibernate.test.cache.infinispan.AbstractEntityCollectionRegionTestCase;
|
||||
import org.infinispan.AdvancedCache;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
|
@ -28,10 +29,11 @@ import static org.junit.Assert.fail;
|
|||
* @since 3.5
|
||||
*/
|
||||
public class EntityRegionImplTestCase extends AbstractEntityCollectionRegionTestCase {
|
||||
private static CacheDataDescription MUTABLE_NON_VERSIONED = new CacheDataDescriptionImpl(true, false, null);
|
||||
|
||||
@Override
|
||||
protected void supportedAccessTypeTest(RegionFactory regionFactory, Properties properties) {
|
||||
EntityRegion region = regionFactory.buildEntityRegion("test", properties, null);
|
||||
EntityRegion region = regionFactory.buildEntityRegion("test", properties, MUTABLE_NON_VERSIONED);
|
||||
assertNull("Got TRANSACTIONAL",
|
||||
region.buildAccessStrategy(AccessType.TRANSACTIONAL).lockRegion());
|
||||
try {
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.cache.infinispan.entity;
|
||||
import org.hibernate.cache.spi.access.AccessType;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import org.hibernate.cache.spi.access.AccessType;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests for the "extra API" in EntityRegionAccessStrategy;
|
||||
|
@ -25,15 +25,9 @@ public class ReadOnlyExtraAPITestCase extends TransactionalExtraAPITestCase {
|
|||
return AccessType.READ_ONLY;
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
@Override
|
||||
public void testAfterUpdate() {
|
||||
try {
|
||||
getEntityAccessStrategy().afterUpdate(
|
||||
KEY, VALUE2, 1, 2, new MockSoftLock());
|
||||
fail( "Call to afterUpdate did not throw exception" );
|
||||
}
|
||||
catch (UnsupportedOperationException expected) {
|
||||
getEntityAccessStrategy().afterUpdate(KEY, VALUE2, 1, 2, new MockSoftLock());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
package org.hibernate.test.cache.infinispan.entity;
|
||||
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.cache.internal.CacheDataDescriptionImpl;
|
||||
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
|
||||
import org.hibernate.cache.spi.access.AccessType;
|
||||
import org.hibernate.cache.spi.access.EntityRegionAccessStrategy;
|
||||
|
@ -49,7 +50,7 @@ public class TransactionalExtraAPITestCase extends AbstractNonFunctionalTestCase
|
|||
// Sleep a bit to avoid concurrent FLUSH problem
|
||||
avoidConcurrentFlush();
|
||||
|
||||
accessStrategy = environment.getEntityRegion( REGION_NAME, null ).buildAccessStrategy( getAccessType() );
|
||||
accessStrategy = environment.getEntityRegion( REGION_NAME, new CacheDataDescriptionImpl(true, false, null)).buildAccessStrategy( getAccessType() );
|
||||
}
|
||||
|
||||
protected StandardServiceRegistryBuilder createStandardServiceRegistryBuilder() {
|
||||
|
|
Loading…
Reference in New Issue