References
A consistent hashing implementation. The space described by the ring coincides with SHA-1 hashes, and so any two keys producing the same SHA-1 hash are considered identical within the ring.
Warning: It is not recommended that code outside this module make use of the structure of a chash.chash() = {num_partitions(), [node_entry()]}
A Node is the unique identifier for the owner of a given partition. An Erlang Pid works well here, but the chash module allows it to be any term.
chash_node() = term()
Indices into the ring, used as keys for object location, are binary representations of 160-bit integers.
index() = <<_:160>>
index_as_int() = integer()
node_entry() = {index_as_int(), chash_node()}
num_partitions() = pos_integer()
| contains_name/2 | Return true if named Node owns any partitions in the ring, else false. |
| fresh/2 | Create a brand new ring. |
| key_of/1 | Given any term used to name an object, produce that object's key into the ring. |
| lookup/2 | Find the Node that owns the partition identified by IndexAsInt. |
| members/1 | Return all Nodes that own any partitions in the ring. |
| merge_rings/2 | Return a randomized merge of two rings. |
| next_index/2 | Given the integer representation of a chash key, return the next ring index integer value. |
| nodes/1 | Return the entire set of NodeEntries in the ring. |
| predecessors/2 | Given an object key, return all NodeEntries in reverse order starting at Index. |
| predecessors/3 | Given an object key, return the next N NodeEntries in reverse order starting at Index. |
| ring_increment/1 | Return increment between ring indexes given the number of ring partitions. |
| size/1 | Return the number of partitions in the ring. |
| successors/2 | Given an object key, return all NodeEntries in order starting at Index. |
| successors/3 | Given an object key, return the next N NodeEntries in order starting at Index. |
| update/3 | Make the partition beginning at IndexAsInt owned by Name'd node. |
contains_name(Name::chash_node(), CHash::chash()) -> boolean()
Return true if named Node owns any partitions in the ring, else false.
fresh(NumPartitions::num_partitions(), SeedNode::chash_node()) -> chash()
Create a brand new ring. The size and seednode are specified; initially all partitions are owned by the seednode. If NumPartitions is not much larger than the intended eventual number of participating nodes, then performance will suffer.
key_of(ObjectName::term()) -> index()
Given any term used to name an object, produce that object's key into the ring. Two names with the same SHA-1 hash value are considered the same name.
lookup(IndexAsInt::index_as_int(), CHash::chash()) -> chash_node()
Find the Node that owns the partition identified by IndexAsInt.
members(CHash::chash()) -> [chash_node()]
Return all Nodes that own any partitions in the ring.
Return a randomized merge of two rings. If multiple nodes are actively claiming nodes in the same time period, churn will occur. Be prepared to live with it.
next_index(IntegerKey::integer(), CHash::chash()) -> index_as_int()
Given the integer representation of a chash key, return the next ring index integer value.
nodes(CHash::chash()) -> [node_entry()]
Return the entire set of NodeEntries in the ring.
predecessors(Index::index() | index_as_int(), CHash::chash()) -> [node_entry()]
Given an object key, return all NodeEntries in reverse order starting at Index.
predecessors(Index::index() | index_as_int(), CHash::chash(), N::integer()) -> [node_entry()]
Given an object key, return the next N NodeEntries in reverse order starting at Index.
ring_increment(NumPartitions::pos_integer()) -> pos_integer()
Return increment between ring indexes given the number of ring partitions.
size(CHash::chash()) -> integer()
Return the number of partitions in the ring.
successors(Index::index(), CHash::chash()) -> [node_entry()]
Given an object key, return all NodeEntries in order starting at Index.
successors(Index::index(), CHash::chash(), N::integer()) -> [node_entry()]
Given an object key, return the next N NodeEntries in order starting at Index.
update(IndexAsInt::index_as_int(), Name::chash_node(), CHash::chash()) -> chash()
Make the partition beginning at IndexAsInt owned by Name'd node.
Generated by EDoc