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; }
break; case TRANSACTION_MODE: builder.transaction().transactionMode(TransactionMode.valueOf(value)); transactionModeSpecified = true; break;
@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 TransactionalModeFilter() { super(InTransactionMode.class, InTransactionMode::value, (m, b) -> b == Boolean.valueOf(m.isTransactional())); }
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 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 static boolean isTransactionalCache(AdvancedCache cache) { return cache.getCacheConfiguration().transaction().transactionMode().isTransactional(); }
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(); } }
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 final void testToCacheIsTransactional() { assertTrue(cache(0).getCacheConfiguration().transaction().transactionMode().isTransactional()); }
/** * Registers the {@link PerCacheTxTable} to a transactional cache. */ private void registerServerTransactionTable(ComponentRegistry componentRegistry, String cacheName) { //skip for global tx table and non-transactional cache if (GLOBAL_TX_TABLE_CACHE_NAME.equals(cacheName) || !componentRegistry.getComponent(Configuration.class).transaction().transactionMode().isTransactional()) { return; } EmbeddedCacheManager cacheManager = componentRegistry.getGlobalComponentRegistry() .getComponent(EmbeddedCacheManager.class); createGlobalTxTable(cacheManager); // TODO We need a way for a module to install a factory before the default implementation is instantiated BasicComponentRegistry basicComponentRegistry = componentRegistry.getComponent(BasicComponentRegistry.class); basicComponentRegistry.replaceComponent(PerCacheTxTable.class.getName(), new PerCacheTxTable(cacheManager.getAddress()), true); basicComponentRegistry.replaceComponent(TransactionOriginatorChecker.class.getName(), new ServerTransactionOriginatorChecker(), true); basicComponentRegistry.rewire(); }
public NonStrictAccessDelegate(InfinispanDataRegion region, Comparator versionComparator) { this.region = region; this.cache = region.getCache(); FunctionalMapImpl fmap = FunctionalMapImpl.create(cache).withParams(Param.PersistenceMode.SKIP_LOAD); this.writeMap = ReadWriteMapImpl.create(fmap); // Note that correct behaviour of local and async writes depends on LockingInterceptor (see there for details) this.putFromLoadMap = ReadWriteMapImpl.create(fmap).withParams(Param.LockingMode.TRY_LOCK, Param.ReplicationMode.ASYNC); Configuration configuration = cache.getCacheConfiguration(); if (configuration.clustering().cacheMode().isInvalidation()) { throw new IllegalArgumentException("Nonstrict-read-write mode cannot use invalidation."); } if (configuration.transaction().transactionMode().isTransactional()) { throw new IllegalArgumentException("Currently transactional caches are not supported."); } this.versionComparator = versionComparator; if (versionComparator == null) { throw new IllegalArgumentException("This strategy requires versioned entities/collections but region " + region.getName() + " contains non-versioned data!"); } }
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(); }
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(); }
Consumer<MultipleCacheManagersTest>[] transactionModifiers = getModifiers(InTransactionMode.class, InTransactionMode::value, (t, m) -> t.transactional(m.isTransactional())); allModifiers = asList(cacheModeModifiers, transactionModifiers); } catch (Exception e) {
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())); } }