public class

AutoRebalancer

extends Object
implements Rebalancer MappingCalculator
java.lang.Object
   ↳ org.apache.helix.controller.rebalancer.AutoRebalancer

Class Overview

This is a Rebalancer specific to full automatic mode. It is tasked with computing the ideal state of a resource, fully adapting to the addition or removal of instances. This includes computation of a new preference list and a partition to instance and state mapping based on the computed instance preferences. The input is the current assignment of partitions to instances, as well as existing instance preferences, if any. The output is a preference list and a mapping based on that preference list, i.e. partition p has a replica on node k with state s.

Summary

Public Constructors
AutoRebalancer()
Public Methods
ResourceAssignment computeBestPossiblePartitionState(ClusterDataCache cache, IdealState idealState, Resource resource, CurrentStateOutput currentStateOutput)
Given an ideal state for a resource and the liveness of instances, compute the best possible state assignment for each partition's replicas.
IdealState computeNewIdealState(String resourceName, IdealState currentIdealState, CurrentStateOutput currentStateOutput, ClusterDataCache clusterData)
This method provides all the relevant information needed to rebalance a resource.
void init(HelixManager manager)
static LinkedHashMap<StringInteger> stateCount(StateModelDefinition stateModelDef, int liveNodesNb, int totalReplicas)
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.apache.helix.controller.rebalancer.Rebalancer
From interface org.apache.helix.controller.rebalancer.internal.MappingCalculator

Public Constructors

public AutoRebalancer ()

Public Methods

public ResourceAssignment computeBestPossiblePartitionState (ClusterDataCache cache, IdealState idealState, Resource resource, CurrentStateOutput currentStateOutput)

Given an ideal state for a resource and the liveness of instances, compute the best possible state assignment for each partition's replicas.

Parameters
currentStateOutput Provides the current state and pending state transitions for all partitions

public IdealState computeNewIdealState (String resourceName, IdealState currentIdealState, CurrentStateOutput currentStateOutput, ClusterDataCache clusterData)

This method provides all the relevant information needed to rebalance a resource. If you need additional information use manager.getAccessor to read the cluster data. This allows one to compute the newIdealState according to app specific requirement.

Parameters
resourceName Name of the resource to be rebalanced
currentStateOutput Provides the current state and pending state transition for all partitions
clusterData Provides additional methods to retrieve cluster data.

public void init (HelixManager manager)

public static LinkedHashMap<StringInteger> stateCount (StateModelDefinition stateModelDef, int liveNodesNb, int totalReplicas)

Returns
  • state count map: state->count