Module riak_core_ring

riak_core_ring manages a riak node's local view of partition ownership.

Description

riak_core_ring manages a riak node's local view of partition ownership. The functions in this module revolve around use of the chstate record, which should be treated as opaque by other modules. Riak nodes exchange instances of these records via gossip in order to converge on a common view of node/partition ownership.

Data Types

chstate()

chstate() = riak_core_ring()

member_status()

member_status() = joining | valid | invalid | leaving | exiting | down

partition_id()

partition_id() = non_neg_integer()

pending_change()

pending_change() = {Owner::node(), NextOwner::node(), awaiting | complete} | {undefined, undefined, undefined}

riak_core_dict()

riak_core_dict() = dict()

riak_core_ring()

riak_core_ring() = #chstate_v2{nodename = term(), vclock = vclock:vclock() | undefined, chring = chash:chash(), meta = riak_core_dict() | undefined, clustername = {term(), term()}, next = [{integer(), term(), term(), [module()], awaiting | complete}], members = [{node(), {member_status(), vclock:vclock(), [{atom(), term()}]}}], claimant = term(), seen = [{term(), vclock:vclock()}], rvsn = vclock:vclock()}

ring_size()

ring_size() = non_neg_integer()

Function Index

active_members/1Produce a list of all active (not marked as down) cluster members.
add_member/3
all_member_status/1Returns the current membership status for all nodes in the cluster.
all_members/1Produce a list of all nodes that are members of the cluster.
all_next_owners/1
all_owners/1Provide all ownership information in the form of {Index,Node} pairs.
all_preflists/2Provide every preflist in the ring, truncated at N.
awaiting_resize_transfer/3returns the first awaiting resize_transfer for a {SourceIdx, SourceNode} pair.
cancel_transfers/1Return a ring with all transfers cancelled - for claim sim.
chash/1Return the CHash of the ring.
check_tainted/2
claimant/1Return the current claimant.
claiming_members/1Return a list of all members of the cluster that are eligible to claim partitions.
clear_member_meta/3
cluster_name/1Returns the unique identifer for this cluster.
complete_resize_transfers/3
completed_next_owners/2
deletion_complete/3
diff_nodes/2For two rings, return the list of owners that have differing ownership.
disowning_indices/2Return all indices that a node is scheduled to give to another.
down_member/3
down_members/1Return a list of all members of the cluster that are marked as down.
downgrade/2Downgrade the latest ring structure to a specified version.
equal_rings/2
exit_member/3
fresh/0This is used only when this node is creating a brand new cluster.
fresh/1Equivalent to fresh/0 but allows specification of the local node name.
fresh/2Equivalent to fresh/1 but allows specification of the ring size.
future_index/3Given a key and an index in the current ring, determine which index will own the key in the future ring.
future_index/4
future_index/5
future_indices/2Return all partition indices that will be owned by a node after all pending ownership transfers have completed.
future_num_partitions/1
future_owner/2Return the node that will own this index after transtions have completed this function will error if the ring is shrinking and Idx no longer exists in it.
future_ring/1Return the ring that will exist after all pending ownership transfers have completed.
get_buckets/1return the names of all the custom buckets stored in the ring.
get_member_meta/3
get_meta/2Return a value from the cluster metadata dict.
handoff_complete/3Marks a pending transfer as completed.
increment_ring_version/2
increment_vclock/2
index_owner/2Return the node that owns the given index.
indices/2Return all partition indices owned by a node.
is_future_index/4
is_post_resize/1
is_primary/2Determine if a given Index/Node IdxNode combination is a primary.
is_resize_complete/1
is_resizing/1
leave_member/3
legacy_reconcile/2Incorporate another node's state into our view of the Riak world.
maybe_abort_resize/1
member_status/2Returns the current membership status for a node in the cluster.
members/2
my_indices/1Return all partition indices owned by the node executing this function.
nearly_equal/2Verify that the two rings are identical expect that metadata can differ and RingB's vclock is allowed to be equal or a direct descendant of RingA's vclock.
next_owner/2Return details for a pending partition ownership change.
next_owner/3Return details for a pending partition ownership change.
num_partitions/1Return the number of partitions in this Riak ring.
owner_node/1Return the node that is responsible for a given chstate.
pending_changes/1Returns a list of all pending ownership transfers.
preflist/2For a given object key, produce the ordered list of {partition,node} pairs that could be responsible for that object.
pretty_print/2
random_node/1Return a randomly-chosen node from amongst the owners.
random_other_active_node/1Return a randomly-chosen active node other than this one.
random_other_index/1Return a partition index not owned by the node executing this function.
random_other_index/2
random_other_node/1Return a randomly-chosen node from amongst the owners other than this one.
ready_members/1Returns a list of members guaranteed safe for requests.
reconcile/2Incorporate another node's state into our view of the Riak world.
reconcile_names/2
remove_member/3
remove_meta/2Logical delete of a key in the cluster metadata dict.
rename_node/3 Rename OldNode to NewNode in a Riak ring.
reschedule_resize_transfers/3reassign all outbound and inbound resize transfers from Node to NewNode
resize/2change the size of the ring to NewRingSize.
resize_transfer_complete/4mark a resize_transfer from Source to Target for Mod complete.
resize_transfer_status/4return the status of a resize_transfer for Source (an index-node pair).
resized_ring/1
responsible_index/2Determine the integer ring index responsible for a chash key.
ring_changed/2
ring_ready/0
ring_ready/1Returns true if all cluster members have seen the current ring.
ring_ready_info/1
ring_version/1
schedule_resize_transfer/3
set_chash/2
set_claimant/2
set_cluster_name/2Sets the unique identifer for this cluster.
set_member/4
set_member/5
set_owner/2Set the node that is responsible for a given chstate.
set_pending_changes/2
set_pending_resize/2Given a ring, Resizing, that has been resized (and presumably rebalanced) schedule a resize transition for Orig.
set_pending_resize_abort/1
set_resized_ring/2
set_tainted/1
transfer_node/3
update_member_meta/5Set a key in the member metadata orddict.
update_meta/3Set a key in the cluster metadata dict.
upgrade/1Upgrade old ring structures to the latest format.
vnode_type/2

