private double computeCostForRegionServer(int regionServerIndex) {
    int cost = 0;
    for (int regionIdx : cluster.regionsPerServer[regionServerIndex]) {
      if (regionIdx == cluster.regionIndexToPrimaryIndex[regionIdx]) {
        cost++;
      }
    }
    return cost;
  }
Compute the cost of a potential cluster state from skew in number of primary regions on a
cluster.
hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/PrimaryRegionCountSkewCostFunction.java