@Override
  protected void loadCosts() {
    // max cost is the case where every region replica is hosted together regardless of host
    maxCost = cluster.numHosts > 1 ? getMaxCost(cluster) : 0;
    costsPerGroup = new long[cluster.numHosts];
    // either server based or host based
    colocatedReplicaCountsPerGroup = cluster.multiServersPerHost
      ? cluster.colocatedReplicaCountsPerHost
      : cluster.colocatedReplicaCountsPerServer;
    for (int i = 0; i < colocatedReplicaCountsPerGroup.length; i++) {
      costsPerGroup[i] = costPerGroup(colocatedReplicaCountsPerGroup[i]);
    }
  }
A cost function for region replicas. We give a very high cost to hosting replicas of the same
region in the same host. We do not prevent the case though, since if numReplicas >
numRegionServers, we still want to keep the replica open.
hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/RegionReplicaHostCostFunction.java