Function Details

active_members/1

active_members(Chstate_v2) -> any()

Produce a list of all active (not marked as down) cluster members

add_member/3

add_member(PNode, State, Node) -> any()

all_member_status/1

all_member_status(State::chstate()) -> [{node(), member_status()}]

Returns the current membership status for all nodes in the cluster.

all_members/1

all_members(State::chstate()) -> [Node::term()]

Produce a list of all nodes that are members of the cluster

all_next_owners/1

all_next_owners(CState::chstate()) -> [{integer(), term()}]

all_owners/1

all_owners(State::chstate()) -> [{Index::integer(), Node::term()}]

Provide all ownership information in the form of {Index,Node} pairs.

all_preflists/2

all_preflists(State::chstate(), N::integer()) -> [[{Index::integer(), Node::term()}]]

Provide every preflist in the ring, truncated at N.

awaiting_resize_transfer/3

awaiting_resize_transfer(State::chstate(), Source::{integer(), term()}, Mod::atom()) -> {integer(), term()} | undefined

returns the first awaiting resize_transfer for a {SourceIdx, SourceNode} pair. If all transfers for the pair are complete, undefined is returned

cancel_transfers/1

cancel_transfers(Ring) -> any()

Return a ring with all transfers cancelled - for claim sim

chash/1

chash(Chstate_v2::chstate()) -> CHash::chash:chash()

Return the CHash of the ring.

check_tainted/2

check_tainted(Ring, Msg) -> any()

claimant/1

claimant(State::chstate()) -> node()

Return the current claimant.

claiming_members/1

claiming_members(State::chstate()) -> [Node::node()]

Return a list of all members of the cluster that are eligible to claim partitions.

clear_member_meta/3

clear_member_meta(Node, State, Member) -> any()

cluster_name/1

cluster_name(State::chstate()) -> term()

Returns the unique identifer for this cluster.

complete_resize_transfers/3

complete_resize_transfers(State::chstate(), Source::{integer(), term()}, Mod::atom()) -> [{integer(), term()}]

completed_next_owners/2

completed_next_owners(Mod, Chstate_v2) -> any()

deletion_complete/3

deletion_complete(State::chstate(), Idx::integer(), Mod::atom()) -> chstate()

diff_nodes/2

diff_nodes(State1::chstate(), State2::chstate()) -> [node()]

For two rings, return the list of owners that have differing ownership.

disowning_indices/2

disowning_indices(State, Node) -> any()

Return all indices that a node is scheduled to give to another.

down_member/3

down_member(PNode, State, Node) -> any()

down_members/1

down_members(State::chstate()) -> [Node::node()]

Return a list of all members of the cluster that are marked as down.

downgrade/2

downgrade(X1, Chstate_v2) -> any()

Downgrade the latest ring structure to a specified version.

equal_rings/2

equal_rings(A::chstate(), B::chstate()) -> boolean()

exit_member/3

exit_member(PNode, State, Node) -> any()

fresh/0

fresh() -> chstate()

This is used only when this node is creating a brand new cluster.

fresh/1

fresh(NodeName::term()) -> chstate()

Equivalent to fresh/0 but allows specification of the local node name. Called by fresh/0, and otherwise only intended for testing purposes.

fresh/2

fresh(RingSize::ring_size(), NodeName::term()) -> chstate()

Equivalent to fresh/1 but allows specification of the ring size. Called by fresh/1, and otherwise only intended for testing purposes.

