HHH-10272 Make pending-puts cache template configurable

* also set pending-puts cache to use simple cache
This commit is contained in:
Radim Vansa 2015-11-11 17:00:10 -05:00 committed by Steve Ebersole
parent c2abc5c289
commit 9584a7b060
19 changed files with 182 additions and 57 deletions

View File

@ -57,6 +57,7 @@ import org.infinispan.commons.util.Util;
import org.infinispan.configuration.cache.CacheMode;
import org.infinispan.configuration.cache.Configuration;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.configuration.cache.ExpirationConfiguration;
import org.infinispan.configuration.parsing.ConfigurationBuilderHolder;
import org.infinispan.configuration.parsing.ParserRegistry;
import org.infinispan.factories.GlobalComponentRegistry;
@ -64,7 +65,6 @@ import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.transaction.TransactionMode;
import org.infinispan.transaction.lookup.GenericTransactionManagerLookup;
import org.infinispan.util.concurrent.IsolationLevel;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
@ -216,13 +216,13 @@ public class InfinispanRegionFactory implements RegionFactory {
* Locking is still required since the putFromLoad validator
* code uses conditional operations (i.e. putIfAbsent)
*/
public static final Configuration PENDING_PUTS_CACHE_CONFIGURATION = new ConfigurationBuilder()
.clustering().cacheMode(CacheMode.LOCAL)
public static final Configuration DEFAULT_PENDING_PUTS_CACHE_CONFIGURATION = new ConfigurationBuilder()
.clustering().cacheMode(CacheMode.LOCAL).simpleCache(true)
.transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL)
.expiration().maxIdle(TimeUnit.SECONDS.toMillis(60))
.storeAsBinary().enabled(false)
.locking().isolationLevel(IsolationLevel.READ_COMMITTED)
.jmxStatistics().disable().build();
.jmxStatistics().enabled(false).available(false).build();
private Configuration pendingPutsCacheConfiguration;
private EmbeddedCacheManager manager;
@ -384,7 +384,24 @@ public class InfinispanRegionFactory implements RegionFactory {
}
}
defineGenericDataTypeCacheConfigurations( properties );
manager.defineConfiguration( PENDING_PUTS_CACHE_NAME, PENDING_PUTS_CACHE_CONFIGURATION );
pendingPutsCacheConfiguration = manager.getCacheConfiguration(PENDING_PUTS_CACHE_NAME);
if (pendingPutsCacheConfiguration == null) {
// We need this configuration to be in place, so this is a fallback if the user did not define it
pendingPutsCacheConfiguration = DEFAULT_PENDING_PUTS_CACHE_CONFIGURATION;
manager.defineConfiguration(PENDING_PUTS_CACHE_NAME, pendingPutsCacheConfiguration);
}
else {
if (pendingPutsCacheConfiguration.clustering().cacheMode().isClustered()) {
throw new IllegalStateException("Pending-puts cache must not be clustered!");
}
if (pendingPutsCacheConfiguration.transaction().transactionMode().isTransactional()) {
throw new IllegalStateException("Pending-puts cache must not be transactional!");
}
ExpirationConfiguration expiration = pendingPutsCacheConfiguration.expiration();
if (expiration.maxIdle() <= 0 && expiration.lifespan() <= 0) {
log.warn("Pending-puts cache should expire old entries");
}
}
}
catch (CacheException ce) {
throw ce;
@ -725,4 +742,8 @@ public class InfinispanRegionFactory implements RegionFactory {
}
return override;
}
public Configuration getPendingPutsCacheConfiguration() {
return pendingPutsCacheConfiguration;
}
}

View File

@ -7,12 +7,12 @@
package org.hibernate.cache.infinispan.collection;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cache.infinispan.access.AccessDelegate;
import org.hibernate.cache.infinispan.impl.BaseTransactionalDataRegion;
import org.hibernate.cache.spi.CacheDataDescription;
import org.hibernate.cache.spi.CacheKeysFactory;
import org.hibernate.cache.spi.CollectionRegion;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy;
import org.infinispan.AdvancedCache;
@ -39,7 +39,7 @@ public class CollectionRegionImpl extends BaseTransactionalDataRegion implements
*/
public CollectionRegionImpl(
AdvancedCache cache, String name, TransactionManager transactionManager,
CacheDataDescription metadata, RegionFactory factory, CacheKeysFactory cacheKeysFactory) {
CacheDataDescription metadata, InfinispanRegionFactory factory, CacheKeysFactory cacheKeysFactory) {
super( cache, name, transactionManager, metadata, factory, cacheKeysFactory );
}

