Class AllocationBalancingRoundSummaryService

java.lang.Object
org.elasticsearch.cluster.routing.allocation.allocator.AllocationBalancingRoundSummaryService

public class AllocationBalancingRoundSummaryService extends Object
Manages the lifecycle of a series of BalancingRoundSummary results from allocation balancing rounds and creates reports thereof. Reporting balancer round summary results will provide information with which to do cost-benefit analyses of the work that shard allocation rebalancing executes. Any successfully added summary via addBalancerRoundSummary(BalancingRoundSummary) will eventually be collected/drained and reported. This should still be done in the event of the node stepping down from master, on the assumption that all summaries are only added while master and should be drained for reporting. There is no need to start/stop this service with master election/stepdown because balancer rounds will no longer be supplied when not master. It will simply drain the last summaries and then have nothing more to do. This does have the tradeoff that non-master nodes will run a task to check for summaries to report every BALANCER_ROUND_SUMMARIES_LOG_INTERVAL_SETTING seconds.
  • Field Details

    • ENABLE_BALANCER_ROUND_SUMMARIES_SETTING

      public static final Setting<Boolean> ENABLE_BALANCER_ROUND_SUMMARIES_SETTING
      Turns on or off balancing round summary reporting.
    • BALANCER_ROUND_SUMMARIES_LOG_INTERVAL_SETTING

      public static final Setting<TimeValue> BALANCER_ROUND_SUMMARIES_LOG_INTERVAL_SETTING
      Controls how frequently in time balancer round summaries are logged.
  • Constructor Details

    • AllocationBalancingRoundSummaryService

      public AllocationBalancingRoundSummaryService(ThreadPool threadPool, ClusterSettings clusterSettings)
  • Method Details

    • createBalancerRoundSummary

      public static BalancingRoundSummary createBalancerRoundSummary(DesiredBalance oldDesiredBalance, DesiredBalance newDesiredBalance)
      Summarizes the work required to move from an old to new desired balance shard allocation.
    • addBalancerRoundSummary

      public void addBalancerRoundSummary(DesiredBalance oldDesiredBalance, DesiredBalance newDesiredBalance)
      Creates and saves a balancer round summary for the work to move from oldDesiredBalance to newDesiredBalance. If balancer round summaries are not enabled in the cluster (see ENABLE_BALANCER_ROUND_SUMMARIES_SETTING), then the summary is immediately discarded.
    • addBalancerRoundSummary

      public void addBalancerRoundSummary(BalancingRoundSummary summary)
      Adds the summary of a balancing round. If summaries are enabled, this will eventually be reported (logging, etc.). If balancer round summaries are not enabled in the cluster, then the summary is immediately discarded (so as not to fill up a data structure that will never be drained).
    • verifyNumberOfSummaries

      protected void verifyNumberOfSummaries(int numberOfSummaries)
      Checks that the number of entries in summaries matches the given numberOfSummaries.