SuperCache.Cluster.Raft.Group (SuperCache v1.7.0)

Copy Markdown View Source

Maps SuperCache partitions to Raft server groups.

Each partition gets one Raft cluster named after the partition. The voting members are the partition's primary and replicas from SuperCache.Cluster.Manager, so all nodes sharing a partition map derive the same membership. The primary node creates the group; replica nodes host their server and wait for it to become available.

Summary

Functions

Return the cluster name for a partition.

Return {to_add, to_remove} between current and desired member ids.

Ensure this node has a started group for a partition.

Return the partition indexes this node currently owns.

Return the state machine tuple for a partition.

Return all server ids for a partition, in deterministic {name, node} order derived from the partition map.

Derive deterministic member ids from a {primary, replicas} tuple.

Return the local Raft server name for a partition.

Return this node's server id for a partition.

Start the Raft group for a partition.

Start groups for every partition owned by this node.

Stop the local Raft server for a partition.

Stop every local group started by this node.

Return the partition indexes with a local group started.

Forget all tracked groups without stopping their servers.

Functions

cluster_name(partition_idx)

@spec cluster_name(non_neg_integer()) :: atom()

Return the cluster name for a partition.

diff_members(current, desired)

@spec diff_members([term()], [term()]) :: {[term()], [term()]}

Return {to_add, to_remove} between current and desired member ids.

ensure_started(partition_idx)

@spec ensure_started(non_neg_integer()) :: :ok | {:error, term()}

Ensure this node has a started group for a partition.

local_partitions()

@spec local_partitions() :: [non_neg_integer()]

Return the partition indexes this node currently owns.

machine(partition_idx)

@spec machine(non_neg_integer()) :: tuple()

Return the state machine tuple for a partition.

member_ids(partition_idx)

@spec member_ids(non_neg_integer()) :: [{atom(), node()}]

Return all server ids for a partition, in deterministic {name, node} order derived from the partition map.

members_from(arg, partition_idx)

@spec members_from(
  {node(), [node()]},
  non_neg_integer()
) :: [{atom(), node()}]

Derive deterministic member ids from a {primary, replicas} tuple.

name(partition_idx)

@spec name(non_neg_integer()) :: atom()

Return the local Raft server name for a partition.

server_id(partition_idx)

@spec server_id(non_neg_integer()) :: {atom(), node()}

Return this node's server id for a partition.

start(partition_idx)

@spec start(non_neg_integer()) :: :ok | {:error, term()}

Start the Raft group for a partition.

start_all()

@spec start_all() :: :ok

Start groups for every partition owned by this node.

stop(partition_idx)

@spec stop(non_neg_integer()) :: :ok | {:error, term()}

Stop the local Raft server for a partition.

stop_all()

@spec stop_all() :: :ok

Stop every local group started by this node.

tracked()

@spec tracked() :: [non_neg_integer()]

Return the partition indexes with a local group started.

untrack_all()

@spec untrack_all() :: :ok

Forget all tracked groups without stopping their servers.