pub struct TabletLayout { /* private fields */ }Expand description
On-node directory layout of one tablet replica and its Raft group (spec section 12.3):
node-data/
tablets/<tablet-id>/{state,runs,indexes,temp} + tablet.json
groups/<raft-group-id>/{raft,snapshots}The applied MVCC state, sorted runs, local index generations, and compaction state live under the tablet directory; the Raft log and snapshots live under the group directory, so a group can outlive any single applied-state rebuild (spec section 4.4: runs and indexes are applied state and may be rebuilt).
Implementations§
Source§impl TabletLayout
impl TabletLayout
Sourcepub fn new(
node_data: impl Into<PathBuf>,
tablet_id: TabletId,
raft_group_id: RaftGroupId,
) -> Self
pub fn new( node_data: impl Into<PathBuf>, tablet_id: TabletId, raft_group_id: RaftGroupId, ) -> Self
The layout of tablet_id/raft_group_id under node_data.
Sourcepub fn raft_group_id(&self) -> RaftGroupId
pub fn raft_group_id(&self) -> RaftGroupId
The Raft group this layout belongs to.
Sourcepub fn tablet_dir(&self) -> PathBuf
pub fn tablet_dir(&self) -> PathBuf
node-data/tablets/<tablet-id>.
Sourcepub fn state_dir(&self) -> PathBuf
pub fn state_dir(&self) -> PathBuf
tablets/<tablet-id>/state (applied MVCC + compaction state).
Sourcepub fn indexes_dir(&self) -> PathBuf
pub fn indexes_dir(&self) -> PathBuf
tablets/<tablet-id>/indexes (local index generations).
Sourcepub fn snapshots_dir(&self) -> PathBuf
pub fn snapshots_dir(&self) -> PathBuf
Legacy layout path groups/<raft-group-id>/snapshots (unused by the
consensus SM). Prefer Self::raft_snapshot_dir (review N3).
Sourcepub fn raft_snapshot_dir(&self) -> PathBuf
pub fn raft_snapshot_dir(&self) -> PathBuf
groups/<raft-group-id>/raft/snapshot — the path the consensus state
machine actually writes (review N3 reconciliation).
Sourcepub fn metadata_path(&self) -> PathBuf
pub fn metadata_path(&self) -> PathBuf
tablets/<tablet-id>/tablet.json.
Sourcepub fn create(&self, descriptor: &TabletDescriptor) -> Result<(), TabletError>
pub fn create(&self, descriptor: &TabletDescriptor) -> Result<(), TabletError>
Creates the directory tree and persists the initial tablet metadata.
The metadata file is created atomically and only if absent (the same
hard-link publish idiom as the node identity); a concurrent or
repeated create that finds identical metadata succeeds, while
different existing metadata fails closed with
TabletError::MetadataConflict — a tablet directory is never
silently repurposed.
Sourcepub fn store_metadata(
&self,
descriptor: &TabletDescriptor,
) -> Result<(), TabletError>
pub fn store_metadata( &self, descriptor: &TabletDescriptor, ) -> Result<(), TabletError>
Atomically replaces the persisted metadata (used by the meta-driven apply path when the descriptor’s generation advances). The descriptor is validated and must name this layout’s tablet and group.
Sourcepub fn load_metadata(&self) -> Result<TabletDescriptor, TabletError>
pub fn load_metadata(&self) -> Result<TabletDescriptor, TabletError>
Loads and verifies the persisted tablet metadata. Missing, corrupt, unknown-version, wrong-checksum, or wrong-tablet files all fail closed (spec sections 4.10, 12.3).
Sourcepub fn validate(&self) -> Result<TabletDescriptor, TabletError>
pub fn validate(&self) -> Result<TabletDescriptor, TabletError>
Opens the layout for use: verifies the persisted metadata and the presence of every required directory, failing closed on any missing or corrupt piece (spec section 12.3).
Sourcepub fn teardown(&self) -> Result<(), TabletError>
pub fn teardown(&self) -> Result<(), TabletError>
Removes the local replica: the tablet directory and the Raft-group
directory (spec section 12.5 step 11; the consensus membership removal
is the runtime’s half). Idempotent — a partially torn-down or absent
directory is fine — but never destructive across identity: a
tablet.json that names a different tablet or group fails closed with
TabletError::TabletMismatch instead of deleting foreign state.
Trait Implementations§
Source§impl Clone for TabletLayout
impl Clone for TabletLayout
Source§fn clone(&self) -> TabletLayout
fn clone(&self) -> TabletLayout
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 TabletLayout
impl Debug for TabletLayout
impl Eq for TabletLayout
Source§impl PartialEq for TabletLayout
impl PartialEq for TabletLayout
impl StructuralPartialEq for TabletLayout
Auto Trait Implementations§
impl Freeze for TabletLayout
impl RefUnwindSafe for TabletLayout
impl Send for TabletLayout
impl Sync for TabletLayout
impl Unpin for TabletLayout
impl UnsafeUnpin for TabletLayout
impl UnwindSafe for TabletLayout
Blanket Implementations§
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,
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