View File

@ -7,12 +7,12 @@
package org.hibernate.cache.infinispan.entity;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cache.infinispan.access.AccessDelegate;
import org.hibernate.cache.infinispan.impl.BaseTransactionalDataRegion;
import org.hibernate.cache.spi.CacheDataDescription;
import org.hibernate.cache.spi.CacheKeysFactory;
import org.hibernate.cache.spi.EntityRegion;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cache.spi.access.EntityRegionAccessStrategy;
@ -40,7 +40,7 @@ public class EntityRegionImpl extends BaseTransactionalDataRegion implements Ent
*/
public EntityRegionImpl(
AdvancedCache cache, String name, TransactionManager transactionManager,
CacheDataDescription metadata, RegionFactory factory, CacheKeysFactory cacheKeysFactory) {
CacheDataDescription metadata, InfinispanRegionFactory factory, CacheKeysFactory cacheKeysFactory) {
super( cache, name, transactionManager, metadata, factory, cacheKeysFactory);
}

View File

@ -7,9 +7,9 @@
package org.hibernate.cache.infinispan.impl;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cache.infinispan.util.Caches;
import org.hibernate.cache.spi.GeneralDataRegion;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.engine.spi.SessionImplementor;
import org.infinispan.AdvancedCache;
@ -33,7 +33,7 @@ public abstract class BaseGeneralDataRegion extends BaseRegion implements Genera
*/
public BaseGeneralDataRegion(
AdvancedCache cache, String name,
RegionFactory factory) {
InfinispanRegionFactory factory) {
super( cache, name, null, factory );
this.putCache = Caches.ignoreReturnValuesCache( cache );
}

View File

