pub struct VnodeRegistry { /* private fields */ }Expand description
Runtime registry of vnode topology and assignment.
Implementations§
Source§impl VnodeRegistry
impl VnodeRegistry
Sourcepub fn new(vnode_count: u32) -> Self
pub fn new(vnode_count: u32) -> Self
Create a registry sized for vnode_count vnodes, all marked
as NodeId::UNASSIGNED. The assignment version starts at 1.
§Panics
Panics if vnode_count == 0.
Sourcepub fn single_owner(vnode_count: u32, owner: NodeId) -> Self
pub fn single_owner(vnode_count: u32, owner: NodeId) -> Self
Create a registry where every vnode is owned by the same node.
Used by single-instance / embedded deployments.
§Panics
Panics if vnode_count == 0.
Sourcepub fn vnode_count(&self) -> u32
pub fn vnode_count(&self) -> u32
Number of vnodes.
Sourcepub fn assignment_version(&self) -> u64
pub fn assignment_version(&self) -> u64
Current monotonic assignment version.
Sourcepub fn owner(&self, vnode: u32) -> NodeId
pub fn owner(&self, vnode: u32) -> NodeId
Owner of a given vnode. Returns NodeId::UNASSIGNED if the
vnode is out of range or unassigned.
Sourcepub fn snapshot(&self) -> Arc<[NodeId]>
pub fn snapshot(&self) -> Arc<[NodeId]>
Snapshot the current assignment vector. Cheap — internally an
Arc::clone.
Sourcepub fn set_assignment(&self, new_assignment: Arc<[NodeId]>)
pub fn set_assignment(&self, new_assignment: Arc<[NodeId]>)
Replace the full assignment and bump the version.
§Panics
Panics if new_assignment.len() != self.vnode_count.
Sourcepub fn set_assignment_and_version(
&self,
new_assignment: Arc<[NodeId]>,
version: u64,
)
pub fn set_assignment_and_version( &self, new_assignment: Arc<[NodeId]>, version: u64, )
Replace the full assignment and set the version to version
atomically. For recovery paths that must restore the registry to
a persisted fence generation, not a fresh bump.
§Panics
Panics on length mismatch, or if version is less than the
current one (assignment versions are monotonic).
Sourcepub fn vnode_for_key(&self, key: &[u8]) -> u32
pub fn vnode_for_key(&self, key: &[u8]) -> u32
Map a primary key to a vnode.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for VnodeRegistry
impl !RefUnwindSafe for VnodeRegistry
impl Send for VnodeRegistry
impl Sync for VnodeRegistry
impl Unpin for VnodeRegistry
impl UnsafeUnpin for VnodeRegistry
impl UnwindSafe for VnodeRegistry
Blanket Implementations§
§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
§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