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 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()); }
@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; }
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; }
@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(); }
@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(); } }
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 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(); }
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(); }
public final void testToCacheIsTransactional() { assertTrue(cache(0).getCacheConfiguration().transaction().transactionMode().isTransactional()); }
private boolean isTxCache() { return advancedCache(0, cacheName).getCacheConfiguration().transaction().transactionMode().isTransactional(); } }
/** * 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 void test() { final ConfigurationBuilder c = TestCacheManagerFactory.getDefaultCacheConfiguration(false); assert !c.build().transaction().transactionMode().isTransactional(); c.transaction().transactionMode(TransactionMode.TRANSACTIONAL); assert c.build().transaction().transactionMode().isTransactional(); c.transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL); assert !c.build().transaction().transactionMode().isTransactional(); }
public static <K, V> MapCollectableCloseableIterable<K, V> entrySet(AdvancedCache<K, V> cache, KeyValueFilter<K, V> filter) { if (cache.getCacheConfiguration().transaction().transactionMode().isTransactional()) { // Dummy read to enlist the LocalTransaction as workaround for ISPN-5676 cache.containsKey(false); } // HHH-10023: we can't use values() CloseableIterator<CacheEntry<K, V>> iterator = Closeables.iterator( cache.cacheEntrySet().stream().filter(CacheFilters.predicate(filter))); return new MapCollectableCloseableIterableImpl<K, V>(iterator); }
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()); }