@ -8,16 +8,15 @@ package org.hibernate.cache.infinispan.impl;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.infinispan.access.PutFromLoadValidator;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cache.infinispan.util.Caches;
import org.hibernate.cache.spi.Region;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.access.AccessType;
import org.infinispan.AdvancedCache;
@ -42,7 +41,7 @@ public abstract class BaseRegion implements Region {
protected final AdvancedCache cache;
protected final AdvancedCache localAndSkipLoadCache;
protected final TransactionManager tm;
private final RegionFactory factory;
protected final InfinispanRegionFactory factory;
protected volatile long lastRegionInvalidation = Long.MIN_VALUE;
protected int invalidations = 0;
@ -55,7 +54,7 @@ public abstract class BaseRegion implements Region {
* @param transactionManager transaction manager may be needed even for non-transactional caches.
* @param factory for this region
*/
public BaseRegion(AdvancedCache cache, String name, TransactionManager transactionManager, RegionFactory factory) {
public BaseRegion(AdvancedCache cache, String name, TransactionManager transactionManager, InfinispanRegionFactory factory) {
this.cache = cache;
this.name = name;
this.tm = transactionManager;
@ -254,4 +253,8 @@ public abstract class BaseRegion implements Region {
localAndSkipLoadCache.clear();
}
}
public InfinispanRegionFactory getRegionFactory() {
return factory;
}
}

View File

@ -21,7 +21,6 @@ import org.hibernate.cache.infinispan.util.Tombstone;
import org.hibernate.cache.infinispan.util.VersionedEntry;
import org.hibernate.cache.spi.CacheDataDescription;
import org.hibernate.cache.spi.CacheKeysFactory;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.TransactionalDataRegion;
import org.hibernate.cache.spi.access.AccessType;
@ -79,7 +78,7 @@ public abstract class BaseTransactionalDataRegion
*/
public BaseTransactionalDataRegion(
AdvancedCache cache, String name, TransactionManager transactionManager,
CacheDataDescription metadata, RegionFactory factory, CacheKeysFactory cacheKeysFactory) {
CacheDataDescription metadata, InfinispanRegionFactory factory, CacheKeysFactory cacheKeysFactory) {
super( cache, name, transactionManager, factory);
this.metadata = metadata;
this.cacheKeysFactory = cacheKeysFactory;
@ -87,8 +86,7 @@ public abstract class BaseTransactionalDataRegion
Configuration configuration = cache.getCacheConfiguration();
requiresTransaction = configuration.transaction().transactionMode().isTransactional()
&& !configuration.transaction().autoCommit();
// TODO: make these timeouts configurable
tombstoneExpiration = InfinispanRegionFactory.PENDING_PUTS_CACHE_CONFIGURATION.expiration().maxIdle();
tombstoneExpiration = factory.getPendingPutsCacheConfiguration().expiration().maxIdle();
if (!isRegionAccessStrategyEnabled()) {
strategy = Strategy.NONE;
}

View File

@ -7,12 +7,12 @@
package org.hibernate.cache.infinispan.naturalid;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cache.infinispan.access.AccessDelegate;
import org.hibernate.cache.infinispan.impl.BaseTransactionalDataRegion;
import org.hibernate.cache.spi.CacheDataDescription;
import org.hibernate.cache.spi.CacheKeysFactory;
import org.hibernate.cache.spi.NaturalIdRegion;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy;
import org.infinispan.AdvancedCache;
@ -40,7 +40,7 @@ public class NaturalIdRegionImpl extends BaseTransactionalDataRegion
*/
public NaturalIdRegionImpl(
AdvancedCache cache, String name, TransactionManager transactionManager,
CacheDataDescription metadata, RegionFactory factory, CacheKeysFactory cacheKeysFactory) {
CacheDataDescription metadata, InfinispanRegionFactory factory, CacheKeysFactory cacheKeysFactory) {
super( cache, name, transactionManager, metadata, factory, cacheKeysFactory );
}

View File

@ -10,11 +10,11 @@ import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cache.infinispan.impl.BaseTransactionalDataRegion;
import org.hibernate.cache.infinispan.util.Caches;
import org.hibernate.cache.infinispan.util.InvocationAfterCompletion;
import org.hibernate.cache.spi.QueryResultsRegion;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.resource.transaction.TransactionCoordinator;
import org.infinispan.AdvancedCache;
@ -52,7 +52,7 @@ public class QueryResultsRegionImpl extends BaseTransactionalDataRegion implemen
* @param name of the query region
* @param factory for the query region
*/
public QueryResultsRegionImpl(AdvancedCache cache, String name, TransactionManager transactionManager, RegionFactory factory) {
public QueryResultsRegionImpl(AdvancedCache cache, String name, TransactionManager transactionManager, InfinispanRegionFactory factory) {
super( cache, name, transactionManager, null, factory, null );
// If Infinispan is using INVALIDATION for query cache, we don't want to propagate changes.
// We use the Timestamps cache to manage invalidation

View File

@ -11,15 +11,12 @@ import java.util.concurrent.ConcurrentHashMap;
import javax.transaction.Transaction;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cache.infinispan.util.Caches;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.engine.spi.SessionImplementor;
import org.infinispan.AdvancedCache;
import org.infinispan.CacheSet;
import org.infinispan.commons.util.CloseableIterable;
import org.infinispan.commons.util.CloseableIterator;
import org.infinispan.container.entries.CacheEntry;
import org.infinispan.context.Flag;
import org.infinispan.notifications.Listener;
import org.infinispan.notifications.cachelistener.annotation.CacheEntryModified;
@ -53,7 +50,7 @@ public class ClusteredTimestampsRegionImpl extends TimestampsRegionImpl {
*/
public ClusteredTimestampsRegionImpl(
AdvancedCache cache,
String name, RegionFactory factory) {
String name, InfinispanRegionFactory factory) {
super( cache, name, factory );
cache.addListener( this );
populateLocalCache();

View File

@ -9,9 +9,9 @@ package org.hibernate.cache.infinispan.timestamp;
import javax.transaction.Transaction;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cache.infinispan.impl.BaseGeneralDataRegion;
import org.hibernate.cache.infinispan.util.Caches;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.TimestampsRegion;
import org.hibernate.engine.spi.SessionImplementor;
@ -39,7 +39,7 @@ public class TimestampsRegionImpl extends BaseGeneralDataRegion implements Times
*/
public TimestampsRegionImpl(
AdvancedCache cache, String name,
RegionFactory factory) {
InfinispanRegionFactory factory) {
super( cache, name, factory );
this.removeCache = Caches.ignoreReturnValuesCache( cache );

View File

@ -53,6 +53,12 @@
<eviction strategy="NONE"/>
<expiration interval="0"/>
</replicated-cache-configuration>
<!-- This configuration should match to InfinispanRegionFactory.DEFAULT_PENDING_PUTS_CACHE_CONFIGURATION -->
<local-cache-configuration name="pending-puts" statistics="false" statistics-available="false" simple-cache="true">
<transaction mode="NONE"/>
<expiration max-idle="60000" />
</local-cache-configuration>
</cache-container>
</infinispan>

View File

@ -44,12 +44,7 @@ import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.test.TestingUtil;
import org.infinispan.transaction.TransactionMode;
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 static org.junit.Assert.*;
/**
* InfinispanRegionFactoryTestCase.
@ -564,6 +559,37 @@ public class InfinispanRegionFactoryTestCase {
}
}
@Test
public void testDefaultPendingPutsCache() {
Properties p = createProperties();
InfinispanRegionFactory factory = createRegionFactory(p);
try {
Configuration ppConfig = factory.getPendingPutsCacheConfiguration();
// workaround for ISPN-5950
ConfigurationBuilder cb = new ConfigurationBuilder().read(ppConfig);
cb.transaction().useSynchronization(false);
ppConfig = cb.build();
assertEquals(InfinispanRegionFactory.DEFAULT_PENDING_PUTS_CACHE_CONFIGURATION, ppConfig);
} finally {
factory.stop();
}
}
@Test
public void testCustomPendingPutsCache() {
Properties p = createProperties();
p.setProperty(InfinispanRegionFactory.INFINISPAN_CONFIG_RESOURCE_PROP, "alternative-infinispan-configs.xml");
InfinispanRegionFactory factory = createRegionFactory(p);
try {
Configuration ppConfig = factory.getPendingPutsCacheConfiguration();
assertEquals(120000, ppConfig.expiration().maxIdle());
assertNotEquals(120000, InfinispanRegionFactory.DEFAULT_PENDING_PUTS_CACHE_CONFIGURATION.expiration().maxIdle());
} finally {
factory.stop();
}
}
private InfinispanRegionFactory createRegionFactory(Properties p) {
return createRegionFactory(null, p);
}

View File

@ -80,7 +80,7 @@ public class PutFromLoadValidatorUnitTest {
private static EmbeddedCacheManager createCacheManager() {
EmbeddedCacheManager cacheManager = TestCacheManagerFactory.createCacheManager(false);
cacheManager.defineConfiguration(InfinispanRegionFactory.PENDING_PUTS_CACHE_NAME,
InfinispanRegionFactory.PENDING_PUTS_CACHE_CONFIGURATION);
InfinispanRegionFactory.DEFAULT_PENDING_PUTS_CACHE_CONFIGURATION);
return cacheManager;
}
@ -513,7 +513,7 @@ public class PutFromLoadValidatorUnitTest {
@TestForIssue(jiraKey = "HHH-9928")
public void testGetForNullReleasePuts() {
EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(false);
ConfigurationBuilder cb = new ConfigurationBuilder().read(InfinispanRegionFactory.PENDING_PUTS_CACHE_CONFIGURATION);
ConfigurationBuilder cb = new ConfigurationBuilder().read(InfinispanRegionFactory.DEFAULT_PENDING_PUTS_CACHE_CONFIGURATION);
cb.expiration().maxIdle(500);
cm.defineConfiguration(InfinispanRegionFactory.PENDING_PUTS_CACHE_NAME, cb.build());
withCacheManager(new CacheManagerCallable(cm) {

View File

@ -77,7 +77,7 @@ public class CollectionRegionAccessStrategyTest extends
public void doPutFromLoadRemoveDoesNotProduceStaleDataInvalidation() {
final CountDownLatch pferLatch = new CountDownLatch( 1 );
final CountDownLatch removeLatch = new CountDownLatch( 1 );
withCacheManager(new CacheManagerCallable(createCacheManager()) {
withCacheManager(new CacheManagerCallable(createCacheManager(localRegion.getRegionFactory())) {
@Override
public void call() {
PutFromLoadValidator validator = getPutFromLoadValidator(remoteRegion.getCache(), cm, removeLatch, pferLatch);
@ -126,10 +126,10 @@ public class CollectionRegionAccessStrategyTest extends
});
}
private static EmbeddedCacheManager createCacheManager() {
private static EmbeddedCacheManager createCacheManager(InfinispanRegionFactory regionFactory) {
EmbeddedCacheManager cacheManager = TestCacheManagerFactory.createCacheManager(false);
cacheManager.defineConfiguration(InfinispanRegionFactory.PENDING_PUTS_CACHE_NAME,
InfinispanRegionFactory.PENDING_PUTS_CACHE_CONFIGURATION);
regionFactory.getPendingPutsCacheConfiguration());
return cacheManager;
}

View File

@ -2,7 +2,6 @@ package org.hibernate.test.cache.infinispan.functional;
import org.hibernate.PessimisticLockException;
import org.hibernate.StaleStateException;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cache.infinispan.entity.EntityRegionImpl;
import org.hibernate.cache.infinispan.util.Caches;
import org.hibernate.cache.spi.Region;
@ -37,7 +36,6 @@ import static org.junit.Assert.assertEquals;
* @author Radim Vansa &lt;rvansa@redhat.com&gt;
*/
public abstract class AbstractNonInvalidationTest extends SingleNodeTest {
protected static final long TIMEOUT = InfinispanRegionFactory.PENDING_PUTS_CACHE_CONFIGURATION.expiration().maxIdle();
protected static final int WAIT_TIMEOUT = 2000;
protected static final TestTimeService TIME_SERVICE = new TestTimeService();
@ -46,6 +44,7 @@ public abstract class AbstractNonInvalidationTest extends SingleNodeTest {
protected AdvancedCache entityCache;
protected long itemId;
protected Region region;
protected long timeout;
@BeforeClassOnce
public void setup() {
@ -68,6 +67,7 @@ public abstract class AbstractNonInvalidationTest extends SingleNodeTest {
public void insertAndClearCache() throws Exception {
region = sessionFactory().getSecondLevelCacheRegion(Item.class.getName());
entityCache = ((EntityRegionImpl) region).getCache();
timeout = ((EntityRegionImpl) region).getRegionFactory().getPendingPutsCacheConfiguration().expiration().maxIdle();
Item item = new Item("my item", "Original item");
withTxSession(s -> s.persist(item));
entityCache.clear();

View File

@ -52,7 +52,7 @@ public class TombstoneTest extends AbstractNonInvalidationTest {
assertEquals(1, contents.size());
assertEquals(Tombstone.class, contents.get(itemId).getClass());
TIME_SERVICE.advance(TIMEOUT + 1);
TIME_SERVICE.advance(timeout + 1);
assertNull(entityCache.get(itemId)); // force expiration
contents = Caches.entrySet(entityCache).toMap();
assertEquals(Collections.EMPTY_MAP, contents);
@ -81,7 +81,7 @@ public class TombstoneTest extends AbstractNonInvalidationTest {
Object value = contents.get(itemId);
if (value instanceof FutureUpdate) {
// DB did not blocked two concurrent updates
TIME_SERVICE.advance(TIMEOUT + 1);
TIME_SERVICE.advance(timeout + 1);
assertNull(entityCache.get(itemId));
contents = Caches.entrySet(entityCache).toMap();
assertEquals(Collections.EMPTY_MAP, contents);
@ -89,7 +89,7 @@ public class TombstoneTest extends AbstractNonInvalidationTest {
// DB left only one update to proceed, and the entry should not be expired
assertNotNull(value);
assertEquals(StandardCacheEntryImpl.class, value.getClass());
TIME_SERVICE.advance(TIMEOUT + 1);
TIME_SERVICE.advance(timeout + 1);
assertEquals(value, entityCache.get(itemId));
}
}
@ -118,7 +118,7 @@ public class TombstoneTest extends AbstractNonInvalidationTest {
assertEquals(1, contents.size());
assertEquals(Tombstone.class, contents.get(itemId).getClass());
TIME_SERVICE.advance(TIMEOUT + 1);
TIME_SERVICE.advance(timeout + 1);
assertNull(entityCache.get(itemId)); // force expiration
contents = Caches.entrySet(entityCache).toMap();
assertEquals(Collections.EMPTY_MAP, contents);
@ -149,14 +149,14 @@ public class TombstoneTest extends AbstractNonInvalidationTest {
Object value = contents.get(itemId);
if (removeSucceeded) {
assertEquals(Tombstone.class, value.getClass());
TIME_SERVICE.advance(TIMEOUT + 1);
TIME_SERVICE.advance(timeout + 1);
assertNull(entityCache.get(itemId)); // force expiration
contents = Caches.entrySet(entityCache).toMap();
assertEquals(Collections.EMPTY_MAP, contents);
} else {
assertNotNull(value);
assertEquals(StandardCacheEntryImpl.class, value.getClass());
TIME_SERVICE.advance(TIMEOUT + 1);
TIME_SERVICE.advance(timeout + 1);
assertEquals(value, entityCache.get(itemId));
}
}
@ -217,7 +217,7 @@ public class TombstoneTest extends AbstractNonInvalidationTest {
Object value = contents.get(itemId);
assertNotNull(value);
assertEquals(StandardCacheEntryImpl.class, value.getClass());
TIME_SERVICE.advance(TIMEOUT + 1);
TIME_SERVICE.advance(timeout + 1);
assertEquals(value, entityCache.get(itemId));
}

View File

@ -74,7 +74,7 @@ public class VersionedTest extends AbstractNonInvalidationTest {
assertSingleEmpty();
TIME_SERVICE.advance(TIMEOUT + 1);
TIME_SERVICE.advance(timeout + 1);
assertEmptyCache();
}
@ -208,7 +208,7 @@ public class VersionedTest extends AbstractNonInvalidationTest {
assertSingleEmpty();
TIME_SERVICE.advance(TIMEOUT + 1);
TIME_SERVICE.advance(timeout + 1);
assertEmptyCache();
}
@ -230,7 +230,7 @@ public class VersionedTest extends AbstractNonInvalidationTest {
});
assertSingleCacheEntry();
TIME_SERVICE.advance(TIMEOUT + 1);
TIME_SERVICE.advance(timeout + 1);
assertSingleCacheEntry();
}

View File

@ -14,7 +14,6 @@ import org.infinispan.util.TimeService;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Factory that should be overridden in tests.
@ -62,6 +61,9 @@ public class TestInfinispanRegionFactory extends InfinispanRegionFactory {
}
protected void amendCacheConfiguration(String cacheName, ConfigurationBuilder configurationBuilder) {
if (cacheName.equals(InfinispanRegionFactory.PENDING_PUTS_CACHE_NAME)) {
return;
}
if (transactional) {
if (!cacheName.endsWith("query") && !cacheName.equals(DEF_TIMESTAMPS_RESOURCE)) {
configurationBuilder.transaction().transactionMode(TransactionMode.TRANSACTIONAL).useSynchronization(true);

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:infinispan:config:7.2"
xsi:schemaLocation="urn:infinispan:config:7.2 http://www.infinispan.org/schemas/infinispan-config-7.2.xsd">
<jgroups>
<stack-file name="hibernate-jgroups" path="${hibernate.cache.infinispan.jgroups_cfg:default-configs/default-jgroups-tcp.xml}"/>
</jgroups>
<cache-container name="SampleCacheManager" statistics="false" default-cache="the-default-cache" shutdown-hook="DEFAULT">
<transport stack="hibernate-jgroups" cluster="infinispan-hibernate-cluster"/>
<local-cache name="the-default-cache" statistics="false" />
<!-- Default configuration is appropriate for entity/collection caching. -->
<invalidation-cache name="entity" mode="SYNC" remote-timeout="20000">
<locking concurrency-level="1000" acquire-timeout="15000"/>
<transaction mode="NONE" />
<eviction max-entries="10000" strategy="LRU"/>
<expiration max-idle="100000" interval="5000"/>
</invalidation-cache>
<!-- Default configuration for immutable entities -->
<invalidation-cache name="immutable-entity" mode="SYNC" remote-timeout="20000">
<locking concurrency-level="1000" acquire-timeout="15000"/>
<transaction mode="NONE"/>
<eviction max-entries="10000" strategy="LRU"/>
<expiration max-idle="100000" interval="5000"/>
</invalidation-cache>
<!-- A config appropriate for query caching. Does not replicate queries. -->
<local-cache name="local-query">
<locking concurrency-level="1000" acquire-timeout="15000"/>
<transaction mode="NONE" />
<eviction max-entries="10000" strategy="LRU"/>
<expiration max-idle="100000" interval="5000"/>
</local-cache>
<!-- A query cache that replicates queries. Replication is asynchronous. -->
<replicated-cache name="replicated-query" mode="ASYNC">
<locking concurrency-level="1000" acquire-timeout="15000"/>
<transaction mode="NONE" />
<eviction max-entries="10000" strategy="LRU"/>
<expiration max-idle="100000" interval="5000"/>
</replicated-cache>
<!-- Optimized for timestamp caching. A clustered timestamp cache
is required if query caching is used, even if the query cache
itself is configured with CacheMode=LOCAL. -->
<replicated-cache name="timestamps" mode="ASYNC">
<locking concurrency-level="1000" acquire-timeout="15000"/>
<!-- Explicitly non transactional -->
<transaction mode="NONE"/>
<!-- Don't ever evict modification timestamps -->
<eviction strategy="NONE"/>
<expiration interval="0"/>
</replicated-cache>
<!-- This configuration should match to InfinispanRegionFactory.DEFAULT_PENDING_PUTS_CACHE_CONFIGURATION -->
<local-cache name="pending-puts" statistics="false">
<transaction mode="NONE"/>
<expiration max-idle="120000" />
</local-cache>
</cache-container>
</infinispan>