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: u32Snapshot format version; see META_STATE_FORMAT_VERSION.
metadata_version: MetadataVersionMonotonic 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: ClusterSettingsDynamic cluster settings (spec section 16.2).
feature_level: ClusterFeatureLevelCluster 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: u64Next 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
impl MetaState
Sourcepub fn apply(
&mut self,
command: &MetaCommand,
command_id: Option<[u8; 16]>,
commit_ts: HlcTimestamp,
registry: &FeatureRegistry,
) -> Result<(), MetaRejectionReason>
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.
Sourcepub fn node(&self, node_id: NodeId) -> Option<&NodeDescriptor>
pub fn node(&self, node_id: NodeId) -> Option<&NodeDescriptor>
One registered node’s descriptor.
Sourcepub fn node_record(&self, node_id: NodeId) -> Option<&NodeRecord>
pub fn node_record(&self, node_id: NodeId) -> Option<&NodeRecord>
One registered node’s record (descriptor + modification version).
Sourcepub fn node_descriptors(&self) -> Vec<NodeDescriptor>
pub fn node_descriptors(&self) -> Vec<NodeDescriptor>
Every registered node descriptor, in node-id order.
Sourcepub fn database(&self, database_id: DatabaseId) -> Option<&DatabaseDescriptor>
pub fn database(&self, database_id: DatabaseId) -> Option<&DatabaseDescriptor>
One database descriptor by id.
Sourcepub fn database_by_name(&self, name: &str) -> Option<&DatabaseDescriptor>
pub fn database_by_name(&self, name: &str) -> Option<&DatabaseDescriptor>
One database descriptor by name.
Sourcepub fn table(&self, table_id: TableId) -> Option<&TableSchemaRecord>
pub fn table(&self, table_id: TableId) -> Option<&TableSchemaRecord>
One table’s schema record.
Sourcepub fn tablet(&self, tablet_id: TabletId) -> Option<&TabletDescriptor>
pub fn tablet(&self, tablet_id: TabletId) -> Option<&TabletDescriptor>
One tablet descriptor (the canonical crate::tablet shape).
Sourcepub fn tablet_record(&self, tablet_id: TabletId) -> Option<&TabletRecord>
pub fn tablet_record(&self, tablet_id: TabletId) -> Option<&TabletRecord>
One tablet record (descriptor + modification version).
Sourcepub fn placement(&self, raft_group_id: RaftGroupId) -> Option<&ReplicaPlacement>
pub fn placement(&self, raft_group_id: RaftGroupId) -> Option<&ReplicaPlacement>
One raft group’s replica placement.
Sourcepub fn placement_policy(&self, name: &str) -> Option<&PlacementPolicy>
pub fn placement_policy(&self, name: &str) -> Option<&PlacementPolicy>
One named placement policy (the canonical crate::placement shape).
Sourcepub fn placement_policy_record(
&self,
name: &str,
) -> Option<&PlacementPolicyRecord>
pub fn placement_policy_record( &self, name: &str, ) -> Option<&PlacementPolicyRecord>
One named placement policy record (policy + modification version).
Sourcepub fn schema_job(&self, job_id: u64) -> Option<&SchemaJobRecord>
pub fn schema_job(&self, job_id: u64) -> Option<&SchemaJobRecord>
One schema job record.
Sourcepub fn txn_status_partition(
&self,
partition_id: u32,
) -> Option<&TxnStatusPartition>
pub fn txn_status_partition( &self, partition_id: u32, ) -> Option<&TxnStatusPartition>
One transaction status partition.
Sourcepub fn settings(&self) -> &ClusterSettings
pub fn settings(&self) -> &ClusterSettings
The dynamic cluster settings.
Sourcepub fn feature_level(&self) -> ClusterFeatureLevel
pub fn feature_level(&self) -> ClusterFeatureLevel
The cluster feature level.
Sourcepub fn feature_active(&self, registry: &FeatureRegistry, feature: &str) -> bool
pub fn feature_active(&self, registry: &FeatureRegistry, feature: &str) -> bool
Whether feature is active at the state’s current feature level.
Sourcepub fn feature_activations(&self) -> &[FeatureActivation]
pub fn feature_activations(&self) -> &[FeatureActivation]
The applied feature activations, oldest first.
Sourcepub fn rejections(&self) -> &VecDeque<MetaRejection>
pub fn rejections(&self) -> &VecDeque<MetaRejection>
The bounded refusal journal, oldest first.
Sourcepub fn next_raft_node_id(&self) -> u64
pub fn next_raft_node_id(&self) -> u64
The next id the meta-owned raft-node-id allocator hands out.
Sourcepub fn raft_id_allocation(&self, command_id: &[u8; 16]) -> Option<u64>
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<'de> Deserialize<'de> for MetaState
impl<'de> Deserialize<'de> for MetaState
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 StructuralPartialEq for MetaState
Auto Trait Implementations§
impl Freeze for MetaState
impl RefUnwindSafe for MetaState
impl Send for MetaState
impl Sync for MetaState
impl Unpin for MetaState
impl UnsafeUnpin for MetaState
impl UnwindSafe for MetaState
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<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