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");
}
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);
}
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;
}
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);
}
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();
}
Aggregations