public static Mode forCacheMode(CacheMode mode) { return mode.isSynchronous() ? SYNC : ASYNC; }
public static Mode forCacheMode(CacheMode mode) { return mode.isSynchronous() ? SYNC : ASYNC; }
public static Mode forCacheMode(CacheMode mode) { return mode.isSynchronous() ? SYNC : ASYNC; }
private static void validateIndexCaches(String indexName, Cache<?, ?>... caches) { Arrays.stream(caches).filter(Objects::nonNull).forEach(cache -> { ClusteringConfiguration clusteringConfiguration = cache.getCacheConfiguration().clustering(); CacheMode cacheMode = clusteringConfiguration.cacheMode(); if (cacheMode.isClustered() && !cacheMode.isSynchronous()) { throw log.cannotStoreIndexOnAsyncCaches(indexName, cache.getName(), cacheMode); } }); }
/** * Indicates whether the given cache is configured with * {@link org.infinispan.configuration.cache.CacheMode#REPL_SYNC}, * {@link org.infinispan.configuration.cache.CacheMode#INVALIDATION_SYNC}, or * {@link org.infinispan.configuration.cache.CacheMode#DIST_SYNC}. * * @param cache to check for synchronous configuration * @return true if the cache is configured with synchronous mode, false otherwise */ public static boolean isSynchronousCache(AdvancedCache cache) { return cache.getCacheConfiguration() .clustering().cacheMode().isSynchronous(); }
private static void validateIndexCaches(String indexName, Cache<?, ?>... caches) { Arrays.stream(caches).filter(Objects::nonNull).forEach(cache -> { ClusteringConfiguration clusteringConfiguration = cache.getCacheConfiguration().clustering(); CacheMode cacheMode = clusteringConfiguration.cacheMode(); if (cacheMode.isClustered() && !cacheMode.isSynchronous()) { throw log.cannotStoreIndexOnAsyncCaches(indexName, cache.getName(), cacheMode); } }); }
/** * Expects any commands, within transactional scope (i.e., as a payload to a PrepareCommand). If the cache mode is * synchronous, a CommitCommand is expected as well. */ @SuppressWarnings("unchecked") public void expectAnyWithTx() { List<Class<? extends VisitableCommand>> cmdsToExpect = new ArrayList<Class<? extends VisitableCommand>>(2); cmdsToExpect.add(PrepareCommand.class); //this is because for async replication we have an 1pc transaction if (cache.getCacheConfiguration().clustering().cacheMode().isSynchronous()) cmdsToExpect.add(CommitCommand.class); expect(cmdsToExpect.toArray(new Class[cmdsToExpect.size()])); }
/** * Expects a specific set of commands, within transactional scope (i.e., as a payload to a PrepareCommand). If the * cache mode is synchronous, a CommitCommand is expected as well. * * @param commands commands to expect (not counting transaction boundary commands like PrepareCommand and * CommitCommand) */ @SuppressWarnings("unchecked") public void expectWithTx(Class<? extends VisitableCommand>... commands) { List<Class<? extends VisitableCommand>> cmdsToExpect = new ArrayList<>(); cmdsToExpect.add(PrepareCommand.class); if (commands != null) cmdsToExpect.addAll(Arrays.asList(commands)); //this is because for async replication we have an 1pc transaction if (cache.getCacheConfiguration().clustering().cacheMode().isSynchronous()) cmdsToExpect.add(CommitCommand.class); expect(cmdsToExpect.toArray(new Class[cmdsToExpect.size()])); }
protected void assertCacheValue(int originatorIndex, Object key, Object value) { for (int index = 0; index < caches().size(); ++index) { if ((index == originatorIndex && mode.isSynchronous()) || (index != originatorIndex && syncCommit)) { assertEquals(index, key, value); } else { assertEventuallyEquals(index, key, value); } } }
/** * Create a Configuration object initialized from the data in the operation. * * @param cache data representing cache configuration * @param builder * @param dependencies * * @return initialised Configuration object */ @Override void processModelNode(OperationContext context, String containerName, ModelNode cache, ConfigurationBuilder builder, List<Dependency<?>> dependencies) throws OperationFailedException { // process cache attributes and elements super.processModelNode(context, containerName, cache, builder, dependencies); // adjust the cache mode used based on the value of clustered attribute MODE ModelNode modeModel = ClusteredCacheConfigurationResource.MODE.resolveModelAttribute(context, cache); CacheMode cacheMode = modeModel.isDefined() ? Mode.valueOf(modeModel.asString()).apply(this.mode) : this.mode; builder.clustering().cacheMode(cacheMode); final long remoteTimeout = ClusteredCacheConfigurationResource.REMOTE_TIMEOUT.resolveModelAttribute(context, cache).asLong(); // process clustered cache attributes and elements if (cacheMode.isSynchronous()) { builder.clustering().remoteTimeout(remoteTimeout); } } }
if (cacheMode.isSynchronous()) configuration.clustering().remoteTimeout(60, TimeUnit.SECONDS); configuration.locking().lockAcquisitionTimeout(lockTimeout, TimeUnit.SECONDS); configuration.clustering().l1().enabled(l1CacheEnabled);