@Test public void testDistSyncAutoCommit() { Configuration configuration = new ConfigurationBuilder() .clustering().cacheMode(CacheMode.DIST_SYNC) .transaction().autoCommit(true) .build(); Assert.assertTrue(configuration.transaction().autoCommit()); Assert.assertEquals(configuration.clustering().cacheMode(), CacheMode.DIST_SYNC); }
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 final boolean localOnly = Caches.isInvalidationCache(cache); this.evictCache = localOnly ? Caches.localCache(cache) : cache; this.putCache = localOnly ? Caches.failSilentWriteCache(cache, Flag.CACHE_MODE_LOCAL ) : Caches.failSilentWriteCache(cache); this.getCache = Caches.failSilentReadCache(cache); TransactionConfiguration transactionConfiguration = this.putCache.getCacheConfiguration().transaction(); boolean transactional = transactionConfiguration.transactionMode() != TransactionMode.NON_TRANSACTIONAL; this.putCacheRequiresTransaction = transactional && !transactionConfiguration.autoCommit(); // Since we execute the query update explicitly form transaction synchronization, the putCache does not need // to be transactional anymore (it had to be in the past to prevent revealing uncommitted changes). if (transactional) { log.useNonTransactionalQueryCache(); } }
public TombstoneAccessDelegate(InfinispanDataRegion region) { this.region = region; this.cache = region.getCache(); FunctionalMapImpl<Object, Object> fmap = FunctionalMapImpl.create(cache).withParams(Param.PersistenceMode.SKIP_LOAD); writeMap = ReadWriteMapImpl.create(fmap); // Note that correct behaviour of local and async writes depends on LockingInterceptor (see there for details) asyncWriteMap = ReadWriteMapImpl.create(fmap).withParams(Param.ReplicationMode.ASYNC); putFromLoadMap = ReadWriteMapImpl.create(fmap).withParams(Param.LockingMode.TRY_LOCK, Param.ReplicationMode.ASYNC); Configuration configuration = this.cache.getCacheConfiguration(); if (configuration.clustering().cacheMode().isInvalidation()) { throw new IllegalArgumentException("For tombstone-based caching, invalidation cache is not allowed."); } if (configuration.transaction().transactionMode().isTransactional()) { throw new IllegalArgumentException("Currently transactional caches are not supported."); } requiresTransaction = configuration.transaction().transactionMode().isTransactional() && !configuration.transaction().autoCommit(); }
/** * Base transactional region constructor * @param cache instance to store transactional data * @param name of the transactional region * @param transactionManager * @param metadata for the transactional region * @param factory for the transactional region * @param cacheKeysFactory factory for cache keys */ public BaseTransactionalDataRegion( AdvancedCache cache, String name, TransactionManager transactionManager, CacheDataDescription metadata, InfinispanRegionFactory factory, CacheKeysFactory cacheKeysFactory) { super( cache, name, transactionManager, factory); this.metadata = metadata; this.cacheKeysFactory = cacheKeysFactory; localCache = cache.withFlags(Flag.CACHE_MODE_LOCAL); Configuration configuration = cache.getCacheConfiguration(); requiresTransaction = configuration.transaction().transactionMode().isTransactional() && !configuration.transaction().autoCommit(); tombstoneExpiration = factory.getPendingPutsCacheConfiguration().expiration().maxIdle(); if (!isRegionAccessStrategyEnabled()) { strategy = Strategy.NONE; } expiringMetaParam = new MetaParam.MetaLifespan(tombstoneExpiration); }
assertEquals(10000, c.transaction().cacheStopTimeout()); assertEquals(LockingMode.PESSIMISTIC, c.transaction().lockingMode()); assertTrue(!c.transaction().autoCommit());