private double computeCostForRegionServer(int regionServerIndex) {
    // Cost this server has from RegionLoad
    double cost = 0;

    // for every region on this server get the rl
    for (int regionIndex : cluster.regionsPerServer[regionServerIndex]) {
      Collection<BalancerRegionLoad> regionLoadList = cluster.regionLoads[regionIndex];

      // Now if we found a region load get the type of cost that was requested.
      if (regionLoadList != null) {
        cost += getRegionLoadCost(regionLoadList);
      }
    }
    return cost;
  }
Base class the allows writing costs functions from rolling average of some number from
RegionLoad.
hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/CostFromRegionLoadFunction.java