public int getRackOwned(String site, String rack) { int count = 0; for (Address node : topologyInfo.getRackNodes(site, rack)) { count += stats.getOwned(node); } return count; }
public int getMachineOwned(String site, String rack, String machine) { int count = 0; for (Address node : topologyInfo.getMachineNodes(site, rack, machine)) { count += stats.getOwned(node); } return count; }
public int getSiteOwned(String site) { int count = 0; for (Address node : topologyInfo.getSiteNodes(site)) { count += stats.getOwned(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 getOwned(Address node) { return stats.getOwned(node); }