Refine search
@Override public Affinity getWeakAffinity(I id) { if (this.cache.getCacheConfiguration().clustering().cacheMode().isClustered()) { Node node = this.locatePrimaryOwner(id); Map.Entry<String, ?> entry = this.registry.getEntry(node); if (entry != null) { return new NodeAffinity(entry.getKey()); } } return Affinity.NONE; }
public ConsistentHashLocality(Cache<?, ?> cache, ConsistentHash hash) { this.topology = new LocalizedCacheTopology(cache.getCacheConfiguration().clustering().cacheMode(), new CacheTopology(0, 0, hash, null, CacheTopology.Phase.NO_REBALANCE, Collections.emptyList(), Collections.emptyList()), cache.getCacheConfiguration().clustering().hash().keyPartitioner(), cache.getCacheManager().getAddress(), true); }
@Override public <K> KeyAffinityService<K> createService(Cache<K, ?> cache, KeyGenerator<K> generator) { CacheMode mode = cache.getCacheConfiguration().clustering().cacheMode(); return mode.isDistributed() || mode.isReplicated() ? new KeyAffinityServiceImpl<>(executor, cache, generator, bufferSize, Collections.singleton(cache.getCacheManager().getAddress()), false) : new SimpleKeyAffinityService<>(generator); } };
@Override public Affinity getStrictAffinity() { Group group = this.registry.getGroup(); return this.cache.getCacheConfiguration().clustering().cacheMode().isClustered() ? new ClusterAffinity(group.getName()) : new NodeAffinity(this.registry.getEntry(group.getLocalMember()).getKey()); }
Node locatePrimaryOwner(I id) { DistributionManager dist = this.cache.getAdvancedCache().getDistributionManager(); Address address = (dist != null) && !this.cache.getCacheConfiguration().clustering().cacheMode().isScattered() ? dist.getCacheTopology().getDistribution(new Key<>(id)).primary() : null; Node member = (address != null) ? this.nodeFactory.createNode(address) : null; return (member != null) ? member : this.registry.getGroup().getLocalMember(); }
@Override public String locate(String sessionId) { DistributionManager dist = this.cache.getAdvancedCache().getDistributionManager(); Address address = (dist != null) && !this.cache.getCacheConfiguration().clustering().cacheMode().isScattered() ? dist.getCacheTopology().getDistribution(new Key<>(sessionId)).primary() : this.cache.getCacheManager().getAddress(); Node node = (address != null) ? this.factory.createNode(address) : null; Map.Entry<String, Void> entry = (node != null) ? this.registry.getEntry(node) : null; if (entry == null) { entry = this.registry.getEntry(this.registry.getGroup().getLocalMember()); } return (entry != null) ? entry.getKey() : null; } }
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()); }
/** * Checks if the specified cache is configured in invalidation mode. * * @param cache The cache to check. * * @return {@code true} if the cache is configured in invalidation * mode, else {@code false}. */ public static boolean detectInvalidationMode(final Cache cache) { return Arrays.asList(CacheMode.INVALIDATION_SYNC, CacheMode.INVALIDATION_ASYNC) .contains(cache.getCacheConfiguration().clustering().cacheMode()); }
private void setLocalMode() { if (this.cache.getCacheConfiguration().clustering().cacheMode() == CacheMode.LOCAL) { localMode = true; } }
public void startCache() { if (isStarted.compareAndSet(false, true)) { logger.info("Starting JBoss Cache " + name + " ..."); this.cache.start(); if (logger.isInfoEnabled()) { logger.info("Mobicents Cache " + name + " started, status: " + cache.getStatus() + ", Mode: " + cache.getCacheConfiguration().clustering().cacheMode()); } } }
/** * Indicates whether the given cache is configured to cluster its contents. * A cache is considered to clustered if it's configured with any cache mode * except {@link org.infinispan.configuration.cache.CacheMode#LOCAL} * * @param cache to check whether it clusters its contents * @return true if the cache is configured with clustering, false otherwise */ public static boolean isClustered(AdvancedCache cache) { return cache.getCacheConfiguration() .clustering().cacheMode().isClustered(); }
/** * 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(); }
private void setLocalMode() { if(jBossDefaultCache.getCache().getCacheConfiguration().clustering().cacheMode() == CacheMode.LOCAL){ localMode = true; } }
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); } }); }
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); } }); }
public PartitionHandlingSupport(AdvancedCache<?, ?> cache) { this.cache = cache; ClusteringConfiguration clusteringConfiguration = cache.getCacheConfiguration().clustering(); this.isClustered = clusteringConfiguration.cacheMode().isClustered(); this.partitionHandling = isClustered ? clusteringConfiguration.partitionHandling().whenSplit() : null; }
public void startCache() { if(!(jBossDefaultCache.getCache().getStatus() == ComponentStatus.RUNNING)){ logger.info("Starting JBoss Cache..."); jBossDefaultCache.start(); } if (logger.isInfoEnabled()) { logger.info("Mobicents Cache started, status: " + this.jBossDefaultCache.getCache().getStatus() + ", Mode: " + jBossDefaultCache.getCache().getCacheConfiguration().clustering().cacheMode()); } }
@Override public <K> KeyAffinityService<K> createService(Cache<K, ?> cache, KeyGenerator<K> generator) { boolean distributed = cache.getCacheConfiguration().clustering().cacheMode().isDistributed(); return distributed ? new KeyAffinityServiceImpl<>(this.executor, cache, generator, this.bufferSize, Collections.singleton(cache.getCacheManager().getAddress()), false) : new SimpleKeyAffinityService<>(generator); }
/** * 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()])); }
@Override public <K> KeyAffinityService<K> createService(Cache<K, ?> cache, KeyGenerator<K> generator) { CacheMode mode = cache.getCacheConfiguration().clustering().cacheMode(); return mode.isDistributed() || mode.isReplicated() ? new KeyAffinityServiceImpl<>(executor, cache, generator, bufferSize, Collections.singleton(cache.getCacheManager().getAddress()), false) : new SimpleKeyAffinityService<>(generator); } };