public class

AutoRebalanceStrategy

extends Object
java.lang.Object
   ↳ org.apache.helix.controller.strategy.AutoRebalanceStrategy

Summary

Nested Classes
class AutoRebalanceStrategy.DefaultPlacementScheme Compute preferred placements based on a default strategy that assigns replicas to nodes as evenly as possible while avoiding placing two replicas of the same partition on any node. 
interface AutoRebalanceStrategy.ReplicaPlacementScheme Interface for providing a custom approach to computing a replica's affinity to a node. 
Public Constructors
AutoRebalanceStrategy(String resourceName, List<String> partitions, LinkedHashMap<StringInteger> states, int maximumPerNode, AutoRebalanceStrategy.ReplicaPlacementScheme placementScheme)
Initialize this strategy for a resource
AutoRebalanceStrategy(String resourceName, List<String> partitions, LinkedHashMap<StringInteger> states)
Initialize the strategy with a default placement scheme
AutoRebalanceStrategy(ResourceId resourceId, List<PartitionId> partitions, LinkedHashMap<StateInteger> states, int maximumPerNode, AutoRebalanceStrategy.ReplicaPlacementScheme placementScheme)
Constructor to support logically-typed Helix components
Public Methods
ZNRecord computePartitionAssignment(List<String> liveNodes, Map<StringMap<StringString>> currentMapping, List<String> allNodes)
Determine a preference list and mapping of partitions to nodes for all replicas
ZNRecord typedComputePartitionAssignment(List<ParticipantId> liveNodes, Map<PartitionIdMap<ParticipantIdState>> currentMapping, List<ParticipantId> allNodes)
Wrap computePartitionAssignment(List, Map, List) with a function that takes concrete types
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public AutoRebalanceStrategy (String resourceName, List<String> partitions, LinkedHashMap<StringInteger> states, int maximumPerNode, AutoRebalanceStrategy.ReplicaPlacementScheme placementScheme)

Initialize this strategy for a resource

Parameters
resourceName the resource for which an assignment will be computed
partitions the partition names for the resource
states the states and the number of replicas that should be in each state
maximumPerNode the maximum number of replicas any note can hold
placementScheme the scheme to use for preferred replica locations. If null, this is AutoRebalanceStrategy.DefaultPlacementScheme

public AutoRebalanceStrategy (String resourceName, List<String> partitions, LinkedHashMap<StringInteger> states)

Initialize the strategy with a default placement scheme

public AutoRebalanceStrategy (ResourceId resourceId, List<PartitionId> partitions, LinkedHashMap<StateInteger> states, int maximumPerNode, AutoRebalanceStrategy.ReplicaPlacementScheme placementScheme)

Constructor to support logically-typed Helix components

Parameters
resourceId the resource for which to compute an assignment
partitions the partitions of the resource
states the states and counts for each state
maximumPerNode the maximum number of replicas per node
placementScheme the scheme to use for preferred replica locations. If null, this is AutoRebalanceStrategy.DefaultPlacementScheme

Public Methods

public ZNRecord computePartitionAssignment (List<String> liveNodes, Map<StringMap<StringString>> currentMapping, List<String> allNodes)

Determine a preference list and mapping of partitions to nodes for all replicas

Parameters
liveNodes the current list of live participants
currentMapping the current assignment of replicas to nodes
allNodes the full list of known nodes in the system
Returns
  • the preference list and replica mapping

public ZNRecord typedComputePartitionAssignment (List<ParticipantId> liveNodes, Map<PartitionIdMap<ParticipantIdState>> currentMapping, List<ParticipantId> allNodes)

Wrap computePartitionAssignment(List, Map, List) with a function that takes concrete types

Parameters
liveNodes list of live participant ids
currentMapping map of partition id to map of participant id to state
allNodes list of all participant ids
Returns
  • the preference list and replica mapping