public CacheEntryMutator(Cache<K, V> cache, K id, V value) { this.cache = cache; this.id = id; this.value = value; this.mutated = cache.getCacheConfiguration().transaction().transactionMode().isTransactional() ? new AtomicBoolean(false) : null; }
public InfinispanCache(org.infinispan.Cache<K, V> cacheStore, String cacheName, ClassLoader classloader) { assert(cacheStore != null); this.cacheStore = cacheStore.getAdvancedCache(); TransactionMode transactionMode = this.cacheStore.getCacheConfiguration().transaction().transactionMode(); this.transactional = transactionMode == TransactionMode.TRANSACTIONAL; LogManager.logDetail(LogConstants.CTX_RUNTIME, "Added", transactionMode, "infinispan cache", cacheName); //$NON-NLS-1$ //$NON-NLS-2$ this.name = cacheName; this.classloader = classloader; }
public InfinispanCacheProperties(Configuration config) { this.transactional = config.transaction().transactionMode().isTransactional(); this.lockOnWrite = this.transactional && (config.transaction().lockingMode() == LockingMode.PESSIMISTIC); this.lockOnRead = this.lockOnWrite && (config.locking().isolationLevel() == IsolationLevel.REPEATABLE_READ); boolean clustered = config.clustering().cacheMode().needsStateTransfer(); boolean hasStore = config.persistence().usingStores(); this.marshalling = clustered || hasStore; this.persistent = clustered || (hasStore && !config.persistence().passivation()); }
transaction().transactionMode() != TransactionMode.TRANSACTIONAL) { if (LOG.isLoggable(Level.FINEST)) { LOG.finest("Not transactional, so returning true");
public CacheEntryMutator(Cache<K, V> cache, K id, V value) { this.cache = cache; this.id = id; this.value = value; this.mutated = cache.getCacheConfiguration().transaction().transactionMode().isTransactional() ? new AtomicBoolean(false) : null; }
/** * Inject our TransactionManager lookup delegate for transactional caches ONLY! * <p> * injecting one in a non-transactional cache will have side-effects on other configuration settings. * * @return an updated version of the configuration */ private static Configuration injectTransactionManager(TransactionManagerLookupDelegator transactionManagerLookupDelegator, Configuration configuration) { if ( configuration.transaction().transactionMode() == TransactionMode.TRANSACTIONAL ) { ConfigurationBuilder builder = new ConfigurationBuilder().read( configuration ); builder.transaction() .transactionManagerLookup( transactionManagerLookupDelegator ); return builder.build(); } return configuration; }
public CacheEntryMutator(Cache<K, V> cache, K id, V value) { this.cache = cache; this.id = id; this.value = value; this.mutated = cache.getCacheConfiguration().transaction().transactionMode().isTransactional() ? new AtomicBoolean(false) : null; }
/** * Inject our TransactionManager lookup delegate for transactional caches ONLY! * <p> * injecting one in a non-transactional cache will have side-effects on other configuration settings. * * @return an updated version of the configuration */ private static Configuration injectTransactionManager(TransactionManagerLookupDelegator transactionManagerLookupDelegator, Configuration configuration) { if ( configuration.transaction().transactionMode() == TransactionMode.TRANSACTIONAL ) { ConfigurationBuilder builder = new ConfigurationBuilder().read( configuration ); builder.transaction() .transactionManagerLookup( transactionManagerLookupDelegator ); return builder.build(); } return configuration; }
public static boolean isTransactionalCache(AdvancedCache cache) { return cache.getCacheConfiguration().transaction().transactionMode().isTransactional(); }
public void testTransactionModeOverride() { ConfigurationBuilder c = new ConfigurationBuilder(); c.transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL); assertEquals(TransactionMode.TRANSACTIONAL, cacheManager.getCache().getCacheConfiguration().transaction().transactionMode()); cacheManager.defineConfiguration("nonTx", c.build()); assertEquals(TransactionMode.NON_TRANSACTIONAL, cacheManager.getCache("nonTx").getCacheConfiguration().transaction().transactionMode()); }
protected void checkAccessType(AccessType accessType) { if (accessType == AccessType.TRANSACTIONAL && !cache.getCacheConfiguration().transaction().transactionMode().isTransactional()) { log.transactionalStrategyNonTransactionalCache(); } else if (accessType == AccessType.READ_WRITE && cache.getCacheConfiguration().transaction().transactionMode().isTransactional()) { log.readWriteStrategyTransactionalCache(); } }
} else if (config.transaction().transactionMode() == org.infinispan.transaction.TransactionMode.TRANSACTIONAL) { configBuilder.addDependency( TxnServices.JBOSS_TXN_TRANSACTION_MANAGER, cacheConfigurationDependencies.getTransactionManagerInjector() ); if (config.transaction().useSynchronization()) { configBuilder.addDependency( TxnServices.JBOSS_TXN_SYNCHRONIZATION_REGISTRY,
/** * Checks if the configuration (and the transaction manager) is able to handle client transactions. */ private void validateConfiguration(AdvancedCache<byte[], byte[]> cache) { Configuration configuration = cache.getCacheConfiguration(); if (!configuration.transaction().transactionMode().isTransactional()) { throw log.expectedTransactionalCache(cache.getName()); } if (configuration.locking().isolationLevel() != IsolationLevel.REPEATABLE_READ) { throw log.unexpectedIsolationLevel(cache.getName()); } //TODO because of ISPN-7672, optimistic and total order transactions needs versions. however, versioning is currently broken if (configuration.transaction().lockingMode() == LockingMode.OPTIMISTIC || configuration.transaction().transactionProtocol() == TransactionProtocol.TOTAL_ORDER) { //no Log. see comment above throw new IllegalStateException( String.format("Cache '%s' cannot use Optimistic neither Total Order transactions.", cache.getName())); } }
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(); }
@Test public void testBuildImmutableEntityRegion() { AdvancedCache cache; Properties p = new Properties(); TestRegionFactory factory = createRegionFactory(p); try { factory.getCacheManager(); InfinispanBaseRegion region = factory.buildEntityRegion("com.acme.Address", AccessType.TRANSACTIONAL); assertNull( factory.getBaseConfiguration( "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(); } }
protected void runInvalidation(boolean inTransaction) { // If we're running inside a transaction, we need to remove elements one-by-one // to clean the context as well (cache.clear() does not do that). // When we don't have transaction, we can do a clear operation (since we don't // case about context) and can't do the one-by-one remove: remove() on tx cache // requires transactional context. if (inTransaction && cache.getCacheConfiguration().transaction().transactionMode().isTransactional()) { log.tracef( "Transaction, clearing one element at the time" ); Caches.removeAll( localAndSkipLoadCache ); } else { log.tracef( "Non-transactional, clear in one go" ); localAndSkipLoadCache.clear(); } }
@Test public void testGetBlockingLocalPut() throws Throwable { final Cache<Object, String> nonOwnerCache = getFirstNonOwner(key); final Cache<Object, String> ownerCache = getFirstOwner(key); ownerCache.put(key, firstValue); assertIsNotInL1(nonOwnerCache, key); CheckPoint checkPoint = new CheckPoint(); waitUntilAboutToAcquireLock(nonOwnerCache, checkPoint); log.warn("Doing get here - ignore all previous"); Future<String> getFuture = fork(() -> nonOwnerCache.get(key)); // Wait until we are about to write value into data container on non owner checkPoint.awaitStrict("pre_acquire_shared_topology_lock_invoked", 10, TimeUnit.SECONDS); Future<String> putFuture = fork(() -> nonOwnerCache.put(key, secondValue)); Exceptions.expectException(TimeoutException.class, () -> putFuture.get(1, TimeUnit.SECONDS)); // Let the get complete finally checkPoint.triggerForever("pre_acquire_shared_topology_lock_released"); assertEquals(firstValue, getFuture.get(10, TimeUnit.SECONDS)); assertEquals(firstValue, putFuture.get(10, TimeUnit.SECONDS)); if (nonOwnerCache.getCacheConfiguration().transaction().transactionMode() == TransactionMode.TRANSACTIONAL) { assertIsInL1(nonOwnerCache, key); } else { assertIsNotInL1(nonOwnerCache, key); } }
public InfinispanCacheProperties(Configuration config) { this.transactional = config.transaction().transactionMode().isTransactional(); this.lockOnWrite = this.transactional && (config.transaction().lockingMode() == LockingMode.PESSIMISTIC); this.lockOnRead = this.lockOnWrite && (config.locking().isolationLevel() == IsolationLevel.REPEATABLE_READ); boolean clustered = config.clustering().cacheMode().needsStateTransfer(); boolean hasStore = config.persistence().usingStores(); this.marshalling = clustered || hasStore; this.persistent = clustered || (hasStore && !config.persistence().passivation()); }
private static void assertCounterAndCacheConfiguration(CounterManagerConfiguration config, Configuration cacheConfig) { AssertJUnit.assertEquals(CacheMode.DIST_SYNC, cacheConfig.clustering().cacheMode()); AssertJUnit.assertEquals(config.numOwners(), cacheConfig.clustering().hash().numOwners()); AssertJUnit.assertEquals(config.reliability() == Reliability.CONSISTENT, cacheConfig.clustering().partitionHandling().whenSplit() == PartitionHandling.DENY_READ_WRITES); AssertJUnit.assertFalse(cacheConfig.clustering().l1().enabled()); AssertJUnit.assertEquals(TransactionMode.NON_TRANSACTIONAL, cacheConfig.transaction().transactionMode()); }