use of org.infinispan.distribution.ch.impl.ReplicatedConsistentHash in project infinispan by infinispan.
the class DistributionManagerImpl method makeSingletonTopology.
public static LocalizedCacheTopology makeSingletonTopology(CacheMode cacheMode, KeyPartitioner keyPartitioner, int numSegments, Address localAddress) {
List<Address> members = Collections.singletonList(localAddress);
int[] owners = new int[numSegments];
Arrays.fill(owners, 0);
ConsistentHash ch = new ReplicatedConsistentHash(members, null, Collections.emptyList(), owners);
CacheTopology cacheTopology = new CacheTopology(-1, -1, ch, null, CacheTopology.Phase.NO_REBALANCE, members, null);
return new LocalizedCacheTopology(cacheMode, cacheTopology, keyPartitioner, localAddress, false);
}
use of org.infinispan.distribution.ch.impl.ReplicatedConsistentHash in project infinispan by infinispan.
the class TriangleOrderManagerTest method mockCacheTopology.
private static LocalizedCacheTopology mockCacheTopology(int topologyId) {
List<Address> members = Collections.singletonList(LOCAL_ADDRESS);
ConsistentHash ch = new ReplicatedConsistentHash(members, new int[] { 0 });
CacheTopology cacheTopology = new CacheTopology(topologyId, 0, ch, null, CacheTopology.Phase.NO_REBALANCE, members, null);
return new LocalizedCacheTopology(CacheMode.DIST_SYNC, cacheTopology, key -> 0, LOCAL_ADDRESS, true);
}
use of org.infinispan.distribution.ch.impl.ReplicatedConsistentHash in project infinispan by infinispan.
the class ReplicatedConsistentHashFactoryTest method test1.
public void test1() {
int[] testSegments = { 1, 2, 4, 8, 16, 31, 32, 33, 67, 128 };
ReplicatedConsistentHashFactory factory = new ReplicatedConsistentHashFactory();
Address A = new TestAddress(0, "A");
Address B = new TestAddress(1, "B");
Address C = new TestAddress(2, "C");
Address D = new TestAddress(3, "D");
List<Address> a = Arrays.asList(A);
List<Address> ab = Arrays.asList(A, B);
List<Address> abc = Arrays.asList(A, B, C);
List<Address> abcd = Arrays.asList(A, B, C, D);
List<Address> bcd = Arrays.asList(B, C, D);
List<Address> c = Arrays.asList(C);
for (int segments : testSegments) {
ReplicatedConsistentHash ch = factory.create(0, segments, a, null);
checkDistribution(ch);
ch = factory.updateMembers(ch, ab, null);
ch = factory.rebalance(ch);
checkDistribution(ch);
ch = factory.updateMembers(ch, abc, null);
ch = factory.rebalance(ch);
checkDistribution(ch);
ch = factory.updateMembers(ch, abcd, null);
ch = factory.rebalance(ch);
checkDistribution(ch);
ch = factory.updateMembers(ch, bcd, null);
ch = factory.rebalance(ch);
checkDistribution(ch);
ch = factory.updateMembers(ch, c, null);
ch = factory.rebalance(ch);
checkDistribution(ch);
}
}
Aggregations