public class

ResourceAssignment

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

Class Overview

Represents the assignments of replicas for an entire resource, keyed on partitions of the resource. Each partition has its replicas assigned to a node, and each replica is in a state. For example, if there is a partition p with 2 replicas, a valid assignment is:

p: {(n1, s1), (n2, s2)}

This means one replica of p is located at node n1 and is in state s1, and another is in node n2 and is in state s2. n1 cannot be equal to n2, but s1 can be equal to s2 if at least two replicas can be in s1.

Summary

[Expand]
Inherited Fields
From class org.apache.helix.HelixProperty
Public Constructors
ResourceAssignment(String resourceName)
Initialize an empty mapping
ResourceAssignment(ZNRecord existingMapping)
Initialize a mapping from an existing ResourceMapping
Public Methods
void addReplicaMap(Partition partition, Map<StringString> replicaMap)
Add instance, state pairs for a partition
List<Partition> getMappedPartitions()
Get the currently mapped partitions
Map<StringString> getReplicaMap(Partition partition)
Get the instance, state pairs for a partition
String getResourceName()
Get the resource for which this assignment was created
[Expand]
Inherited Methods
From class org.apache.helix.HelixProperty
From class java.lang.Object

Public Constructors

public ResourceAssignment (String resourceName)

Initialize an empty mapping

Parameters
resourceName the resource being mapped

public ResourceAssignment (ZNRecord existingMapping)

Initialize a mapping from an existing ResourceMapping

Parameters
existingMapping pre-populated ResourceMapping

Public Methods

public void addReplicaMap (Partition partition, Map<StringString> replicaMap)

Add instance, state pairs for a partition

Parameters
partition the partition to set
replicaMap map of (instance name, state)

public List<Partition> getMappedPartitions ()

Get the currently mapped partitions

Returns
  • list of Partition objects

public Map<StringString> getReplicaMap (Partition partition)

Get the instance, state pairs for a partition

Parameters
partition the Partition to look up
Returns
  • map of (instance name, state)

public String getResourceName ()

Get the resource for which this assignment was created

Returns
  • resource name