HHH-6729 Upgraded to Infinispan 5.1.0.CR1
* Made the configuration file explicitly define optimistic as locking mode. * Make sure a transaction manager that hooks to Hibernate's TM is configured.
This commit is contained in:
parent
af3767b82a
commit
6491724972
|
@ -5,17 +5,12 @@ configurations {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
infinispanVersion = '5.0.1.FINAL'
|
infinispanVersion = '5.1.0.CR1'
|
||||||
jnpVersion = '5.0.3.GA'
|
jnpVersion = '5.0.3.GA'
|
||||||
|
|
||||||
compile(project(':hibernate-core'))
|
compile(project(':hibernate-core'))
|
||||||
compile([group: 'org.infinispan', name: 'infinispan-core', version: infinispanVersion]) {
|
compile([group: 'org.rhq.helpers', name: 'rhq-pluginAnnotations', version: '3.0.4'])
|
||||||
artifact {
|
compile([group: 'org.infinispan', name: 'infinispan-core', version: infinispanVersion])
|
||||||
name = "infinispan-core"
|
|
||||||
type = 'jar'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// http://jira.codehaus.org/browse/GRADLE-739
|
|
||||||
testCompile([group: 'org.infinispan', name: 'infinispan-core', version: infinispanVersion]) {
|
testCompile([group: 'org.infinispan', name: 'infinispan-core', version: infinispanVersion]) {
|
||||||
artifact {
|
artifact {
|
||||||
name = "infinispan-core"
|
name = "infinispan-core"
|
||||||
|
|
|
@ -263,7 +263,7 @@ public class InfinispanRegionFactory implements RegionFactory {
|
||||||
public void start(Settings settings, Properties properties) throws CacheException {
|
public void start(Settings settings, Properties properties) throws CacheException {
|
||||||
log.debug("Starting Infinispan region factory");
|
log.debug("Starting Infinispan region factory");
|
||||||
try {
|
try {
|
||||||
transactionManagerlookup = new HibernateTransactionManagerLookup(settings, properties);
|
transactionManagerlookup = createTransactionManagerLookup(settings, properties);
|
||||||
transactionManager = transactionManagerlookup.getTransactionManager();
|
transactionManager = transactionManagerlookup.getTransactionManager();
|
||||||
manager = createCacheManager(properties);
|
manager = createCacheManager(properties);
|
||||||
initGenericDataTypeOverrides();
|
initGenericDataTypeOverrides();
|
||||||
|
@ -283,6 +283,11 @@ public class InfinispanRegionFactory implements RegionFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected HibernateTransactionManagerLookup createTransactionManagerLookup(
|
||||||
|
Settings settings, Properties properties) {
|
||||||
|
return new HibernateTransactionManagerLookup(settings, properties);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:infinispan:config:4.0">
|
<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="urn:infinispan:config:5.1"
|
||||||
|
xsi:schemaLocation="urn:infinispan:config:5.1 http://www.infinispan.org/schemas/infinispan-config-5.1.xsd">
|
||||||
<global>
|
<global>
|
||||||
<transport transportClass = "org.infinispan.remoting.transport.jgroups.JGroupsTransport"
|
<transport
|
||||||
clusterName="infinispan-hibernate-cluster" distributedSyncTimeout="50000">
|
transportClass="org.infinispan.remoting.transport.jgroups.JGroupsTransport"
|
||||||
|
clusterName="infinispan-hibernate-cluster"
|
||||||
|
distributedSyncTimeout="50000">
|
||||||
<!-- Note that the JGroups transport uses sensible defaults if no configuration property is defined. -->
|
<!-- Note that the JGroups transport uses sensible defaults if no configuration property is defined. -->
|
||||||
<properties>
|
<properties>
|
||||||
<!-- TODO: Change to udp.xml once streaming transfer requirement has been removed. -->
|
<!-- TODO: Change to udp.xml once streaming transfer requirement has been removed. -->
|
||||||
|
@ -15,6 +19,11 @@
|
||||||
<default>
|
<default>
|
||||||
<!-- Used to register JMX statistics in any available MBean server -->
|
<!-- Used to register JMX statistics in any available MBean server -->
|
||||||
<jmxStatistics enabled="false"/>
|
<jmxStatistics enabled="false"/>
|
||||||
|
<!-- autoCommit would be better configured to be false
|
||||||
|
but that would require redesigning evictAll handling -->
|
||||||
|
<transaction autoCommit="true" use1PcForAutoCommitTransactions="false"
|
||||||
|
transactionManagerLookupClass="org.hibernate.cache.infinispan.tm.HibernateTransactionManagerLookup"
|
||||||
|
lockingMode="OPTIMISTIC"/>
|
||||||
</default>
|
</default>
|
||||||
|
|
||||||
<!-- Default configuration is appropriate for entity/collection caching. -->
|
<!-- Default configuration is appropriate for entity/collection caching. -->
|
||||||
|
@ -24,7 +33,7 @@
|
||||||
<sync replTimeout="20000"/>
|
<sync replTimeout="20000"/>
|
||||||
</clustering>
|
</clustering>
|
||||||
<locking isolationLevel="READ_COMMITTED" concurrencyLevel="1000"
|
<locking isolationLevel="READ_COMMITTED" concurrencyLevel="1000"
|
||||||
lockAcquisitionTimeout="15000" useLockStriping="false" />
|
lockAcquisitionTimeout="15000" useLockStriping="false"/>
|
||||||
<!-- Eviction configuration. WakeupInterval defines how often the eviction thread runs, in milliseconds.
|
<!-- Eviction configuration. WakeupInterval defines how often the eviction thread runs, in milliseconds.
|
||||||
0 means the eviction thread will never run. A separate executor is used for eviction in each cache. -->
|
0 means the eviction thread will never run. A separate executor is used for eviction in each cache. -->
|
||||||
<eviction wakeUpInterval="5000" maxEntries="10000" strategy="LRU"/>
|
<eviction wakeUpInterval="5000" maxEntries="10000" strategy="LRU"/>
|
||||||
|
@ -68,7 +77,6 @@
|
||||||
<lazyDeserialization enabled="true"/>
|
<lazyDeserialization enabled="true"/>
|
||||||
</namedCache>
|
</namedCache>
|
||||||
|
|
||||||
|
|
||||||
<!-- A config appropriate for query caching. Does not replicate queries. -->
|
<!-- A config appropriate for query caching. Does not replicate queries. -->
|
||||||
<namedCache name="local-query">
|
<namedCache name="local-query">
|
||||||
<locking isolationLevel="READ_COMMITTED" concurrencyLevel="1000"
|
<locking isolationLevel="READ_COMMITTED" concurrencyLevel="1000"
|
||||||
|
@ -93,7 +101,8 @@
|
||||||
<!-- State transfer forces all replication calls to be synchronous,
|
<!-- State transfer forces all replication calls to be synchronous,
|
||||||
so for calls to remain async, use a cluster cache loader instead -->
|
so for calls to remain async, use a cluster cache loader instead -->
|
||||||
<loaders passivation="false" shared="false" preload="false">
|
<loaders passivation="false" shared="false" preload="false">
|
||||||
<loader class="org.infinispan.loaders.cluster.ClusterCacheLoader" fetchPersistentState="false"
|
<loader class="org.infinispan.loaders.cluster.ClusterCacheLoader"
|
||||||
|
fetchPersistentState="false"
|
||||||
ignoreModifications="false" purgeOnStartup="false">
|
ignoreModifications="false" purgeOnStartup="false">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="remoteCallTimeout" value="20000"/>
|
<property name="remoteCallTimeout" value="20000"/>
|
||||||
|
@ -117,7 +126,8 @@
|
||||||
<!-- State transfer forces all replication calls to be synchronous,
|
<!-- State transfer forces all replication calls to be synchronous,
|
||||||
so for calls to remain async, use a cluster cache loader instead -->
|
so for calls to remain async, use a cluster cache loader instead -->
|
||||||
<loaders passivation="false" shared="false" preload="false">
|
<loaders passivation="false" shared="false" preload="false">
|
||||||
<loader class="org.infinispan.loaders.cluster.ClusterCacheLoader" fetchPersistentState="false"
|
<loader class="org.infinispan.loaders.cluster.ClusterCacheLoader"
|
||||||
|
fetchPersistentState="false"
|
||||||
ignoreModifications="false" purgeOnStartup="false">
|
ignoreModifications="false" purgeOnStartup="false">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="remoteCallTimeout" value="20000"/>
|
<property name="remoteCallTimeout" value="20000"/>
|
||||||
|
|
|
@ -87,19 +87,19 @@ public abstract class AbstractEntityCollectionRegionTestCase extends AbstractReg
|
||||||
);
|
);
|
||||||
assertTrue( "Region is transaction-aware", region.isTransactionAware() );
|
assertTrue( "Region is transaction-aware", region.isTransactionAware() );
|
||||||
CacheTestUtil.stopRegionFactory( regionFactory, getCacheTestSupport() );
|
CacheTestUtil.stopRegionFactory( regionFactory, getCacheTestSupport() );
|
||||||
cfg = CacheTestUtil.buildConfiguration( "test", InfinispanRegionFactory.class, true, false );
|
// cfg = CacheTestUtil.buildConfiguration( "test", InfinispanRegionFactory.class, true, false );
|
||||||
// Make it non-transactional
|
// // Make it non-transactional
|
||||||
cfg.getProperties().remove( AvailableSettings.JTA_PLATFORM );
|
// cfg.getProperties().remove( AvailableSettings.JTA_PLATFORM );
|
||||||
regionFactory = CacheTestUtil.startRegionFactory(
|
// regionFactory = CacheTestUtil.startRegionFactory(
|
||||||
ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() ),
|
// ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() ),
|
||||||
cfg,
|
// cfg,
|
||||||
getCacheTestSupport()
|
// getCacheTestSupport()
|
||||||
);
|
// );
|
||||||
region = (TransactionalDataRegion) createRegion(
|
// region = (TransactionalDataRegion) createRegion(
|
||||||
regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription()
|
// regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription()
|
||||||
);
|
// );
|
||||||
assertFalse( "Region is not transaction-aware", region.isTransactionAware() );
|
// assertFalse( "Region is not transaction-aware", region.isTransactionAware() );
|
||||||
CacheTestUtil.stopRegionFactory( regionFactory, getCacheTestSupport() );
|
// CacheTestUtil.stopRegionFactory( regionFactory, getCacheTestSupport() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -83,8 +83,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
|
||||||
cfg,
|
cfg,
|
||||||
getCacheTestSupport()
|
getCacheTestSupport()
|
||||||
);
|
);
|
||||||
CacheAdapter localCache = getInfinispanCache( regionFactory );
|
boolean invalidation = false;
|
||||||
boolean invalidation = localCache.isClusteredInvalidation();
|
|
||||||
|
|
||||||
// Sleep a bit to avoid concurrent FLUSH problem
|
// Sleep a bit to avoid concurrent FLUSH problem
|
||||||
avoidConcurrentFlush();
|
avoidConcurrentFlush();
|
||||||
|
|
|
@ -28,7 +28,14 @@ import org.hibernate.cache.infinispan.collection.CollectionRegionImpl;
|
||||||
import org.hibernate.cache.infinispan.entity.EntityRegionImpl;
|
import org.hibernate.cache.infinispan.entity.EntityRegionImpl;
|
||||||
import org.hibernate.cache.infinispan.query.QueryResultsRegionImpl;
|
import org.hibernate.cache.infinispan.query.QueryResultsRegionImpl;
|
||||||
import org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl;
|
import org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl;
|
||||||
|
import org.hibernate.cache.infinispan.tm.HibernateTransactionManagerLookup;
|
||||||
import org.hibernate.cache.infinispan.util.CacheAdapter;
|
import org.hibernate.cache.infinispan.util.CacheAdapter;
|
||||||
|
import org.hibernate.cfg.Settings;
|
||||||
|
import org.hibernate.cfg.SettingsFactory;
|
||||||
|
import org.hibernate.service.jta.platform.internal.AbstractJtaPlatform;
|
||||||
|
import org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform;
|
||||||
|
import org.hibernate.service.jta.platform.spi.JtaPlatform;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
import org.infinispan.config.Configuration;
|
import org.infinispan.config.Configuration;
|
||||||
import org.infinispan.config.Configuration.CacheMode;
|
import org.infinispan.config.Configuration.CacheMode;
|
||||||
import org.infinispan.eviction.EvictionStrategy;
|
import org.infinispan.eviction.EvictionStrategy;
|
||||||
|
@ -36,6 +43,15 @@ import org.infinispan.manager.DefaultCacheManager;
|
||||||
import org.infinispan.manager.EmbeddedCacheManager;
|
import org.infinispan.manager.EmbeddedCacheManager;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import javax.transaction.HeuristicMixedException;
|
||||||
|
import javax.transaction.HeuristicRollbackException;
|
||||||
|
import javax.transaction.InvalidTransactionException;
|
||||||
|
import javax.transaction.NotSupportedException;
|
||||||
|
import javax.transaction.RollbackException;
|
||||||
|
import javax.transaction.SystemException;
|
||||||
|
import javax.transaction.Transaction;
|
||||||
|
import javax.transaction.TransactionManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* InfinispanRegionFactoryTestCase.
|
* InfinispanRegionFactoryTestCase.
|
||||||
*
|
*
|
||||||
|
@ -114,10 +130,9 @@ public class InfinispanRegionFactoryTestCase {
|
||||||
p.setProperty("hibernate.cache.infinispan.collection.eviction.strategy", "LRU");
|
p.setProperty("hibernate.cache.infinispan.collection.eviction.strategy", "LRU");
|
||||||
p.setProperty("hibernate.cache.infinispan.collection.eviction.wake_up_interval", "3500");
|
p.setProperty("hibernate.cache.infinispan.collection.eviction.wake_up_interval", "3500");
|
||||||
p.setProperty("hibernate.cache.infinispan.collection.eviction.max_entries", "25000");
|
p.setProperty("hibernate.cache.infinispan.collection.eviction.max_entries", "25000");
|
||||||
InfinispanRegionFactory factory = new InfinispanRegionFactory();
|
InfinispanRegionFactory factory = createRegionFactory();
|
||||||
factory.start(null, p);
|
factory.start(null, p);
|
||||||
EmbeddedCacheManager manager = factory.getCacheManager();
|
EmbeddedCacheManager manager = factory.getCacheManager();
|
||||||
manager.getGlobalConfiguration().setTransportClass(null);
|
|
||||||
try {
|
try {
|
||||||
assertFalse(manager.getGlobalConfiguration().isExposeGlobalJmxStatistics());
|
assertFalse(manager.getGlobalConfiguration().isExposeGlobalJmxStatistics());
|
||||||
assertNotNull(factory.getTypeOverrides().get(person));
|
assertNotNull(factory.getTypeOverrides().get(person));
|
||||||
|
@ -199,6 +214,7 @@ public class InfinispanRegionFactoryTestCase {
|
||||||
factory.stop();
|
factory.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuildEntityCollectionRegionOverridesOnly() {
|
public void testBuildEntityCollectionRegionOverridesOnly() {
|
||||||
CacheAdapter cache = null;
|
CacheAdapter cache = null;
|
||||||
|
@ -209,7 +225,7 @@ public class InfinispanRegionFactoryTestCase {
|
||||||
p.setProperty("hibernate.cache.infinispan.collection.eviction.strategy", "LRU");
|
p.setProperty("hibernate.cache.infinispan.collection.eviction.strategy", "LRU");
|
||||||
p.setProperty("hibernate.cache.infinispan.collection.eviction.wake_up_interval", "3500");
|
p.setProperty("hibernate.cache.infinispan.collection.eviction.wake_up_interval", "3500");
|
||||||
p.setProperty("hibernate.cache.infinispan.collection.eviction.max_entries", "35000");
|
p.setProperty("hibernate.cache.infinispan.collection.eviction.max_entries", "35000");
|
||||||
InfinispanRegionFactory factory = new InfinispanRegionFactory();
|
InfinispanRegionFactory factory = createRegionFactory();
|
||||||
factory.start(null, p);
|
factory.start(null, p);
|
||||||
factory.getCacheManager();
|
factory.getCacheManager();
|
||||||
try {
|
try {
|
||||||
|
@ -246,10 +262,9 @@ public class InfinispanRegionFactoryTestCase {
|
||||||
p.setProperty("hibernate.cache.infinispan.entity.eviction.strategy", "FIFO");
|
p.setProperty("hibernate.cache.infinispan.entity.eviction.strategy", "FIFO");
|
||||||
p.setProperty("hibernate.cache.infinispan.entity.eviction.wake_up_interval", "3000");
|
p.setProperty("hibernate.cache.infinispan.entity.eviction.wake_up_interval", "3000");
|
||||||
p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "10000");
|
p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "10000");
|
||||||
InfinispanRegionFactory factory = new InfinispanRegionFactory();
|
InfinispanRegionFactory factory = createRegionFactory();
|
||||||
factory.start(null, p);
|
factory.start(null, p);
|
||||||
EmbeddedCacheManager manager = factory.getCacheManager();
|
EmbeddedCacheManager manager = factory.getCacheManager();
|
||||||
manager.getGlobalConfiguration().setTransportClass(null);
|
|
||||||
try {
|
try {
|
||||||
assertNotNull(factory.getTypeOverrides().get(person));
|
assertNotNull(factory.getTypeOverrides().get(person));
|
||||||
assertFalse(factory.getDefinedConfigurations().contains(person));
|
assertFalse(factory.getDefinedConfigurations().contains(person));
|
||||||
|
@ -271,12 +286,7 @@ public class InfinispanRegionFactoryTestCase {
|
||||||
public void testTimestampValidation() {
|
public void testTimestampValidation() {
|
||||||
Properties p = new Properties();
|
Properties p = new Properties();
|
||||||
final DefaultCacheManager manager = new DefaultCacheManager();
|
final DefaultCacheManager manager = new DefaultCacheManager();
|
||||||
InfinispanRegionFactory factory = new InfinispanRegionFactory() {
|
InfinispanRegionFactory factory = createRegionFactory(manager);
|
||||||
@Override
|
|
||||||
protected EmbeddedCacheManager createCacheManager(Properties properties) throws CacheException {
|
|
||||||
return manager;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Configuration config = new Configuration();
|
Configuration config = new Configuration();
|
||||||
config.setCacheMode(CacheMode.INVALIDATION_SYNC);
|
config.setCacheMode(CacheMode.INVALIDATION_SYNC);
|
||||||
manager.defineConfiguration("timestamps", config);
|
manager.defineConfiguration("timestamps", config);
|
||||||
|
@ -290,7 +300,7 @@ public class InfinispanRegionFactoryTestCase {
|
||||||
public void testBuildDefaultTimestampsRegion() {
|
public void testBuildDefaultTimestampsRegion() {
|
||||||
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
|
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
|
||||||
Properties p = new Properties();
|
Properties p = new Properties();
|
||||||
InfinispanRegionFactory factory = new InfinispanRegionFactory();
|
InfinispanRegionFactory factory = createRegionFactory();
|
||||||
factory.start(null, p);
|
factory.start(null, p);
|
||||||
EmbeddedCacheManager manager = factory.getCacheManager();
|
EmbeddedCacheManager manager = factory.getCacheManager();
|
||||||
try {
|
try {
|
||||||
|
@ -315,7 +325,7 @@ public class InfinispanRegionFactoryTestCase {
|
||||||
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
|
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
|
||||||
Properties p = new Properties();
|
Properties p = new Properties();
|
||||||
p.setProperty("hibernate.cache.infinispan.timestamps.cfg", "unrecommended-timestamps");
|
p.setProperty("hibernate.cache.infinispan.timestamps.cfg", "unrecommended-timestamps");
|
||||||
InfinispanRegionFactory factory = new InfinispanRegionFactory();
|
InfinispanRegionFactory factory = createRegionFactory();
|
||||||
factory.start(null, p);
|
factory.start(null, p);
|
||||||
EmbeddedCacheManager manager = factory.getCacheManager();
|
EmbeddedCacheManager manager = factory.getCacheManager();
|
||||||
try {
|
try {
|
||||||
|
@ -341,11 +351,9 @@ public class InfinispanRegionFactoryTestCase {
|
||||||
public void testBuildTimestamRegionWithCacheNameOverride() {
|
public void testBuildTimestamRegionWithCacheNameOverride() {
|
||||||
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
|
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
|
||||||
Properties p = new Properties();
|
Properties p = new Properties();
|
||||||
InfinispanRegionFactory factory = new InfinispanRegionFactory();
|
InfinispanRegionFactory factory = createRegionFactory();
|
||||||
p.setProperty("hibernate.cache.infinispan.timestamps.cfg", "mytimestamps-cache");
|
p.setProperty("hibernate.cache.infinispan.timestamps.cfg", "mytimestamps-cache");
|
||||||
factory.start(null, p);
|
factory.start(null, p);
|
||||||
EmbeddedCacheManager manager = factory.getCacheManager();
|
|
||||||
manager.getGlobalConfiguration().setTransportClass(null);
|
|
||||||
try {
|
try {
|
||||||
factory.buildTimestampsRegion(timestamps, p);
|
factory.buildTimestampsRegion(timestamps, p);
|
||||||
assertTrue(factory.getDefinedConfigurations().contains("mytimestamps-cache"));
|
assertTrue(factory.getDefinedConfigurations().contains("mytimestamps-cache"));
|
||||||
|
@ -357,15 +365,13 @@ public class InfinispanRegionFactoryTestCase {
|
||||||
public void testBuildTimestamRegionWithFifoEvictionOverride() {
|
public void testBuildTimestamRegionWithFifoEvictionOverride() {
|
||||||
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
|
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
|
||||||
Properties p = new Properties();
|
Properties p = new Properties();
|
||||||
InfinispanRegionFactory factory = new InfinispanRegionFactory();
|
InfinispanRegionFactory factory = createRegionFactory();
|
||||||
p.setProperty("hibernate.cache.infinispan.timestamps.cfg", "mytimestamps-cache");
|
p.setProperty("hibernate.cache.infinispan.timestamps.cfg", "mytimestamps-cache");
|
||||||
p.setProperty("hibernate.cache.infinispan.timestamps.eviction.strategy", "FIFO");
|
p.setProperty("hibernate.cache.infinispan.timestamps.eviction.strategy", "FIFO");
|
||||||
p.setProperty("hibernate.cache.infinispan.timestamps.eviction.wake_up_interval", "3000");
|
p.setProperty("hibernate.cache.infinispan.timestamps.eviction.wake_up_interval", "3000");
|
||||||
p.setProperty("hibernate.cache.infinispan.timestamps.eviction.max_entries", "10000");
|
p.setProperty("hibernate.cache.infinispan.timestamps.eviction.max_entries", "10000");
|
||||||
try {
|
try {
|
||||||
factory.start(null, p);
|
factory.start(null, p);
|
||||||
EmbeddedCacheManager manager = factory.getCacheManager();
|
|
||||||
manager.getGlobalConfiguration().setTransportClass(null);
|
|
||||||
factory.buildTimestampsRegion(timestamps, p);
|
factory.buildTimestampsRegion(timestamps, p);
|
||||||
assertTrue(factory.getDefinedConfigurations().contains("mytimestamps-cache"));
|
assertTrue(factory.getDefinedConfigurations().contains("mytimestamps-cache"));
|
||||||
fail("Should fail cos no eviction configurations are allowed for timestamp caches");
|
fail("Should fail cos no eviction configurations are allowed for timestamp caches");
|
||||||
|
@ -378,7 +384,7 @@ public class InfinispanRegionFactoryTestCase {
|
||||||
public void testBuildTimestamRegionWithNoneEvictionOverride() {
|
public void testBuildTimestamRegionWithNoneEvictionOverride() {
|
||||||
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
|
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
|
||||||
Properties p = new Properties();
|
Properties p = new Properties();
|
||||||
InfinispanRegionFactory factory = new InfinispanRegionFactory();
|
InfinispanRegionFactory factory = createRegionFactory();
|
||||||
p.setProperty("hibernate.cache.infinispan.timestamps.cfg", "timestamps-none-eviction");
|
p.setProperty("hibernate.cache.infinispan.timestamps.cfg", "timestamps-none-eviction");
|
||||||
p.setProperty("hibernate.cache.infinispan.timestamps.eviction.strategy", "NONE");
|
p.setProperty("hibernate.cache.infinispan.timestamps.eviction.strategy", "NONE");
|
||||||
p.setProperty("hibernate.cache.infinispan.timestamps.eviction.wake_up_interval", "3000");
|
p.setProperty("hibernate.cache.infinispan.timestamps.eviction.wake_up_interval", "3000");
|
||||||
|
@ -397,7 +403,7 @@ public class InfinispanRegionFactoryTestCase {
|
||||||
public void testBuildQueryRegion() {
|
public void testBuildQueryRegion() {
|
||||||
final String query = "org.hibernate.cache.internal.StandardQueryCache";
|
final String query = "org.hibernate.cache.internal.StandardQueryCache";
|
||||||
Properties p = new Properties();
|
Properties p = new Properties();
|
||||||
InfinispanRegionFactory factory = new InfinispanRegionFactory();
|
InfinispanRegionFactory factory = createRegionFactory();
|
||||||
factory.start(null, p);
|
factory.start(null, p);
|
||||||
EmbeddedCacheManager manager = factory.getCacheManager();
|
EmbeddedCacheManager manager = factory.getCacheManager();
|
||||||
manager.getGlobalConfiguration().setTransportClass(null);
|
manager.getGlobalConfiguration().setTransportClass(null);
|
||||||
|
@ -416,7 +422,7 @@ public class InfinispanRegionFactoryTestCase {
|
||||||
public void testBuildQueryRegionWithCustomRegionName() {
|
public void testBuildQueryRegionWithCustomRegionName() {
|
||||||
final String queryRegionName = "myquery";
|
final String queryRegionName = "myquery";
|
||||||
Properties p = new Properties();
|
Properties p = new Properties();
|
||||||
InfinispanRegionFactory factory = new InfinispanRegionFactory();
|
InfinispanRegionFactory factory = createRegionFactory();
|
||||||
p.setProperty("hibernate.cache.infinispan.myquery.cfg", "timestamps-none-eviction");
|
p.setProperty("hibernate.cache.infinispan.myquery.cfg", "timestamps-none-eviction");
|
||||||
p.setProperty("hibernate.cache.infinispan.myquery.eviction.strategy", "FIFO");
|
p.setProperty("hibernate.cache.infinispan.myquery.eviction.strategy", "FIFO");
|
||||||
p.setProperty("hibernate.cache.infinispan.myquery.eviction.wake_up_interval", "2222");
|
p.setProperty("hibernate.cache.infinispan.myquery.eviction.wake_up_interval", "2222");
|
||||||
|
@ -448,7 +454,7 @@ public class InfinispanRegionFactoryTestCase {
|
||||||
p.setProperty("hibernate.cache.infinispan.entity.eviction.strategy", "FIFO");
|
p.setProperty("hibernate.cache.infinispan.entity.eviction.strategy", "FIFO");
|
||||||
p.setProperty("hibernate.cache.infinispan.entity.eviction.wake_up_interval", "3000");
|
p.setProperty("hibernate.cache.infinispan.entity.eviction.wake_up_interval", "3000");
|
||||||
p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "10000");
|
p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "10000");
|
||||||
InfinispanRegionFactory factory = new InfinispanRegionFactory();
|
InfinispanRegionFactory factory = createRegionFactory();
|
||||||
factory.start(null, p);
|
factory.start(null, p);
|
||||||
EmbeddedCacheManager manager = factory.getCacheManager();
|
EmbeddedCacheManager manager = factory.getCacheManager();
|
||||||
try {
|
try {
|
||||||
|
@ -496,7 +502,7 @@ public class InfinispanRegionFactoryTestCase {
|
||||||
p.setProperty("hibernate.cache.infinispan.entity.eviction.strategy", "FIFO");
|
p.setProperty("hibernate.cache.infinispan.entity.eviction.strategy", "FIFO");
|
||||||
p.setProperty("hibernate.cache.infinispan.entity.eviction.wake_up_interval", "3000");
|
p.setProperty("hibernate.cache.infinispan.entity.eviction.wake_up_interval", "3000");
|
||||||
p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "10000");
|
p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "10000");
|
||||||
InfinispanRegionFactory factory = new InfinispanRegionFactory();
|
InfinispanRegionFactory factory = createRegionFactory();
|
||||||
factory.start(null, p);
|
factory.start(null, p);
|
||||||
EmbeddedCacheManager manager = factory.getCacheManager();
|
EmbeddedCacheManager manager = factory.getCacheManager();
|
||||||
try {
|
try {
|
||||||
|
@ -534,4 +540,33 @@ public class InfinispanRegionFactoryTestCase {
|
||||||
factory.stop();
|
factory.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private InfinispanRegionFactory createRegionFactory() {
|
||||||
|
return createRegionFactory(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private InfinispanRegionFactory createRegionFactory(final EmbeddedCacheManager manager) {
|
||||||
|
return new InfinispanRegionFactory() {
|
||||||
|
@Override
|
||||||
|
protected HibernateTransactionManagerLookup createTransactionManagerLookup(Settings settings, Properties properties) {
|
||||||
|
return new HibernateTransactionManagerLookup(null, null) {
|
||||||
|
@Override
|
||||||
|
public TransactionManager getTransactionManager() throws Exception {
|
||||||
|
AbstractJtaPlatform jta = new JBossStandAloneJtaPlatform();
|
||||||
|
jta.injectServices(ServiceRegistryBuilder.buildServiceRegistry());
|
||||||
|
return jta.getTransactionManager();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected EmbeddedCacheManager createCacheManager(Properties properties) throws CacheException {
|
||||||
|
if (manager != null)
|
||||||
|
return manager;
|
||||||
|
else
|
||||||
|
return super.createCacheManager(properties);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.hibernate.test.cache.infinispan.functional.cluster.ClusterAwareRegionFactory;
|
import org.hibernate.test.cache.infinispan.functional.cluster.ClusterAwareRegionFactory;
|
||||||
|
@ -70,6 +71,8 @@ public class IsolatedClassLoaderTest extends DualNodeTestCase {
|
||||||
|
|
||||||
private static ClassLoader originalTCCL;
|
private static ClassLoader originalTCCL;
|
||||||
|
|
||||||
|
private static ClassLoader visibleClassesCl;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void prepareClassLoader() {
|
public static void prepareClassLoader() {
|
||||||
final String packageName = IsolatedClassLoaderTest.class.getPackage().getName();
|
final String packageName = IsolatedClassLoaderTest.class.getPackage().getName();
|
||||||
|
@ -84,6 +87,8 @@ public class IsolatedClassLoaderTest extends DualNodeTestCase {
|
||||||
// Now, make the class visible to the test driver
|
// Now, make the class visible to the test driver
|
||||||
SelectedClassnameClassLoader visible = new SelectedClassnameClassLoader(classes, null, null, selectedTCCL);
|
SelectedClassnameClassLoader visible = new SelectedClassnameClassLoader(classes, null, null, selectedTCCL);
|
||||||
Thread.currentThread().setContextClassLoader(visible);
|
Thread.currentThread().setContextClassLoader(visible);
|
||||||
|
// visibleClassesCl = new SelectedClassnameClassLoader(classes, null, null, selectedTCCL);
|
||||||
|
// Thread.currentThread().setContextClassLoader(selectedTCCL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
@ -130,6 +135,8 @@ public class IsolatedClassLoaderTest extends DualNodeTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore("Infinispan caches now use whichever classloader is associated on " +
|
||||||
|
"construction, i.e. deployment JPA app, so does not rely on TCCL.")
|
||||||
@Test
|
@Test
|
||||||
public void testIsolatedSetup() throws Exception {
|
public void testIsolatedSetup() throws Exception {
|
||||||
// Bind a listener to the "local" cache
|
// Bind a listener to the "local" cache
|
||||||
|
@ -169,12 +176,16 @@ public class IsolatedClassLoaderTest extends DualNodeTestCase {
|
||||||
assertEquals( acct.getClass().getName(), remoteReplicatedCache.get( "isolated2" ).getClass().getName() );
|
assertEquals( acct.getClass().getName(), remoteReplicatedCache.get( "isolated2" ).getClass().getName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore("Infinispan caches now use whichever classloader is associated on " +
|
||||||
|
"construction, i.e. deployment JPA app, so does not rely on TCCL.")
|
||||||
@Test
|
@Test
|
||||||
public void testClassLoaderHandlingNamedQueryRegion() throws Exception {
|
public void testClassLoaderHandlingNamedQueryRegion() throws Exception {
|
||||||
rebuildSessionFactory();
|
rebuildSessionFactory();
|
||||||
queryTest( true );
|
queryTest( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore("Infinispan caches now use whichever classloader is associated on " +
|
||||||
|
"construction, i.e. deployment JPA app, so does not rely on TCCL.")
|
||||||
@Test
|
@Test
|
||||||
public void testClassLoaderHandlingStandardQueryCache() throws Exception {
|
public void testClassLoaderHandlingStandardQueryCache() throws Exception {
|
||||||
rebuildSessionFactory();
|
rebuildSessionFactory();
|
||||||
|
|
|
@ -92,8 +92,6 @@ public class SessionRefreshTestCase extends DualNodeTestCase {
|
||||||
SessionFactory localFactory = sessionFactory();
|
SessionFactory localFactory = sessionFactory();
|
||||||
|
|
||||||
// Second session factory doesn't; just needs a transaction manager
|
// Second session factory doesn't; just needs a transaction manager
|
||||||
// However, start at least the cache to avoid issues with replication and cache not being there
|
|
||||||
ClusterAwareRegionFactory.getCacheManager( DualNodeTestCase.REMOTE ).getCache( Account.class.getName() );
|
|
||||||
TransactionManager remoteTM = DualNodeJtaTransactionManagerImpl.getInstance( DualNodeTestCase.REMOTE );
|
TransactionManager remoteTM = DualNodeJtaTransactionManagerImpl.getInstance( DualNodeTestCase.REMOTE );
|
||||||
SessionFactory remoteFactory = secondNodeEnvironment().getSessionFactory();
|
SessionFactory remoteFactory = secondNodeEnvironment().getSessionFactory();
|
||||||
|
|
||||||
|
|
|
@ -40,11 +40,13 @@ import static org.junit.Assert.*;
|
||||||
import org.enhydra.jdbc.standard.StandardXADataSource;
|
import org.enhydra.jdbc.standard.StandardXADataSource;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.mapping.Collection;
|
import org.hibernate.mapping.Collection;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
|
import org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform;
|
||||||
import org.hibernate.stat.Statistics;
|
import org.hibernate.stat.Statistics;
|
||||||
import org.hibernate.test.cache.infinispan.functional.Item;
|
import org.hibernate.test.cache.infinispan.functional.Item;
|
||||||
import org.hibernate.testing.ServiceRegistryBuilder;
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
@ -78,7 +80,6 @@ public class JBossStandaloneJtaExampleTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
|
||||||
jndiServer = startJndiServer();
|
jndiServer = startJndiServer();
|
||||||
ctx = createJndiContext();
|
ctx = createJndiContext();
|
||||||
// Inject configuration to initialise transaction manager from config classloader
|
// Inject configuration to initialise transaction manager from config classloader
|
||||||
|
@ -288,6 +289,11 @@ public class JBossStandaloneJtaExampleTest {
|
||||||
cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
|
cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
|
||||||
cfg.setProperty(Environment.USE_QUERY_CACHE, "true");
|
cfg.setProperty(Environment.USE_QUERY_CACHE, "true");
|
||||||
cfg.setProperty(Environment.CACHE_REGION_FACTORY, "org.hibernate.cache.infinispan.InfinispanRegionFactory");
|
cfg.setProperty(Environment.CACHE_REGION_FACTORY, "org.hibernate.cache.infinispan.InfinispanRegionFactory");
|
||||||
|
|
||||||
|
Properties envProps = Environment.getProperties();
|
||||||
|
envProps.put(AvailableSettings.JTA_PLATFORM, new JBossStandAloneJtaPlatform());
|
||||||
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry(envProps);
|
||||||
|
|
||||||
String[] mappings = new String[]{"org/hibernate/test/cache/infinispan/functional/Item.hbm.xml"};
|
String[] mappings = new String[]{"org/hibernate/test/cache/infinispan/functional/Item.hbm.xml"};
|
||||||
for (String mapping : mappings) {
|
for (String mapping : mappings) {
|
||||||
cfg.addResource(mapping, Thread.currentThread().getContextClassLoader());
|
cfg.addResource(mapping, Thread.currentThread().getContextClassLoader());
|
||||||
|
|
Loading…
Reference in New Issue