/** * Indicates whether the given cache is configured with * {@link org.infinispan.configuration.cache.CacheMode#INVALIDATION_ASYNC} or * {@link org.infinispan.configuration.cache.CacheMode#INVALIDATION_SYNC}. * * @param cache to check for invalidation configuration * @return true if the cache is configured with invalidation, false otherwise */ public static boolean isInvalidationCache(AdvancedCache cache) { return cache.getCacheConfiguration() .clustering().cacheMode().isInvalidation(); }
if (clientIntel == Constants.INTELLIGENCE_HASH_DISTRIBUTION_AWARE && !cacheMode.isInvalidation()) { int numSegments = cacheTopology.getReadConsistentHash().getNumSegments(); return Optional.of(new HashDistAware20Response(topologyId, serverEndpoints, numSegments,
protected CountDownLatch expectReadWriteKeyCommand(AdvancedCache cache, Predicate<Object> valuePredicate, int numUpdates) { if (!cacheMode.isInvalidation()) { CountDownLatch latch = new CountDownLatch(numUpdates); ExpectingInterceptor.get(cache) .when((ctx, cmd) -> cmd instanceof ReadWriteKeyCommand && valuePredicate.test(((ReadWriteKeyCommand) cmd).getFunction())) .countDown(latch); cleanup.add(() -> ExpectingInterceptor.cleanup(cache)); return latch; } else { return new CountDownLatch(0); } }
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 void amendCacheConfiguration(String cacheName, ConfigurationBuilder configurationBuilder) { if (cacheName.equals(DEF_PENDING_PUTS_RESOURCE)) { return; } if (transactional) { if (!cacheName.endsWith("query") && !cacheName.equals(DEF_TIMESTAMPS_RESOURCE) && !cacheName.endsWith(DEF_PENDING_PUTS_RESOURCE)) { configurationBuilder.transaction().transactionMode(TransactionMode.TRANSACTIONAL).useSynchronization(true); } } else { configurationBuilder.transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL); } if (cacheMode != null) { if (configurationBuilder.clustering().cacheMode().isInvalidation()) { configurationBuilder.clustering().cacheMode(cacheMode); } } } }
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(); }
CountDownLatch contactsLatch = new CountDownLatch(2); if (cacheMode.isInvalidation()) { cleanup.add(mockValidator(remoteCustomerCache, customerLatch)); cleanup.add(mockValidator(remoteCollectionCache, collectionLatch));
@Test public void testPutFromLoadRemoveDoesNotProduceStaleData() throws Exception { if (!cacheMode.isInvalidation()) { return;
public CountDownLatch getRemoteUpdateLatch(Cache remoteNaturalIdCache) { CountDownLatch latch; if (cacheMode.isInvalidation()) { latch = useTransactionalCache() ? expectAfterEndInvalidation(remoteNaturalIdCache.getAdvancedCache(), 1) : expectAfterEndInvalidation(remoteNaturalIdCache.getAdvancedCache(), 2); } else { latch = expectAfterUpdate(remoteNaturalIdCache.getAdvancedCache(), 2); } log.tracef("Created latch: %s", latch); return latch; }
@TestForIssue(jiraKey = "HHH-9881") @Test public void testConcurrentLoadAndRemoval() throws Exception { if (!remoteCustomerCache.getCacheConfiguration().clustering().cacheMode().isInvalidation()) {
protected <K, V> Cache<K, V> getLockOwner(Object key, String cacheName) { Configuration c = getCache(0, cacheName).getCacheConfiguration(); if (c.clustering().cacheMode().isInvalidation()) { return getCache(0, cacheName); //for replicated caches only the coordinator acquires lock } else if (!c.clustering().cacheMode().isClustered()) { throw new IllegalStateException("This is not a clustered cache!"); } else { Address address = getCache(0, cacheName).getAdvancedCache().getDistributionManager().getCacheTopology() .getDistribution(key).primary(); for (Cache<K, V> cache : this.<K, V>caches(cacheName)) { if (cache.getAdvancedCache().getRpcManager().getTransport().getAddress().equals(address)) { return cache; } } throw new IllegalStateException(); } }
if (!cacheMode.isInvalidation()) { throw new IllegalArgumentException("PutFromLoadValidator in clustered caches requires invalidation mode.");
if (!cacheMode.isInvalidation()) { remoteCollectionLoadLatch = new CountDownLatch(1); ExpectingInterceptor.get(remoteCollectionCache) if (!cacheMode.isInvalidation() && accessType != AccessType.NONSTRICT_READ_WRITE) { modifyLatch = new CountDownLatch(1); ExpectingInterceptor.get(localCustomerCache).when(this::isFutureUpdate).countDown(modifyLatch); if (cacheMode.isInvalidation()) {
throw e; } finally { if (cacheMode.isInvalidation()) removeAfterEndInvalidationHandler(remoteNaturalIdCache.getAdvancedCache());