pub struct ReplicaLocator { /* private fields */ }
Expand description
ReplicaLocator
provides a way to find the set of owning nodes for a given (token, replication
strategy) pair. It does so by either using the precomputed token ranges, or doing the
computation on the fly.
Implementations§
Source§impl ReplicaLocator
impl ReplicaLocator
Sourcepub fn replicas_for_token<'a>(
&'a self,
token: Token,
strategy: &'a Strategy,
datacenter: Option<&'a str>,
) -> ReplicaSet<'a>
pub fn replicas_for_token<'a>( &'a self, token: Token, strategy: &'a Strategy, datacenter: Option<&'a str>, ) -> ReplicaSet<'a>
Returns a set of nodes that are considered to be replicas for a given token and strategy.
If the datacenter
parameter is set, the returned ReplicaSet
is limited only to replicas
from that datacenter. If a specified datacenter name does not correspond to a valid
datacenter, an empty set will be returned.
Supported replication strategies: SimpleStrategy
, ‘NetworkTopologyStrategy’,
‘LocalStrategy’. If other is specified, it is treated as the SimpleStrategy
with
replication factor equal to 1.
If a provided replication strategy did not appear in precompute_replica_sets_for
parameter of Self::new
, invocation of this function will trigger a computation of the
desired replica set (the computation might be delegated in time and start upon interaction
with the returned ReplicaSet
).
Sourcepub fn ring(&self) -> &TokenRing<Arc<Node>>
pub fn ring(&self) -> &TokenRing<Arc<Node>>
Gives access to the token ring, based on which all token ranges/replica sets are computed.
Sourcepub fn unique_nodes_in_global_ring(&self) -> &[Arc<Node>]
pub fn unique_nodes_in_global_ring(&self) -> &[Arc<Node>]
Gives a list of all nodes in the token ring.
Sourcepub fn datacenter_names(&self) -> &[String]
pub fn datacenter_names(&self) -> &[String]
Gives a list of all known datacenters.
Trait Implementations§
Source§impl Clone for ReplicaLocator
impl Clone for ReplicaLocator
Source§fn clone(&self) -> ReplicaLocator
fn clone(&self) -> ReplicaLocator
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for ReplicaLocator
impl !RefUnwindSafe for ReplicaLocator
impl Send for ReplicaLocator
impl Sync for ReplicaLocator
impl Unpin for ReplicaLocator
impl !UnwindSafe for ReplicaLocator
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> 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 more