future_index/3

future_index(CHashKey::chash:index(), OrigIdx::integer(), State::chstate()) -> integer() | undefined

Given a key and an index in the current ring, determine which index will own the key in the future ring. OrigIdx may or may not be the responsible index for that key (OrigIdx may not be the first index in CHashKey's preflist). The returned index will be in the same position in the preflist for CHashKey in the future ring. For regular transitions the returned index will always be OrigIdx. If the ring is resizing the index may be different

future_index/4

future_index(CHashKey::chash:index(), OrigIdx::integer(), NValCheck::undefined | integer(), State::chstate()) -> integer() | undefined

future_index/5

future_index(CHashKey, OrigIdx, NValCheck, OrigCount, NextCount) -> any()

future_indices/2

future_indices(State::chstate(), Node::node()) -> [integer()]

Return all partition indices that will be owned by a node after all pending ownership transfers have completed.

future_num_partitions/1

future_num_partitions(State::chstate()) -> pos_integer()

future_owner/2

future_owner(State::chstate(), Idx::chash:index_as_int()) -> term()

Return the node that will own this index after transtions have completed this function will error if the ring is shrinking and Idx no longer exists in it

future_ring/1

future_ring(State::chstate()) -> chstate()

Return the ring that will exist after all pending ownership transfers have completed.

get_buckets/1

get_buckets(State::chstate()) -> [term()]

return the names of all the custom buckets stored in the ring.

get_member_meta/3

get_member_meta(State, Member, Key) -> any()

get_meta/2

get_meta(Key::term(), State::chstate()) -> {ok, term()} | undefined

Return a value from the cluster metadata dict

handoff_complete/3

handoff_complete(State::chstate(), Idx::integer(), Mod::module()) -> chstate()

Marks a pending transfer as completed.

increment_ring_version/2

increment_ring_version(Node, State) -> any()

increment_vclock/2

increment_vclock(Node, State) -> any()

index_owner/2

index_owner(State::chstate(), Idx::chash:index_as_int()) -> Node::term()

Return the node that owns the given index.

indices/2

indices(State::chstate(), Node::node()) -> [integer()]

Return all partition indices owned by a node.

is_future_index/4

is_future_index(CHashKey::chash:index(), OrigIdx::integer(), TargetIdx::integer(), State::chstate()) -> boolean()

See also: future_index/4.

is_post_resize/1

is_post_resize(State::chstate()) -> boolean()

is_primary/2

is_primary(Ring::chstate(), IdxNode::{chash:index_as_int(), node()}) -> boolean()

Determine if a given Index/Node IdxNode combination is a primary.

is_resize_complete/1

is_resize_complete(Chstate_v2::chstate()) -> boolean()

is_resizing/1

is_resizing(State::chstate()) -> boolean()

leave_member/3

leave_member(PNode, State, Node) -> any()

legacy_reconcile/2

legacy_reconcile(ExternState, MyState) -> any()

Incorporate another node's state into our view of the Riak world.

maybe_abort_resize/1

maybe_abort_resize(State::chstate()) -> {boolean(), chstate()}

member_status/2

member_status(Chstate_v2::chstate() | [node()], Node::node()) -> member_status()

Returns the current membership status for a node in the cluster.

members/2

members(Chstate_v2, Types) -> any()

my_indices/1

my_indices(State::chstate()) -> [chash:index_as_int()]

Return all partition indices owned by the node executing this function.

nearly_equal/2

nearly_equal(RingA::chstate(), RingB::chstate()) -> boolean()

Verify that the two rings are identical expect that metadata can differ and RingB's vclock is allowed to be equal or a direct descendant of RingA's vclock. This matches the changes that the fix-up logic may make to a ring.

next_owner/2

next_owner(State::chstate(), Idx::integer()) -> pending_change()

Return details for a pending partition ownership change.

next_owner/3

next_owner(State::chstate(), Idx::integer(), Mod::module()) -> pending_change()

Return details for a pending partition ownership change.

num_partitions/1

num_partitions(State::chstate()) -> pos_integer()

Return the number of partitions in this Riak ring.

owner_node/1

owner_node(State::chstate()) -> Node::term()

Return the node that is responsible for a given chstate.

pending_changes/1

pending_changes(State) -> any()

Returns a list of all pending ownership transfers.

preflist/2

preflist(Key::binary(), State::chstate()) -> [{Index::chash:index_as_int(), Node::term()}]

For a given object key, produce the ordered list of {partition,node} pairs that could be responsible for that object.

pretty_print/2

pretty_print(Ring, Opts) -> any()

random_node/1

random_node(State::chstate()) -> Node::term()

Return a randomly-chosen node from amongst the owners.

random_other_active_node/1

random_other_active_node(State::chstate()) -> Node::term() | no_node

Return a randomly-chosen active node other than this one.

random_other_index/1

random_other_index(State::chstate()) -> chash:index_as_int()

Return a partition index not owned by the node executing this function. If this node owns all partitions, return any index.

random_other_index/2

random_other_index(State::chstate(), Exclude::[term()]) -> chash:index_as_int() | no_indices

random_other_node/1

random_other_node(State::chstate()) -> Node::term() | no_node

Return a randomly-chosen node from amongst the owners other than this one.

ready_members/1

ready_members(Chstate_v2) -> any()

Returns a list of members guaranteed safe for requests

reconcile/2

reconcile(ExternState::chstate(), MyState::chstate()) -> {no_change | new_ring, chstate()}

Incorporate another node's state into our view of the Riak world.

reconcile_names/2

reconcile_names(RingA, RingB) -> any()

remove_member/3

remove_member(PNode, State, Node) -> any()

remove_meta/2

remove_meta(Key::term(), State::chstate()) -> chstate()

Logical delete of a key in the cluster metadata dict

rename_node/3

rename_node(State::chstate(), OldNode::atom(), NewNode::atom()) -> chstate()

Rename OldNode to NewNode in a Riak ring.

reschedule_resize_transfers/3

reschedule_resize_transfers(State::chstate(), Node::term(), NewNode::term()) -> chstate()

reassign all outbound and inbound resize transfers from Node to NewNode

resize/2

resize(State::chstate(), NewRingSize::ring_size()) -> chstate()

change the size of the ring to NewRingSize. If the ring is larger than the current ring any new indexes will be owned by a dummy host

resize_transfer_complete/4

resize_transfer_complete(State::chstate(), Source::{integer(), term()}, Target::{integer(), term()}, Mod::atom()) -> chstate()

mark a resize_transfer from Source to Target for Mod complete. if all transfers for Source are complete, the corresponding entry in next is marked complete. This requires any other resize_transfers for Source that need to be started to be scheduled before calling this fuction

resize_transfer_status/4

resize_transfer_status(State::chstate(), Source::{integer(), term()}, Target::{integer(), term()}, Mod::atom()) -> awaiting | complete | undefined

return the status of a resize_transfer for Source (an index-node pair). undefined is returned if no such transfer is scheduled. complete is returned if the transfer is marked as such or Mod is contained in the completed modules set. awaiting is returned otherwise

resized_ring/1

resized_ring(State::chstate()) -> {ok, chash:chash()} | undefined

responsible_index/2

responsible_index(ChashKey::binary(), Chstate_v2::chstate()) -> integer()

Determine the integer ring index responsible for a chash key.

ring_changed/2

ring_changed(Node, State) -> any()

ring_ready/0

ring_ready() -> any()

ring_ready/1

ring_ready(State::chstate()) -> boolean()

Returns true if all cluster members have seen the current ring.

ring_ready_info/1

ring_ready_info(State0) -> any()

ring_version/1

ring_version(Chstate_v2) -> any()

schedule_resize_transfer/3

schedule_resize_transfer(State::chstate(), Source::{integer(), term()}, TargetIdx::integer() | {integer(), term()}) -> chstate()

set_chash/2

set_chash(State, CHash) -> any()

set_claimant/2

set_claimant(State, Claimant) -> any()

set_cluster_name/2

set_cluster_name(State, Name) -> any()

Sets the unique identifer for this cluster.

set_member/4

set_member(Node, CState, Member, Status) -> any()

set_member/5

set_member(Node, CState, Member, Status, X5) -> any()

set_owner/2

set_owner(State::chstate(), Node::node()) -> chstate()

Set the node that is responsible for a given chstate.

set_pending_changes/2

set_pending_changes(State, Transfers) -> any()

set_pending_resize/2

set_pending_resize(Resizing::chstate(), Orig::chstate()) -> chstate()

Given a ring, Resizing, that has been resized (and presumably rebalanced) schedule a resize transition for Orig.

set_pending_resize_abort/1

set_pending_resize_abort(State::chstate()) -> chstate()

set_resized_ring/2

set_resized_ring(State::chstate(), FutureCHash::chash:chash()) -> chstate()

set_tainted/1

set_tainted(Ring) -> any()

transfer_node/3

transfer_node(Idx::integer(), Node::term(), MyState::chstate()) -> chstate()

update_member_meta/5

update_member_meta(Node, State, Member, Key, Val) -> any()

Set a key in the member metadata orddict

update_meta/3

update_meta(Key::term(), Val::term(), State::chstate()) -> chstate()

Set a key in the cluster metadata dict

upgrade/1

upgrade(Old) -> any()

Upgrade old ring structures to the latest format.

vnode_type/2

vnode_type(State::chstate(), Idx::integer()) -> primary | {fallback, term()} | future_primary | resized_primary


Generated by EDoc