Class DoubleArrayCost

java.lang.Object
org.apache.hadoop.hbase.master.balancer.DoubleArrayCost

@Private final class DoubleArrayCost extends Object
A helper class to compute a scaled cost using DescriptiveStatistics(). It assumes that this is a zero sum set of costs. It assumes that the worst case possible is all of the elements in one region server and the rest having 0.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private double
     
    private double[]
     
    private boolean
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
    applyCostsChange(Consumer<double[]> consumer)
    We do not want to introduce a getCosts method to let upper layer get the cost array directly, so here we introduce this method to take a Consumer as parameter, where we will pass the actual cost array in, so you can change the element of the cost array in the Consumer implementation.
    private static double
    computeCost(double[] stats)
     
    (package private) double
     
    static double
    getMaxSkew(double total, double numServers)
    Return the max deviation of distribution Compute max as if all region servers had 0 and one had the sum of all costs.
    static double
    getMinSkew(double total, double numServers)
    Return the min skew of distribution
    private static double
    getSum(double[] stats)
     
    (package private) void
    prepare(int length)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • prepare

      void prepare(int length)
    • applyCostsChange

      void applyCostsChange(Consumer<double[]> consumer)
      We do not want to introduce a getCosts method to let upper layer get the cost array directly, so here we introduce this method to take a Consumer as parameter, where we will pass the actual cost array in, so you can change the element of the cost array in the Consumer implementation.

      Usually, in prepare method, you need to fill all the elements of the cost array, while in regionMoved method, you just need to update the element for the effect region servers.

    • cost

      double cost()
    • computeCost

      private static double computeCost(double[] stats)
    • getSum

      private static double getSum(double[] stats)
    • getMinSkew

      public static double getMinSkew(double total, double numServers)
      Return the min skew of distribution
      Parameters:
      total - is total number of regions
    • getMaxSkew

      public static double getMaxSkew(double total, double numServers)
      Return the max deviation of distribution Compute max as if all region servers had 0 and one had the sum of all costs. This must be a zero sum cost for this to make sense.