Search in sources :

Example 6 with ConsistentHashFactory

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));
}
Also used : ConsistentHash(org.infinispan.distribution.ch.ConsistentHash) ConsistentHashFactory(org.infinispan.distribution.ch.ConsistentHashFactory)

Example 7 with ConsistentHashFactory

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);
}
Also used : ConsistentHash(org.infinispan.distribution.ch.ConsistentHash) ConsistentHashFactory(org.infinispan.distribution.ch.ConsistentHashFactory)

Aggregations

ConsistentHashFactory (org.infinispan.distribution.ch.ConsistentHashFactory)7 ConsistentHash (org.infinispan.distribution.ch.ConsistentHash)6 Address (org.infinispan.remoting.transport.Address)3 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Callable (java.util.concurrent.Callable)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CompletionStage (java.util.concurrent.CompletionStage)1 ExecutorService (java.util.concurrent.ExecutorService)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 ScheduledFuture (java.util.concurrent.ScheduledFuture)1 TimeUnit (java.util.concurrent.TimeUnit)1 MILLISECONDS (java.util.concurrent.TimeUnit.MILLISECONDS)1 GuardedBy (net.jcip.annotations.GuardedBy)1 ReplicableCommand (org.infinispan.commands.ReplicableCommand)1 CacheAvailabilityUpdateCommand (org.infinispan.commands.topology.CacheAvailabilityUpdateCommand)1 CacheJoinCommand (org.infinispan.commands.topology.CacheJoinCommand)1