public int getRackPrimaryOwned(String site, String rack) { int count = 0; for (Address node : topologyInfo.getRackNodes(site, rack)) { count += stats.getPrimaryOwned(node); } return count; }
public int getMachinePrimaryOwned(String site, String rack, String machine) { int count = 0; for (Address node : topologyInfo.getMachineNodes(site, rack, machine)) { count += stats.getPrimaryOwned(node); } return count; }
public int getSitePrimaryOwned(String site) { int count = 0; for (Address node : topologyInfo.getSiteNodes(site)) { count += stats.getPrimaryOwned(node); } return count; }
@Override public String toString() { StringBuilder sb = new StringBuilder("TopologyAwareOwnershipStatistics{\n"); for (String site : topologyInfo.getAllSites()) { sb.append( String.format(" %s: %d/%d\n", site, getSitePrimaryOwned(site), getSiteOwned(site))); for (String rack : topologyInfo.getSiteRacks(site)) { sb.append( String.format( " %s: %d/%d\n", rack, getRackPrimaryOwned(site, rack), getRackOwned(site, rack))); for (String machine : topologyInfo.getRackMachines(site, rack)) { sb.append( String.format( " %s: %d/%d\n", machine, getMachinePrimaryOwned(site, rack, machine), getMachineOwned(site, rack, machine))); for (Address node : topologyInfo.getMachineNodes(site, rack, machine)) { int expectedPrimarySegments = topologyInfo.computeExpectedSegments(numSegments, 1, node); int expectedOwnedSegments = topologyInfo.computeExpectedSegments(numSegments, numOwners, node); sb.append( String.format( " %s: %d/%d (%d/%d)\n", node, stats.getPrimaryOwned(node), stats.getOwned(node), expectedPrimarySegments, expectedOwnedSegments)); } } } } sb.append('}'); return sb.toString(); }
public int getPrimaryOwned(Address node) { return stats.getPrimaryOwned(node); }