pub struct RoutingTable { /* private fields */ }Expand description
Maps vShards to Raft groups and Raft groups to nodes.
The 1024 vShards are divided into distinct Raft Groups (e.g., vShards 0-63 managed by Raft Group 1 across Nodes A, B, and C).
This table is the authoritative routing source. It is updated atomically via Raft state machine when:
- A shard migration completes (Phase 3 atomic cut-over)
- A Raft group membership changes
- A node joins or decommissions
Implementations§
Source§impl RoutingTable
impl RoutingTable
Sourcepub fn uniform(
num_groups: u64,
nodes: &[u64],
replication_factor: usize,
) -> Self
pub fn uniform( num_groups: u64, nodes: &[u64], replication_factor: usize, ) -> Self
Create a routing table with uniform distribution of vShards across data groups.
num_groups is the number of data Raft groups. vShards are distributed
round-robin across groups 1..=num_groups. Group 0 is the metadata group and
is always included in group_members but is never assigned any vShards —
it is accessed only via propose_to_metadata_group, never via
propose(vshard_id, data).
Each data group initially contains replication_factor nodes from nodes.
The metadata group (0) receives the same membership as the first data group.
Sourcepub fn group_for_vshard(&self, vshard_id: u32) -> Result<u64>
pub fn group_for_vshard(&self, vshard_id: u32) -> Result<u64>
Look up which Raft group owns a vShard.
Sourcepub fn leader_for_vshard(&self, vshard_id: u32) -> Result<u64>
pub fn leader_for_vshard(&self, vshard_id: u32) -> Result<u64>
Look up the leader node for a vShard.
Sourcepub fn group_info(&self, group_id: u64) -> Option<&GroupInfo>
pub fn group_info(&self, group_id: u64) -> Option<&GroupInfo>
Get group info.
Sourcepub fn set_leader(&mut self, group_id: u64, leader: u64)
pub fn set_leader(&mut self, group_id: u64, leader: u64)
Update the leader for a Raft group.
Sourcepub fn reassign_vshard(&mut self, vshard_id: u32, new_group_id: u64)
pub fn reassign_vshard(&mut self, vshard_id: u32, new_group_id: u64)
Atomically reassign a vShard to a different Raft group. Used during Phase 3 (atomic cut-over) of shard migration.
Sourcepub fn vshards_for_group(&self, group_id: u64) -> Vec<u32>
pub fn vshards_for_group(&self, group_id: u64) -> Vec<u32>
All vShards assigned to a given group.
Sourcepub fn num_groups(&self) -> usize
pub fn num_groups(&self) -> usize
Number of Raft groups.
Sourcepub fn set_group_members(&mut self, group_id: u64, members: Vec<u64>)
pub fn set_group_members(&mut self, group_id: u64, members: Vec<u64>)
Update the voting members of a Raft group (for membership changes).
Sourcepub fn remove_group_member(&mut self, group_id: u64, node_id: u64) -> bool
pub fn remove_group_member(&mut self, group_id: u64, node_id: u64) -> bool
Remove a node from a group’s voter and learner lists. If the
removed node was the current leader hint, the hint is cleared
so the next query drives a fresh discovery. Returns true if
the group existed and anything was actually removed.
The caller is responsible for safety: dropping below the
configured replication factor must be gated by
decommission::safety::check_can_decommission.
Sourcepub fn set_group_learners(&mut self, group_id: u64, learners: Vec<u64>)
pub fn set_group_learners(&mut self, group_id: u64, learners: Vec<u64>)
Update the learner list for a Raft group.
Sourcepub fn add_group_learner(&mut self, group_id: u64, peer: u64)
pub fn add_group_learner(&mut self, group_id: u64, peer: u64)
Add a learner to a group if not already present. No-op if the peer is already a voter or a learner.
Sourcepub fn promote_group_learner(&mut self, group_id: u64, peer: u64) -> bool
pub fn promote_group_learner(&mut self, group_id: u64, peer: u64) -> bool
Promote a learner to a voter within a group. Returns true if the
learner was found and promoted.
Sourcepub fn vshard_to_group(&self) -> &[u64]
pub fn vshard_to_group(&self) -> &[u64]
Access the vshard-to-group mapping (for persistence / wire transfer).
Sourcepub fn group_members(&self) -> &HashMap<u64, GroupInfo>
pub fn group_members(&self) -> &HashMap<u64, GroupInfo>
Access all group members (for persistence / wire transfer).
Trait Implementations§
Source§impl Clone for RoutingTable
impl Clone for RoutingTable
Source§fn clone(&self) -> RoutingTable
fn clone(&self) -> RoutingTable
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RoutingTable
impl Debug for RoutingTable
Source§impl<'de> Deserialize<'de> for RoutingTable
impl<'de> Deserialize<'de> for RoutingTable
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<'__msgpack_de> FromMessagePack<'__msgpack_de> for RoutingTable
impl<'__msgpack_de> FromMessagePack<'__msgpack_de> for RoutingTable
Source§impl Serialize for RoutingTable
impl Serialize for RoutingTable
Auto Trait Implementations§
impl Freeze for RoutingTable
impl RefUnwindSafe for RoutingTable
impl Send for RoutingTable
impl Sync for RoutingTable
impl Unpin for RoutingTable
impl UnsafeUnpin for RoutingTable
impl UnwindSafe for RoutingTable
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.