Search in sources :

Example 1 with TopologyAwareAddress

use of org.infinispan.remoting.transport.TopologyAwareAddress in project infinispan by infinispan.

the class TopologyInfoBroadcastTest method assertTopologyInfo2Nodes.

private void assertTopologyInfo2Nodes(List<Address> caches) {
    TopologyAwareAddress address0 = (TopologyAwareAddress) caches.get(0);
    assertEquals(address0.getSiteId(), "s0");
    assertEquals(address0.getRackId(), "r0");
    assertEquals(address0.getMachineId(), "m0");
    TopologyAwareAddress address2 = (TopologyAwareAddress) caches.get(1);
    assertEquals(address2.getSiteId(), "s2");
    assertEquals(address2.getRackId(), "r2");
    assertEquals(address2.getMachineId(), "m2");
}
Also used : TopologyAwareAddress(org.infinispan.remoting.transport.TopologyAwareAddress)

Example 2 with TopologyAwareAddress

use of org.infinispan.remoting.transport.TopologyAwareAddress in project infinispan by infinispan.

the class TopologyInfo method addNode.

private void addNode(Address address, float capacityFactor) {
    TopologyAwareAddress taa = (TopologyAwareAddress) address;
    String siteId = taa.getSiteId();
    String rackId = taa.getRackId();
    String machineId = taa.getMachineId();
    cluster.addNode(siteId, rackId, machineId, address, capacityFactor);
}
Also used : TopologyAwareAddress(org.infinispan.remoting.transport.TopologyAwareAddress)

Example 3 with TopologyAwareAddress

use of org.infinispan.remoting.transport.TopologyAwareAddress in project infinispan by infinispan.

the class TopologyAwareConsistentHashFactory method getLocationId.

private Object getLocationId(Address address, TopologyLevel level) {
    TopologyAwareAddress taa = (TopologyAwareAddress) address;
    Object locationId;
    switch(level) {
        case SITE:
            locationId = taa.getSiteId();
            break;
        case RACK:
            locationId = new KeyValuePair<>(taa.getSiteId(), taa.getRackId());
            break;
        case MACHINE:
            locationId = new KeyValuePair<>(taa.getSiteId(), new KeyValuePair<>(taa.getRackId(), taa.getMachineId()));
            break;
        case NODE:
            locationId = address;
            break;
        default:
            throw new IllegalStateException("Unknown level: " + level);
    }
    return locationId;
}
Also used : KeyValuePair(org.infinispan.util.KeyValuePair) TopologyAwareAddress(org.infinispan.remoting.transport.TopologyAwareAddress)

Example 4 with TopologyAwareAddress

use of org.infinispan.remoting.transport.TopologyAwareAddress in project infinispan by infinispan.

the class TopologyAwareOwnershipStatistics method assertSegmentLocation.

private void assertSegmentLocation(int segment, int expectedOwners, int expectedMachines, int expectedRacks, int expectedSites) {
    List<Address> received = ch.locateOwnersForSegment(segment);
    // Check the number of addresses and uniqueness
    assertEquals(received.size(), expectedOwners);
    Set<Address> receivedUnique = new HashSet<>(received);
    assertEquals(receivedUnique.size(), expectedOwners);
    // Check the number of machines
    Set<String> receivedMachines = new HashSet<>();
    for (Address a : received) {
        TopologyAwareAddress taa = (TopologyAwareAddress) a;
        receivedMachines.add(taa.getMachineId() + "|" + taa.getRackId() + "|" + taa.getSiteId());
    }
    assertEquals(receivedMachines.size(), expectedMachines);
    // Check the number of racks
    Set<String> receivedRacks = new HashSet<>();
    for (Address a : received) {
        TopologyAwareAddress taa = (TopologyAwareAddress) a;
        receivedRacks.add(taa.getRackId() + "|" + taa.getSiteId());
    }
    assertEquals(receivedRacks.size(), expectedRacks);
    // Check the number of sites
    Set<String> receivedSites = new HashSet<>();
    for (Address a : received) {
        receivedSites.add(((TopologyAwareAddress) a).getSiteId());
    }
    assertEquals(receivedSites.size(), expectedSites);
}
Also used : TestTopologyAwareAddress(org.infinispan.distribution.TestTopologyAwareAddress) Address(org.infinispan.remoting.transport.Address) TopologyAwareAddress(org.infinispan.remoting.transport.TopologyAwareAddress) HashSet(java.util.HashSet) TestTopologyAwareAddress(org.infinispan.distribution.TestTopologyAwareAddress) TopologyAwareAddress(org.infinispan.remoting.transport.TopologyAwareAddress)

Example 5 with TopologyAwareAddress

use of org.infinispan.remoting.transport.TopologyAwareAddress in project infinispan by infinispan.

the class TopologyAwareOwnershipStatistics method countSites.

private int countSites(List<Address> addresses) {
    Set<String> sites = new HashSet<>(addresses.size());
    for (Address a : addresses) {
        TopologyAwareAddress taa = (TopologyAwareAddress) a;
        sites.add(taa.getSiteId());
    }
    return sites.size();
}
Also used : TestTopologyAwareAddress(org.infinispan.distribution.TestTopologyAwareAddress) Address(org.infinispan.remoting.transport.Address) TopologyAwareAddress(org.infinispan.remoting.transport.TopologyAwareAddress) HashSet(java.util.HashSet) TestTopologyAwareAddress(org.infinispan.distribution.TestTopologyAwareAddress) TopologyAwareAddress(org.infinispan.remoting.transport.TopologyAwareAddress)

Aggregations

TopologyAwareAddress (org.infinispan.remoting.transport.TopologyAwareAddress)8 HashSet (java.util.HashSet)4 TestTopologyAwareAddress (org.infinispan.distribution.TestTopologyAwareAddress)4 Address (org.infinispan.remoting.transport.Address)4 KeyValuePair (org.infinispan.util.KeyValuePair)1