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; }
@Override public void accept(ConfigurationBuilder builder) { super.accept(builder); builder.clustering().cacheMode(CacheMode.LOCAL); // Auto-enable simple cache optimization if cache is non-transactional and non-persistent builder.simpleCache((this.memory().storageType() == StorageType.OBJECT) && !this.transaction().transactionMode().isTransactional() && !this.persistence().usingStores()); } }
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");
@Override public void accept(ConfigurationBuilder builder) { TransactionConfiguration tx = this.transaction.get(); builder.memory().read(this.memory.get()); builder.expiration().read(this.expiration.get()); builder.locking().read(this.locking.get()); builder.persistence().read(this.persistence.get()); builder.transaction().read(tx); builder.jmxStatistics().enabled(this.statisticsEnabled).available(this.statisticsEnabled); try { // Configure invocation batching based on transaction configuration builder.invocationBatching().enable(tx.transactionMode().isTransactional() && (tx.transactionManagerLookup().getTransactionManager() != ContextTransactionManager.getInstance())); } catch (Exception e) { throw new CacheException(e); } }
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; }
private void configureTransactionManager(ConfigurationBuilder builder) { TransactionConfiguration transaction = builder.transaction().create(); if (transaction.transactionMode().isTransactional() ) { final String ispnTmLookupClassName = transaction.transactionManagerLookup().getClass().getName(); final String hbTmLookupClassName = HibernateTransactionManagerLookup.class.getName(); if ( GenericTransactionManagerLookup.class.getName().equals( ispnTmLookupClassName ) ) { log.debug( "Using default Infinispan transaction manager lookup " + "instance (GenericTransactionManagerLookup), overriding it " + "with Hibernate transaction manager lookup" ); builder.transaction().transactionManagerLookup( transactionManagerlookup ); } else if ( ispnTmLookupClassName != null && !ispnTmLookupClassName.equals( hbTmLookupClassName ) ) { log.debug( "Infinispan is configured [" + ispnTmLookupClassName + "] with a different transaction manager lookup " + "class than Hibernate [" + hbTmLookupClassName + "]" ); } else { // Infinispan TM lookup class null, so apply Hibernate one directly builder.transaction().transactionManagerLookup( transactionManagerlookup ); } builder.transaction().useSynchronization( DEF_USE_SYNCHRONIZATION ); } }
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; }
@Override public void accept(ConfigurationBuilder builder) { super.accept(builder); builder.clustering().cacheMode(CacheMode.LOCAL); // Auto-enable simple cache optimization if cache is non-transactional and non-persistent builder.simpleCache((this.memory().storageType() == StorageType.OBJECT) && !this.transaction().transactionMode().isTransactional() && !this.persistence().usingStores()); } }
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()); }
@Override public void accept(ConfigurationBuilder builder) { TransactionConfiguration tx = this.transaction.get(); builder.memory().read(this.memory.get()); builder.expiration().read(this.expiration.get()); builder.locking().read(this.locking.get()); builder.persistence().read(this.persistence.get()); builder.transaction().read(tx); builder.jmxStatistics().enabled(this.statisticsEnabled).available(this.statisticsEnabled); try { // Configure invocation batching based on transaction configuration builder.invocationBatching().enable(tx.transactionMode().isTransactional() && (tx.transactionManagerLookup().getTransactionManager() != ContextTransactionManager.getInstance())); } catch (Exception e) { throw new CacheException(e); } }
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,
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(); } }
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 void testDefaults() { Configuration c = new ConfigurationBuilder().build(); assert !c.transaction().transactionMode().isTransactional(); c = TestCacheManagerFactory.getDefaultCacheConfiguration(false).build(); assert !c.transaction().transactionMode().isTransactional(); c = TestCacheManagerFactory.getDefaultCacheConfiguration(true).build(); assert c.transaction().transactionMode().isTransactional(); c = getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, false).build(); assert !c.transaction().transactionMode().isTransactional(); c = getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, true).build(); assert c.transaction().transactionMode().isTransactional(); }