pub struct Rack { /* private fields */ }Expand description
One rack within a datacenter.
continuums is sorted by token in ascending order to support
vnode_dispatch’s binary search; callers append continuum
points and call Rack::sort_continuums once after a batch of
updates.
Implementations§
Source§impl Rack
impl Rack
Sourcepub fn new(name: String, dc: String) -> Self
pub fn new(name: String, dc: String) -> Self
Build an empty rack.
§Examples
use dynomite::cluster::datacenter::Rack;
let r = Rack::new("rack1".into(), "dc1".into());
assert_eq!(r.name(), "rack1");
assert_eq!(r.dc(), "dc1");
assert!(r.continuums().is_empty());Sourcepub fn continuums(&self) -> &[Continuum]
pub fn continuums(&self) -> &[Continuum]
Borrow the continuum points (sorted by token).
Sourcepub fn nserver_continuum(&self) -> u32
pub fn nserver_continuum(&self) -> u32
Number of distinct servers ever added (mirrors the C
reference’s nserver_continuum).
Sourcepub fn ncontinuum(&self) -> u32
pub fn ncontinuum(&self) -> u32
Number of continuum points (mirrors ncontinuum).
Sourcepub fn add_peer_tokens(&mut self, peer_idx: u32, tokens: &[DynToken])
pub fn add_peer_tokens(&mut self, peer_idx: u32, tokens: &[DynToken])
Append continuum points produced from one peer’s tokens.
§Examples
use dynomite::cluster::datacenter::{Continuum, Rack};
use dynomite::hashkit::DynToken;
let mut r = Rack::new("rack1".into(), "dc1".into());
r.add_peer_tokens(0, &[DynToken::from_u32(2), DynToken::from_u32(5)]);
assert_eq!(r.ncontinuum(), 2);
assert_eq!(r.nserver_continuum(), 2);Sourcepub fn sort_continuums(&mut self)
pub fn sort_continuums(&mut self)
Sort the continuum by token (ascending). Callers must invoke
this once after a batch of Rack::add_peer_tokens calls so
that crate::cluster::vnode::dispatch can binary-search
the ring.
§Examples
use dynomite::cluster::datacenter::Rack;
use dynomite::hashkit::DynToken;
let mut r = Rack::new("r".into(), "d".into());
r.add_peer_tokens(0, &[DynToken::from_u32(5)]);
r.add_peer_tokens(1, &[DynToken::from_u32(2)]);
r.sort_continuums();
assert_eq!(r.continuums()[0].peer_idx, 1);Sourcepub fn clear_continuums(&mut self)
pub fn clear_continuums(&mut self)
Reset all continuum state for a fresh rebuild.
Sourcepub fn set_random_slices(&mut self, slices: RandomSlices)
pub fn set_random_slices(&mut self, slices: RandomSlices)
Install a RandomSlices table on this rack. The
continuum stays populated so the shadow-distribution
path (and any operator-side dump) can still walk the
vnode view.
Sourcepub fn is_random_slicing(&self) -> bool
pub fn is_random_slicing(&self) -> bool
True when the rack’s live distribution is random slicing.
Sourcepub fn random_slices(&self) -> Option<&RandomSlices>
pub fn random_slices(&self) -> Option<&RandomSlices>
Borrow the rack’s RandomSlices table when one is
installed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Rack
impl RefUnwindSafe for Rack
impl Send for Rack
impl Sync for Rack
impl Unpin for Rack
impl UnsafeUnpin for Rack
impl UnwindSafe for Rack
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<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> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.