Class CostFunction

java.lang.Object
org.apache.hadoop.hbase.master.balancer.CostFunction
Direct Known Subclasses:
CacheAwareLoadBalancer.CacheAwareCostFunction, CacheAwareLoadBalancer.CacheAwareRegionSkewnessCostFunction, CostFromRegionLoadFunction, HeterogeneousRegionCountCostFunction, LocalityBasedCostFunction, MoveCostFunction, PrimaryRegionCountSkewCostFunction, RegionCountSkewCostFunction, RegionReplicaGroupingCostFunction, TableSkewCostFunction

@Private abstract class CostFunction extends Object
Base class of StochasticLoadBalancer's Cost Functions.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
    static final double
     
    private float
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract double
     
    (package private) float
     
    (package private) boolean
     
    (package private) void
    Called once per cluster Action to give the cost function an opportunity to update it's state.
    (package private) void
    Called once per LB invocation to give the cost function to initialize it's state, and perform any costly calculation.
    protected void
    regionMoved(int region, int oldServer, int newServer)
     
    protected static double
    scale(double min, double max, double value)
    Scale the value between 0 and 1.
    (package private) void
    setMultiplier(float m)
     
    void
    updateWeight(double[] weights)
    Add the cost of this cost function to the weight of the candidate generator that is optimized for this cost function.

    Methods inherited from class java.lang.Object

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

  • Constructor Details

  • Method Details

    • isNeeded

      boolean isNeeded()
    • getMultiplier

      float getMultiplier()
    • setMultiplier

      void setMultiplier(float m)
    • prepare

      Called once per LB invocation to give the cost function to initialize it's state, and perform any costly calculation.
    • postAction

      void postAction(BalanceAction action)
      Called once per cluster Action to give the cost function an opportunity to update it's state. postAction() is always called at least once before cost() is called with the cluster that this action is performed on.
    • regionMoved

      protected void regionMoved(int region, int oldServer, int newServer)
    • cost

      protected abstract double cost()
    • scale

      protected static double scale(double min, double max, double value)
      Scale the value between 0 and 1.
      Parameters:
      min - Min value
      max - The Max value
      value - The value to be scaled.
      Returns:
      The scaled value.
    • updateWeight

      public void updateWeight(double[] weights)
      Add the cost of this cost function to the weight of the candidate generator that is optimized for this cost function. By default it is the RandomCandiateGenerator for a cost function. Called once per init or after postAction.
      Parameters:
      weights - the weights for every generator.