public class

IdealState

extends HelixProperty
java.lang.Object
   ↳ org.apache.helix.HelixProperty
     ↳ org.apache.helix.model.IdealState

Class Overview

The ideal states of all partitions in a resource

Summary

Nested Classes
enum IdealState.IdealStateModeProperty Deprecated. 
enum IdealState.IdealStateProperty Properties that are persisted and are queryable for an ideal state  
enum IdealState.RebalanceMode The mode used for rebalance. 
Constants
String QUERY_LIST
[Expand]
Inherited Fields
From class org.apache.helix.HelixProperty
Public Constructors
IdealState(String resourceName)
Instantiate an ideal state for a resource
IdealState(ZNRecord record)
Instantiate an ideal state from a record
Public Methods
IdealState.IdealStateModeProperty getIdealStateMode()
Get the rebalancing mode on this resource
String getInstanceGroupTag()
Check for a tag that will restrict assignment to instances with a matching tag
Set<String> getInstanceSet(String partitionName)
Get the instances who host replicas of a partition
Map<StringString> getInstanceStateMap(String partitionName)
Get the current mapping of a partition
int getMaxPartitionsPerInstance()
Get the maximum number of partitions an instance can serve
int getNumPartitions()
Get the number of partitions of this resource
Set<String> getPartitionSet()
Get all of the partitions
List<String> getPreferenceList(String partitionName)
Get the preference list of a partition
IdealState.RebalanceMode getRebalanceMode()
Get the rebalancing mode on this resource
int getRebalanceTimerPeriod()
Set the frequency with which to rebalance
String getRebalancerClassName()
Get the name of the user-defined rebalancer associated with this resource
String getReplicas()
Get the number of replicas for each partition of this resource
String getResourceName()
Get the associated resource
String getStateModelDefRef()
Get the state model associated with this resource
String getStateModelFactoryName()
Get the state model factory associated with this resource
boolean isValid()
Get property validity
IdealState.RebalanceMode rebalanceModeFromString(String mode, IdealState.RebalanceMode defaultMode)
Parse a RebalanceMode from a string.
void setIdealStateMode(String mode)
Get the rebalance mode of the ideal state
void setInstanceGroupTag(String groupTag)
Set a tag to check to enforce assignment to certain instances
void setMaxPartitionsPerInstance(int max)
Set the maximum number of partitions of this resource that an instance can serve
void setNumPartitions(int numPartitions)
Set the number of partitions of this resource
void setPartitionState(String partitionName, String instanceName, String state)
Set the preferred instance placement and state for a partition replica
void setRebalanceMode(IdealState.RebalanceMode rebalancerType)
Get the rebalance mode of the resource
void setRebalancerClassName(String rebalancerClassName)
Define a custom rebalancer that implements Rebalancer
void setReplicas(String replicas)
Set the number of replicas for each partition of this resource.
void setStateModelDefRef(String stateModel)
Set the state model associated with this resource
void setStateModelFactoryName(String name)
Set the state model factory associated with this resource
[Expand]
Inherited Methods
From class org.apache.helix.HelixProperty
From class java.lang.Object

Constants

public static final String QUERY_LIST

Constant Value: "PREFERENCE_LIST_QUERYS"

Public Constructors

public IdealState (String resourceName)

Instantiate an ideal state for a resource

Parameters
resourceName the name of the resource

public IdealState (ZNRecord record)

Instantiate an ideal state from a record

Parameters
record ZNRecord corresponding to an ideal state

Public Methods

public IdealState.IdealStateModeProperty getIdealStateMode ()

Get the rebalancing mode on this resource

public String getInstanceGroupTag ()

Check for a tag that will restrict assignment to instances with a matching tag

Returns
  • the group tag, or null if none is present

public Set<String> getInstanceSet (String partitionName)

Get the instances who host replicas of a partition

Parameters
partitionName the partition to look up
Returns
  • set of instance names

public Map<StringString> getInstanceStateMap (String partitionName)

Get the current mapping of a partition

Parameters
partitionName the name of the partition
Returns
  • the instances where the replicas live and the state of each

public int getMaxPartitionsPerInstance ()

Get the maximum number of partitions an instance can serve

Returns
  • the partition capacity of an instance for this resource, or Integer.MAX_VALUE

public int getNumPartitions ()

Get the number of partitions of this resource

Returns
  • the number of partitions

public Set<String> getPartitionSet ()

Get all of the partitions

Returns
  • a set of partition names

public List<String> getPreferenceList (String partitionName)

Get the preference list of a partition

Parameters
partitionName the name of the partition
Returns
  • a list of instances that can serve replicas of the partition

public IdealState.RebalanceMode getRebalanceMode ()

Get the rebalancing mode on this resource

public int getRebalanceTimerPeriod ()

Set the frequency with which to rebalance

Returns
  • the rebalancing timer period

public String getRebalancerClassName ()

Get the name of the user-defined rebalancer associated with this resource

Returns
  • the rebalancer class name, or null if none is being used

public String getReplicas ()

Get the number of replicas for each partition of this resource

Returns
  • number of replicas (as a string)

public String getResourceName ()

Get the associated resource

Returns
  • the name of the resource

public String getStateModelDefRef ()

Get the state model associated with this resource

Returns
  • an identifier of the state model

public String getStateModelFactoryName ()

Get the state model factory associated with this resource

Returns
  • state model factory name

public boolean isValid ()

Get property validity

Returns
  • true if valid, false if invalid

public IdealState.RebalanceMode rebalanceModeFromString (String mode, IdealState.RebalanceMode defaultMode)

Parse a RebalanceMode from a string. It can also understand IdealStateModeProperty values.

Parameters
mode string containing a RebalanceMode value
defaultMode the mode to use if the string is not valid
Returns
  • converted RebalanceMode value

public void setIdealStateMode (String mode)

Get the rebalance mode of the ideal state

public void setInstanceGroupTag (String groupTag)

Set a tag to check to enforce assignment to certain instances

Parameters
groupTag the instance group tag

public void setMaxPartitionsPerInstance (int max)

Set the maximum number of partitions of this resource that an instance can serve

Parameters
max the maximum number of partitions supported

public void setNumPartitions (int numPartitions)

Set the number of partitions of this resource

Parameters
numPartitions the number of partitions

public void setPartitionState (String partitionName, String instanceName, String state)

Set the preferred instance placement and state for a partition replica

Parameters
partitionName the replica to set
instanceName the assigned instance
state the replica state in this instance

public void setRebalanceMode (IdealState.RebalanceMode rebalancerType)

Get the rebalance mode of the resource

public void setRebalancerClassName (String rebalancerClassName)

Define a custom rebalancer that implements Rebalancer

Parameters
rebalancerClassName the name of the custom rebalancing class

public void setReplicas (String replicas)

Set the number of replicas for each partition of this resource. There are documented special values for the replica count, so this is a String.

Parameters
replicas replica count (as a string)

public void setStateModelDefRef (String stateModel)

Set the state model associated with this resource

Parameters
stateModel state model identifier

public void setStateModelFactoryName (String name)

Set the state model factory associated with this resource

Parameters
name state model factory name