@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); } };
private int handleModeEstimate(int desired, CacheMode mode) { if (mode.isReplicated()) { // A REPL cache always requires just 1 node as all nodes have all data return 1; } return desired; }
static MassIndexStrategy calculateStrategy(EntityIndexBinding indexBinding, Configuration cacheConfiguration) { Set<IndexManager> indexManagers = indexBinding.getIndexManagerSelector().all(); IndexManager indexManager = indexManagers.iterator().next(); boolean sharded = indexManagers.size() > 1; boolean replicated = cacheConfiguration.clustering().cacheMode().isReplicated(); boolean singleMaster = !sharded && indexManager instanceof InfinispanIndexManager; boolean multiMaster = indexManager instanceof AffinityIndexManager; boolean custom = !(indexManager instanceof DirectoryBasedIndexManager); if (singleMaster || custom) { return MassIndexStrategy.SHARED_INDEX_STRATEGY; } if (multiMaster) { return MassIndexStrategy.PER_NODE_PRIMARY; } if (sharded || replicated) { return MassIndexStrategy.PER_NODE_ALL_DATA; } return MassIndexStrategy.PER_NODE_PRIMARY; } }
static MassIndexStrategy calculateStrategy(EntityIndexBinding indexBinding, Configuration cacheConfiguration) { Set<IndexManager> indexManagers = indexBinding.getIndexManagerSelector().all(); IndexManager indexManager = indexManagers.iterator().next(); boolean sharded = indexManagers.size() > 1; boolean replicated = cacheConfiguration.clustering().cacheMode().isReplicated(); boolean singleMaster = !sharded && indexManager instanceof InfinispanIndexManager; boolean multiMaster = indexManager instanceof AffinityIndexManager; boolean custom = !(indexManager instanceof DirectoryBasedIndexManager); if (singleMaster || custom) { return MassIndexStrategy.SHARED_INDEX_STRATEGY; } if (multiMaster) { return MassIndexStrategy.PER_NODE_PRIMARY; } if (sharded || replicated) { return MassIndexStrategy.PER_NODE_ALL_DATA; } return MassIndexStrategy.PER_NODE_PRIMARY; } }
@Start public void start() { isReplicated = cacheConfiguration.clustering().cacheMode().isReplicated(); }
@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); } };
protected synchronized AccessDelegate createAccessDelegate(AccessType accessType) { if (accessType == null) { throw new IllegalArgumentException(); } if (this.accessType != null && !this.accessType.equals(accessType)) { throw new IllegalStateException("This region was already set up for " + this.accessType + ", cannot use using " + accessType); } this.accessType = accessType; CacheMode cacheMode = cache.getCacheConfiguration().clustering().cacheMode(); if (accessType == AccessType.NONSTRICT_READ_WRITE) { prepareForVersionedEntries(cacheMode); return new NonStrictAccessDelegate(this, getCacheDataDescription().getVersionComparator()); } if (cacheMode.isDistributed() || cacheMode.isReplicated()) { prepareForTombstones(cacheMode); return new TombstoneAccessDelegate(this); } else { prepareForValidation(); if (cache.getCacheConfiguration().transaction().transactionMode().isTransactional()) { return new TxInvalidationCacheAccessDelegate(this, validator); } else { return new NonTxInvalidationCacheAccessDelegate(this, validator); } } }
private void prepareCommon(CacheMode cacheMode) { BasicComponentRegistry registry = cache.getComponentRegistry().getComponent(BasicComponentRegistry.class); if (cacheMode.isReplicated() || cacheMode.isDistributed()) { AsyncInterceptorChain chain = cache.getAsyncInterceptorChain();
@Override protected void createCacheManagers() throws Throwable { builderUsed = new ConfigurationBuilder(); HashConfigurationBuilder hashConfiguration = builderUsed.clustering().cacheMode(cacheMode).hash().numSegments(3); if (!cacheMode.isReplicated()) { BaseControlledConsistentHashFactory<? extends ConsistentHash> chf = cacheMode.isScattered() ? new TestScatteredConsistentHashFactory() : new TestDefaultConsistentHashFactory(); hashConfiguration.consistentHashFactory(chf); } if (transactional) { builderUsed.transaction().transactionMode(TransactionMode.TRANSACTIONAL); } if (cacheMode.isClustered()) { builderUsed.clustering().stateTransfer().chunkSize(50); enhanceConfiguration(builderUsed); createClusteredCaches(3, CACHE_NAME, builderUsed); } else { enhanceConfiguration(builderUsed); EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(builderUsed); cacheManagers.add(cm); cm.defineConfiguration(CACHE_NAME, builderUsed.build()); } }