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 groups.
num_groups Raft groups are created. vShards are distributed round-robin.
Each group initially contains nodes_per_group nodes from the nodes list.
Sourcepub fn group_for_vshard(&self, vshard_id: u16) -> Result<u64>
pub fn group_for_vshard(&self, vshard_id: u16) -> Result<u64>
Look up which Raft group owns a vShard.
Sourcepub fn leader_for_vshard(&self, vshard_id: u16) -> Result<u64>
pub fn leader_for_vshard(&self, vshard_id: u16) -> 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: u16, new_group_id: u64)
pub fn reassign_vshard(&mut self, vshard_id: u16, 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<u16>
pub fn vshards_for_group(&self, group_id: u64) -> Vec<u16>
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 members of a Raft group (for membership changes).
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 · 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<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.