Struct scylla::transport::locator::ReplicaLocator
source · pub struct ReplicaLocator { /* private fields */ }
Expand description
ReplicaLocator
provides a way to find the set of owning nodes for a given (token,
replication strategy, table) tuple. It does so by either using the precomputed
token ranges, or doing the computation on the fly (precomputation is configurable).
Implementations§
source§impl ReplicaLocator
impl ReplicaLocator
sourcepub fn replicas_for_token<'a>(
&'a self,
token: Token,
strategy: &'a Strategy,
datacenter: Option<&'a str>,
table_spec: &TableSpec<'_>,
) -> ReplicaSet<'a>
pub fn replicas_for_token<'a>( &'a self, token: Token, strategy: &'a Strategy, datacenter: Option<&'a str>, table_spec: &TableSpec<'_>, ) -> ReplicaSet<'a>
Returns a set of nodes that are considered to be replicas for a given token, strategy and table.
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
).
If the requested table uses Tablets, then a separate code path is taken, which ignores replication strategies and only uses tablet information stored in ReplicaLocator. If we don’t have info about the tablet that owns the given token, empty set will be returned.
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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