本文整理了Java中org.infinispan.configuration.cache.Configuration.clustering()
方法的一些代码示例,展示了Configuration.clustering()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.clustering()
方法的具体详情如下:
包路径:org.infinispan.configuration.cache.Configuration
类名称:Configuration
方法名:clustering
暂无
代码示例来源:origin: wildfly/wildfly
@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;
}
代码示例来源:origin: wildfly/wildfly
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);
}
代码示例来源:origin: wildfly/wildfly
@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);
}
};
代码示例来源:origin: wildfly/wildfly
@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());
}
代码示例来源:origin: wildfly/wildfly
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();
}
代码示例来源:origin: wildfly/wildfly
@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;
}
}
代码示例来源:origin: wildfly/wildfly
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());
}
代码示例来源:origin: com.nimbusds/common
/**
* 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());
}
代码示例来源:origin: org.restcomm.cluster/cache
private void setLocalMode() {
if (this.cache.getCacheConfiguration().clustering().cacheMode() == CacheMode.LOCAL) {
localMode = true;
}
}
代码示例来源:origin: org.restcomm.cluster/cache
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());
}
}
}
代码示例来源:origin: org.infinispan/infinispan-hibernate-cache-commons
/**
* 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();
}
代码示例来源:origin: org.infinispan/infinispan-hibernate-cache-commons
/**
* 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();
}
代码示例来源:origin: org.mobicents.cluster/cache
private void setLocalMode() {
if(jBossDefaultCache.getCache().getCacheConfiguration().clustering().cacheMode() == CacheMode.LOCAL){
localMode = true;
}
}
代码示例来源:origin: org.infinispan/infinispan-embedded-query
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);
}
});
}
代码示例来源:origin: org.infinispan/infinispan-lucene-directory
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);
}
});
}
代码示例来源:origin: org.infinispan/infinispan-query
public PartitionHandlingSupport(AdvancedCache<?, ?> cache) {
this.cache = cache;
ClusteringConfiguration clusteringConfiguration = cache.getCacheConfiguration().clustering();
this.isClustered = clusteringConfiguration.cacheMode().isClustered();
this.partitionHandling = isClustered ? clusteringConfiguration.partitionHandling().whenSplit() : null;
}
代码示例来源:origin: org.mobicents.cluster/cache
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());
}
}
代码示例来源:origin: org.infinispan.server/infinispan-server-infinispan
@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);
}
代码示例来源:origin: org.infinispan/infinispan-core
/**
* 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()]));
}
代码示例来源:origin: org.wildfly/wildfly-clustering-infinispan-extension
@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);
}
};
内容来源于网络,如有侵权,请联系作者删除!