java.lang.Object | |
↳ | org.apache.helix.controller.strategy.DefaultTwoStateStrategy |
DefaultIdealStateCalculator tries to optimally allocate two state partitions among storage nodes. Given a batch of storage nodes, the partition and replication factor, the algorithm first given a initial state When new batches of storage nodes are added, the algorithm will calculate the new ideal state such that the total partition movements are minimized.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Calculate the initial ideal state given a batch of storage instances, the replication factor
and
number of partitions
1.
| |||||||||||
Calculate the initial ideal state given a batch of storage instances, the replication factor
and
number of partitions
1.
| |||||||||||
Given the current idealState, and the list of new Instances needed to be added, calculate the
new Ideal state.
| |||||||||||
Convert the internal result (stored as a Map
| |||||||||||
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Calculate the initial ideal state given a batch of storage instances, the replication factor and number of partitions 1. Calculate the primary state assignment by random shuffling 2. for each storage instance, calculate the 1st secondary state assignment map, by another random shuffling 3. for each storage instance, calculate the i-th secondary state assignment map 4. Combine the i-th secondary state assignment maps together
instanceNames | list of storage node instances |
---|---|
partitions | number of partitions |
replicas | The number of replicas (secondary partitions) per primary partition |
primaryStateValue | primary state value: e.g. "MASTER" or "LEADER" |
secondaryStateValue | secondary state value: e.g. "SLAVE" or "STANDBY" |
Calculate the initial ideal state given a batch of storage instances, the replication factor and number of partitions 1. Calculate the primary assignment by random shuffling 2. for each storage instance, calculate the 1st secondary state assignment map, by another random shuffling 3. for each storage instance, calculate the i-th secondary state assignment map 4. Combine the i-th secondary state assignment maps together
instanceNames | list of storage node instances |
---|---|
partitions | number of partitions |
replicas | The number of replicas (secondary partitions) per primary partition |
Given the current idealState, and the list of new Instances needed to be added, calculate the new Ideal state. 1. Calculate how many primary partitions should be moved to the new cluster of instances 2. assign the number of primary partitions px to be moved to each previous node 3. for each previous node, 3.1 randomly choose px nodes, move them to temp list 3.2 for each px nodes, remove them from the secondary assignment map; record the map position of the partition; 3.3 calculate # of new nodes that should be put in the secondary assignment map 3.4 even-fy the secondary assignment map; 3.5 randomly place # of new nodes that should be placed in 4. from all the temp primary node list get from 3.1, 4.1 randomly assign them to nodes in the new cluster 5. for each node in the new cluster, 5.1 assemble the secondary assignment map 5.2 even-fy the secondary assignment map
newInstances | list of new added storage node instances |
---|---|
previousIdealState | The previous ideal state |
Convert the internal result (stored as a Map