Search in sources :

Example 1 with ReplicatedConsistentHash

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);
}
Also used : ConsistentHash(org.infinispan.distribution.ch.ConsistentHash) ReplicatedConsistentHash(org.infinispan.distribution.ch.impl.ReplicatedConsistentHash) Address(org.infinispan.remoting.transport.Address) LocalModeAddress(org.infinispan.remoting.transport.LocalModeAddress) CacheTopology(org.infinispan.topology.CacheTopology) LocalizedCacheTopology(org.infinispan.distribution.LocalizedCacheTopology) ReplicatedConsistentHash(org.infinispan.distribution.ch.impl.ReplicatedConsistentHash) LocalizedCacheTopology(org.infinispan.distribution.LocalizedCacheTopology)

Example 2 with ReplicatedConsistentHash

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);
}
Also used : ConsistentHash(org.infinispan.distribution.ch.ConsistentHash) ReplicatedConsistentHash(org.infinispan.distribution.ch.impl.ReplicatedConsistentHash) Address(org.infinispan.remoting.transport.Address) CacheTopology(org.infinispan.topology.CacheTopology) ReplicatedConsistentHash(org.infinispan.distribution.ch.impl.ReplicatedConsistentHash)

Example 3 with ReplicatedConsistentHash

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);
    }
}
Also used : ReplicatedConsistentHashFactory(org.infinispan.distribution.ch.impl.ReplicatedConsistentHashFactory) TestAddress(org.infinispan.distribution.TestAddress) Address(org.infinispan.remoting.transport.Address) TestAddress(org.infinispan.distribution.TestAddress) ReplicatedConsistentHash(org.infinispan.distribution.ch.impl.ReplicatedConsistentHash)

Aggregations

ReplicatedConsistentHash (org.infinispan.distribution.ch.impl.ReplicatedConsistentHash)3 Address (org.infinispan.remoting.transport.Address)3 ConsistentHash (org.infinispan.distribution.ch.ConsistentHash)2 CacheTopology (org.infinispan.topology.CacheTopology)2 LocalizedCacheTopology (org.infinispan.distribution.LocalizedCacheTopology)1 TestAddress (org.infinispan.distribution.TestAddress)1 ReplicatedConsistentHashFactory (org.infinispan.distribution.ch.impl.ReplicatedConsistentHashFactory)1 LocalModeAddress (org.infinispan.remoting.transport.LocalModeAddress)1