pub struct TabletDescriptor {
pub tablet_id: TabletId,
pub table_id: TableId,
pub database_id: DatabaseId,
pub raft_group_id: RaftGroupId,
pub partition: PartitionBounds,
pub replicas: Vec<ReplicaDescriptor>,
pub leader_hint: Option<NodeId>,
pub generation: u64,
pub state: TabletState,
}Expand description
One independently replicated data partition (spec section 12.1).
generation advances at every atomic descriptor publication (split,
merge, move); every request carries the generation it was routed with,
and a mismatch is classified by check_generation.
Publication generation rules (spec sections 12.5-12.6; the protocols live
in crate::split and crate::merge):
- Split: the source is marked
TabletState::Splittingatg + 1(g= the pre-split generation); the children are createdCreatingatg + 1and are never routed to; the atomic routing publication assigns one new generationp = (source generation at publication) + 1, taking the childrenCreating -> Activeand the sourceSplitting -> Retiringtogether. A request holdinggagainst the splitting source is classifiedRoutingError::TabletSplit; after publication any generation belowpagainst the retiring source isRoutingError::TabletMoved. - Merge: each source is marked
TabletState::Mergingat its owng + 1; the publication generation isp = max(sources' generations at publication) + 1, assigned to the replacement (Creating -> Active) and to both sources (Merging -> Retiring) in one atomic command. - Source removal publishes
Retiring -> Retiredatp + 1before the descriptor is deleted.
Fields§
§tablet_id: TabletIdThe tablet’s identity.
table_id: TableIdTable the tablet belongs to.
database_id: DatabaseIdLogical database owning the table (meta-resolved). When zero on a
legacy descriptor, the runtime resolves via meta
table_id → database_id before falling back to a deterministic
raft-group-derived id for pre-metadata tablets only.
raft_group_id: RaftGroupIdRaft group replicating the tablet.
partition: PartitionBoundsKey range the tablet covers.
replicas: Vec<ReplicaDescriptor>All replicas (voters and learners), on distinct nodes.
leader_hint: Option<NodeId>Last known leader, when the meta plane has observed one.
generation: u64Descriptor generation; bumped by every atomic publication.
state: TabletStateLifecycle state; transitions go through Self::try_transition.
Implementations§
Source§impl TabletDescriptor
impl TabletDescriptor
Sourcepub fn validate(&self) -> Result<(), TabletError>
pub fn validate(&self) -> Result<(), TabletError>
Structural validation: reserved identifiers, well-formed bounds,
distinct replica nodes and Raft ids, a leader hint that names a
replica, and at least one voter outside TabletState::Creating.
Sourcepub fn voters(&self) -> impl Iterator<Item = &ReplicaDescriptor>
pub fn voters(&self) -> impl Iterator<Item = &ReplicaDescriptor>
The voter replicas.
Sourcepub fn learners(&self) -> impl Iterator<Item = &ReplicaDescriptor>
pub fn learners(&self) -> impl Iterator<Item = &ReplicaDescriptor>
The learner replicas.
Sourcepub fn voter_count(&self) -> usize
pub fn voter_count(&self) -> usize
Number of voting replicas.
Sourcepub fn replica_on(&self, node: NodeId) -> Option<&ReplicaDescriptor>
pub fn replica_on(&self, node: NodeId) -> Option<&ReplicaDescriptor>
The replica on node, if any.
Sourcepub fn try_transition(&mut self, next: TabletState) -> Result<(), TabletError>
pub fn try_transition(&mut self, next: TabletState) -> Result<(), TabletError>
Transitions to next, enforcing the TabletState graph. Generation
bumps are the meta group’s business — this changes only the state.
Sourcepub fn published_transition(
&self,
next: TabletState,
) -> Result<Self, TabletError>
pub fn published_transition( &self, next: TabletState, ) -> Result<Self, TabletError>
A copy of the descriptor transitioned to next with the generation
bumped by one: the shape of one atomic descriptor publication (see the
publication generation rules on TabletDescriptor). The descriptor
itself is unchanged, so the caller stages the published form and the
meta plane applies it last-writer-wins.
Trait Implementations§
Source§impl Clone for TabletDescriptor
impl Clone for TabletDescriptor
Source§fn clone(&self) -> TabletDescriptor
fn clone(&self) -> TabletDescriptor
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 TabletDescriptor
impl Debug for TabletDescriptor
Source§impl<'de> Deserialize<'de> for TabletDescriptor
impl<'de> Deserialize<'de> for TabletDescriptor
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>,
impl Eq for TabletDescriptor
Source§impl PartialEq for TabletDescriptor
impl PartialEq for TabletDescriptor
Source§impl Serialize for TabletDescriptor
impl Serialize for TabletDescriptor
impl StructuralPartialEq for TabletDescriptor
Auto Trait Implementations§
impl Freeze for TabletDescriptor
impl RefUnwindSafe for TabletDescriptor
impl Send for TabletDescriptor
impl Sync for TabletDescriptor
impl Unpin for TabletDescriptor
impl UnsafeUnpin for TabletDescriptor
impl UnwindSafe for TabletDescriptor
Blanket Implementations§
impl<T> AppData for Twhere
T: OptionalSend + OptionalSync + 'static + OptionalSerde,
impl<T> AppDataResponse for Twhere
T: OptionalSend + OptionalSync + 'static + OptionalSerde,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request