Skip to main content

MetaState

Struct MetaState 

Source
pub struct MetaState {
Show 17 fields pub format_version: u32, pub metadata_version: MetadataVersion, pub nodes: BTreeMap<NodeId, NodeRecord>, pub databases: BTreeMap<DatabaseId, DatabaseDescriptor>, pub tables: BTreeMap<TableId, TableSchemaRecord>, pub tablets: BTreeMap<TabletId, TabletRecord>, pub placements: BTreeMap<RaftGroupId, ReplicaPlacement>, pub placement_policies: BTreeMap<String, PlacementPolicyRecord>, pub schema_jobs: BTreeMap<u64, SchemaJobRecord>, pub txn_status_partitions: BTreeMap<u32, TxnStatusPartition>, pub settings: ClusterSettings, pub feature_level: ClusterFeatureLevel, pub feature_activations: Vec<FeatureActivation>, pub rejections: VecDeque<MetaRejection>, pub next_raft_node_id: u64, pub raft_id_allocations: BTreeMap<String, u64>, pub raft_id_allocation_order: VecDeque<String>,
}
Expand description

The replicated control-plane state of the meta group (spec section 12.1).

Deterministic: every replica applies the same commands in the same order and reaches byte-identical state. Versioned: format_version gates the snapshot format and metadata_version ticks once per applied command (accepted or refused — a refusal appends to the rejection journal, which is itself state), giving readers a monotonic watermark.

Fields§

§format_version: u32

Snapshot format version; see META_STATE_FORMAT_VERSION.

§metadata_version: MetadataVersion

Monotonic per-applied-command version.

§nodes: BTreeMap<NodeId, NodeRecord>

Cluster membership: registered node descriptors and locality.

§databases: BTreeMap<DatabaseId, DatabaseDescriptor>

Logical databases.

§tables: BTreeMap<TableId, TableSchemaRecord>

Replicated table schemas.

§tablets: BTreeMap<TabletId, TabletRecord>

Tablet records (canonical descriptor + modification version).

§placements: BTreeMap<RaftGroupId, ReplicaPlacement>

Replica placements by raft group.

§placement_policies: BTreeMap<String, PlacementPolicyRecord>

Named placement policy records (spec section 12.7).

§schema_jobs: BTreeMap<u64, SchemaJobRecord>

Schema/index jobs.

§txn_status_partitions: BTreeMap<u32, TxnStatusPartition>

Transaction status partitions (spec section 12.8).

§settings: ClusterSettings

Dynamic cluster settings (spec section 16.2).

§feature_level: ClusterFeatureLevel

Cluster feature level (never lowers; ADR-0010).

§feature_activations: Vec<FeatureActivation>

Applied feature activations, oldest first.

§rejections: VecDeque<MetaRejection>

Bounded journal of refused commands, oldest first (META_REJECTION_LIMIT).

§next_raft_node_id: u64

Next per-group raft node id the meta-owned allocator hands out (MetaCommand::AllocateRaftNodeIds); monotonic and never reused. Starts at FIRST_RAFT_NODE_ID.

§raft_id_allocations: BTreeMap<String, u64>

Recent raft-node-id allocations by command id (hex-encoded, base of each allocated range), the idempotent-replay record of MetaCommand::AllocateRaftNodeIds; bounded by RAFT_ID_ALLOCATION_RECORD_LIMIT. (Hex keys: JSON map keys must be strings.)

§raft_id_allocation_order: VecDeque<String>

Eviction order of Self::raft_id_allocations, oldest first.

Implementations§

Source§

impl MetaState

Source

pub fn apply( &mut self, command: &MetaCommand, command_id: Option<[u8; 16]>, commit_ts: HlcTimestamp, registry: &FeatureRegistry, ) -> Result<(), MetaRejectionReason>

Applies one committed command. metadata_version ticks first (every applied command moves the watermark); a refusal journals the reason and leaves the records untouched.

commit_ts is the leader-assigned commit timestamp of the command’s log entry: an FeatureActivation::activated_at left as HlcTimestamp::ZERO by the proposer is stamped with it here, so every replica records the identical timestamp.

Source

pub fn node(&self, node_id: NodeId) -> Option<&NodeDescriptor>

One registered node’s descriptor.

Source

pub fn node_record(&self, node_id: NodeId) -> Option<&NodeRecord>

One registered node’s record (descriptor + modification version).

Source

pub fn node_descriptors(&self) -> Vec<NodeDescriptor>

Every registered node descriptor, in node-id order.

Source

pub fn database(&self, database_id: DatabaseId) -> Option<&DatabaseDescriptor>

One database descriptor by id.

Source

pub fn database_by_name(&self, name: &str) -> Option<&DatabaseDescriptor>

One database descriptor by name.

Source

pub fn table(&self, table_id: TableId) -> Option<&TableSchemaRecord>

One table’s schema record.

Source

pub fn tablet(&self, tablet_id: TabletId) -> Option<&TabletDescriptor>

One tablet descriptor (the canonical crate::tablet shape).

Source

pub fn tablet_record(&self, tablet_id: TabletId) -> Option<&TabletRecord>

One tablet record (descriptor + modification version).

Source

pub fn placement(&self, raft_group_id: RaftGroupId) -> Option<&ReplicaPlacement>

One raft group’s replica placement.

Source

pub fn placement_policy(&self, name: &str) -> Option<&PlacementPolicy>

One named placement policy (the canonical crate::placement shape).

Source

pub fn placement_policy_record( &self, name: &str, ) -> Option<&PlacementPolicyRecord>

One named placement policy record (policy + modification version).

Source

pub fn schema_job(&self, job_id: u64) -> Option<&SchemaJobRecord>

One schema job record.

Source

pub fn txn_status_partition( &self, partition_id: u32, ) -> Option<&TxnStatusPartition>

One transaction status partition.

Source

pub fn settings(&self) -> &ClusterSettings

The dynamic cluster settings.

Source

pub fn feature_level(&self) -> ClusterFeatureLevel

The cluster feature level.

Source

pub fn feature_active(&self, registry: &FeatureRegistry, feature: &str) -> bool

Whether feature is active at the state’s current feature level.

Source

pub fn feature_activations(&self) -> &[FeatureActivation]

The applied feature activations, oldest first.

Source

pub fn rejections(&self) -> &VecDeque<MetaRejection>

The bounded refusal journal, oldest first.

Source

pub fn next_raft_node_id(&self) -> u64

The next id the meta-owned raft-node-id allocator hands out.

Source

pub fn raft_id_allocation(&self, command_id: &[u8; 16]) -> Option<u64>

The base of the range allocated by the command with id command_id, when the allocation record is still retained (RAFT_ID_ALLOCATION_RECORD_LIMIT).

Trait Implementations§

Source§

impl Clone for MetaState

Source§

fn clone(&self) -> MetaState

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 MetaState

Source§

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

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

impl Default for MetaState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for MetaState

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 PartialEq for MetaState

Source§

fn eq(&self, other: &MetaState) -> 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 MetaState

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 MetaState

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<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