pub struct AssignmentSnapshot {
pub version: u64,
pub partitioning_abi_version: u16,
pub vnodes: BTreeMap<u32, NodeId>,
pub participants: Vec<CheckpointParticipant>,
pub updated_at_ms: i64,
pub draining: bool,
pub drain_transition: Option<AssignmentDrainTransition>,
}Expand description
Durable vnode-to-instance assignment snapshot.
Fields§
§version: u64Monotonic version. Writers bump on each update.
partitioning_abi_version: u16Key encoding, hashing, and key-group mapping contract used by this owner map.
vnodes: BTreeMap<u32, NodeId>Vnode id → owning instance. BTreeMap (not Vec) so snapshots
with different vnode_count are still deserializable — sparse
indices surface as missing keys the caller can diagnose.
participants: Vec<CheckpointParticipant>Exact process roster certified for this assignment generation. A stable node restart changes this roster and therefore requires a new version even when vnode owners do not.
updated_at_ms: i64Wall-clock timestamp of the last update, millis since epoch.
draining: boolPre-rotation drain phase: when set, this snapshot carries the intended
next assignment but ownership has NOT changed yet. Nodes mark the vnodes
they are about to lose as draining (pausing those source partitions) so the
pre-rotation checkpoint is a clean cut; the leader then publishes the same
assignment with draining = false to commit the rotation.
drain_transition: Option<AssignmentDrainTransition>Exact predecessor, successor, and durable leader term for a draining generation.
Present if and only if draining is true.
Implementations§
Source§impl AssignmentSnapshot
impl AssignmentSnapshot
Sourcepub fn next(&self, vnodes: BTreeMap<u32, NodeId>) -> Result<Self, SnapshotError>
pub fn next(&self, vnodes: BTreeMap<u32, NodeId>) -> Result<Self, SnapshotError>
Next snapshot with bumped version and current wall-clock time.
§Errors
Returns an error if the version overflows or the successor is noncanonical.
Sourcepub fn next_for_participants(
&self,
vnodes: BTreeMap<u32, NodeId>,
participants: Vec<CheckpointParticipant>,
) -> Result<Self, SnapshotError>
pub fn next_for_participants( &self, vnodes: BTreeMap<u32, NodeId>, participants: Vec<CheckpointParticipant>, ) -> Result<Self, SnapshotError>
Next snapshot bound to the supplied canonical process roster.
§Errors
Returns an error if the version overflows or the successor is noncanonical.
Sourcepub fn validate(&self) -> Result<(), SnapshotError>
pub fn validate(&self) -> Result<(), SnapshotError>
Validate the durable owner map, process roster, and optional drain transition.
§Errors
Returns an error when the snapshot or drain transition is noncanonical.
Sourcepub fn assignment_fence(
&self,
) -> Result<CheckpointAssignmentFence, SnapshotError>
pub fn assignment_fence( &self, ) -> Result<CheckpointAssignmentFence, SnapshotError>
Exact checkpoint certificate represented by this snapshot.
§Errors
Returns an error when the assignment map or process roster is noncanonical.
Sourcepub fn next_draining(
&self,
vnodes: BTreeMap<u32, NodeId>,
participants: Vec<CheckpointParticipant>,
leader: LeaderProof,
) -> Result<Self, SnapshotError>
pub fn next_draining( &self, vnodes: BTreeMap<u32, NodeId>, participants: Vec<CheckpointParticipant>, leader: LeaderProof, ) -> Result<Self, SnapshotError>
Create the exact successor as a leader-fenced draining generation.
§Errors
Rejects a non-committed predecessor, invalid successor, or leader proof outside both certified rosters.
Sourcepub fn committed_target(&self) -> Result<Self, SnapshotError>
pub fn committed_target(&self) -> Result<Self, SnapshotError>
Convert a draining generation into its committed target without changing identity.
§Errors
Returns an error unless this is a valid draining snapshot.
Sourcepub fn aborted_target(&self, predecessor: &Self) -> Result<Self, SnapshotError>
pub fn aborted_target(&self, predecessor: &Self) -> Result<Self, SnapshotError>
Convert a draining generation into a committed rollback of its predecessor map.
§Errors
Returns an error when either snapshot is invalid or the predecessor does not match.
Sourcepub fn has_canonical_participants(&self) -> bool
pub fn has_canonical_participants(&self) -> bool
Whether the durable process roster is canonical and covers every vnode owner.
Sourcepub fn vnodes_from_vec(assignment: &[NodeId]) -> BTreeMap<u32, NodeId>
pub fn vnodes_from_vec(assignment: &[NodeId]) -> BTreeMap<u32, NodeId>
Convert a Vec<NodeId> (one entry per vnode id, dense) into the
BTreeMap shape this snapshot uses. Mirrors the layout returned
by rendezvous_assignment.
Sourcepub fn to_vnode_vec(
&self,
vnode_count: u32,
) -> Result<Vec<NodeId>, SnapshotError>
pub fn to_vnode_vec( &self, vnode_count: u32, ) -> Result<Vec<NodeId>, SnapshotError>
Convert the canonical owner map to a dense vector of exactly vnode_count entries.
§Errors
Returns an error when the snapshot is invalid or its vnode map is not exactly dense.
Trait Implementations§
Source§impl Clone for AssignmentSnapshot
impl Clone for AssignmentSnapshot
Source§fn clone(&self) -> AssignmentSnapshot
fn clone(&self) -> AssignmentSnapshot
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 AssignmentSnapshot
impl Debug for AssignmentSnapshot
Source§impl<'de> Deserialize<'de> for AssignmentSnapshot
impl<'de> Deserialize<'de> for AssignmentSnapshot
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 AssignmentSnapshot
Source§impl PartialEq for AssignmentSnapshot
impl PartialEq for AssignmentSnapshot
Source§impl Serialize for AssignmentSnapshot
impl Serialize for AssignmentSnapshot
impl StructuralPartialEq for AssignmentSnapshot
Auto Trait Implementations§
impl Freeze for AssignmentSnapshot
impl RefUnwindSafe for AssignmentSnapshot
impl Send for AssignmentSnapshot
impl Sync for AssignmentSnapshot
impl Unpin for AssignmentSnapshot
impl UnsafeUnpin for AssignmentSnapshot
impl UnwindSafe for AssignmentSnapshot
Blanket Implementations§
impl<T> Allocation for T
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
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>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].