@Override
  protected void regionMoved(int region, int oldServer, int newServer) {
    if (maxCost <= 0) {
      return; // no need to compute
    }
    if (cluster.multiServersPerHost) {
      int oldHost = cluster.serverIndexToHostIndex[oldServer];
      int newHost = cluster.serverIndexToHostIndex[newServer];
      if (newHost != oldHost) {
        costsPerGroup[oldHost] = costPerGroup(cluster.colocatedReplicaCountsPerHost[oldHost]);
        costsPerGroup[newHost] = costPerGroup(cluster.colocatedReplicaCountsPerHost[newHost]);
      }
    } else {
      costsPerGroup[oldServer] = costPerGroup(cluster.colocatedReplicaCountsPerServer[oldServer]);
      costsPerGroup[newServer] = costPerGroup(cluster.colocatedReplicaCountsPerServer[newServer]);
    }
  }
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