@Override
  protected void loadCosts() {
    if (cluster.numRacks <= 1) {
      maxCost = 0;
      return; // disabled for 1 rack
    }
    // max cost is the case where every region replica is hosted together regardless of rack
    maxCost = getMaxCost(cluster);
    costsPerGroup = new long[cluster.numRacks];
    for (int i = 0; i < cluster.colocatedReplicaCountsPerRack.length; i++) {
      costsPerGroup[i] = costPerGroup(cluster.colocatedReplicaCountsPerRack[i]);
    }
  }
A cost function for region replicas for the rack distribution. We give a relatively high cost to
hosting replicas of the same region in the same rack. We do not prevent the case though.
hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/RegionReplicaRackCostFunction.java