Skip to main content

TabletDescriptor

Struct TabletDescriptor 

Source
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::Splitting at g + 1 (g = the pre-split generation); the children are created Creating at g + 1 and are never routed to; the atomic routing publication assigns one new generation p = (source generation at publication) + 1, taking the children Creating -> Active and the source Splitting -> Retiring together. A request holding g against the splitting source is classified RoutingError::TabletSplit; after publication any generation below p against the retiring source is RoutingError::TabletMoved.
  • Merge: each source is marked TabletState::Merging at its own g + 1; the publication generation is p = 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 -> Retired at p + 1 before the descriptor is deleted.

Fields§

§tablet_id: TabletId

The tablet’s identity.

§table_id: TableId

Table the tablet belongs to.

§database_id: DatabaseId

Logical 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: RaftGroupId

Raft group replicating the tablet.

§partition: PartitionBounds

Key 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: u64

Descriptor generation; bumped by every atomic publication.

§state: TabletState

Lifecycle state; transitions go through Self::try_transition.

Implementations§

Source§

impl TabletDescriptor

Source

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.

Source

pub fn voters(&self) -> impl Iterator<Item = &ReplicaDescriptor>

The voter replicas.

Source

pub fn learners(&self) -> impl Iterator<Item = &ReplicaDescriptor>

The learner replicas.

Source

pub fn voter_count(&self) -> usize

Number of voting replicas.

Source

pub fn replica_on(&self, node: NodeId) -> Option<&ReplicaDescriptor>

The replica on node, if any.

Source

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.

Source

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

Source§

fn clone(&self) -> TabletDescriptor

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TabletDescriptor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for TabletDescriptor

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for TabletDescriptor

Source§

impl PartialEq for TabletDescriptor

Source§

fn eq(&self, other: &TabletDescriptor) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for TabletDescriptor

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for TabletDescriptor

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AppData for T
where T: OptionalSend + OptionalSync + 'static + OptionalSerde,

Source§

impl<T> AppDataResponse for T
where T: OptionalSend + OptionalSync + 'static + OptionalSerde,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> OptionalSend for T
where T: Send + ?Sized,

Source§

impl<T> OptionalSync for T
where T: Sync + ?Sized,

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more