use of org.infinispan.distribution.ch.ConsistentHashFactory in project infinispan by infinispan.
the class TestClusterCacheStatus method conflictResolutionConsistentHash.
public static ConsistentHash conflictResolutionConsistentHash(TestClusterCacheStatus... caches) {
ConsistentHashFactory chf = caches[0].joinInfo.getConsistentHashFactory();
ConsistentHash hash = Stream.of(caches).map(TestClusterCacheStatus::readConsistentHash).reduce(chf::union).orElseThrow(IllegalStateException::new);
return chf.union(hash, chf.rebalance(hash));
}
use of org.infinispan.distribution.ch.ConsistentHashFactory in project infinispan by infinispan.
the class ClusterCacheStatus method calculateConflictHash.
@Override
public ConsistentHash calculateConflictHash(ConsistentHash preferredHash, Set<ConsistentHash> distinctHashes, List<Address> actualMembers) {
// If we are required to resolveConflicts, then we utilise a union of all distinct CHs. This is necessary
// to ensure that we read the entries associated with all possible read owners before the rebalance occurs
ConsistentHashFactory chf = getJoinInfo().getConsistentHashFactory();
ConsistentHash unionHash = distinctHashes.stream().reduce(preferredHash, chf::union);
unionHash = chf.union(unionHash, chf.rebalance(unionHash));
return chf.updateMembers(unionHash, actualMembers, capacityFactors);
}
Aggregations