pub struct Strategy<T: Element> { /* private fields */ }Expand description
A probability distribution over read quorums and over write quorums.
Built by QuorumSystem::strategy, QuorumSystem::uniform_strategy,
or QuorumSystem::make_strategy; probabilities always sum to 1.
Implementations§
Source§impl<T: Element> Strategy<T>
impl<T: Element> Strategy<T>
Sourcepub fn quorum_system(&self) -> &QuorumSystem<T>
pub fn quorum_system(&self) -> &QuorumSystem<T>
The quorum system this strategy is for.
Sourcepub fn get_read_quorum(&self) -> HashSet<T>
pub fn get_read_quorum(&self) -> HashSet<T>
Sample a read quorum according to the strategy.
Sourcepub fn get_write_quorum(&self) -> HashSet<T>
pub fn get_write_quorum(&self) -> HashSet<T>
Sample a write quorum according to the strategy.
Sourcepub fn load(
&self,
read_fraction: Option<&Distribution>,
write_fraction: Option<&Distribution>,
) -> Result<f64>
pub fn load( &self, read_fraction: Option<&Distribution>, write_fraction: Option<&Distribution>, ) -> Result<f64>
Expected load of the busiest node, in fractions of its capacity
per operation. Capacity is 1 / load.
§Errors
Returns an error if the distribution is invalid.
Sourcepub fn capacity(
&self,
read_fraction: Option<&Distribution>,
write_fraction: Option<&Distribution>,
) -> Result<f64>
pub fn capacity( &self, read_fraction: Option<&Distribution>, write_fraction: Option<&Distribution>, ) -> Result<f64>
Expected capacity: operations per unit time the system can serve
before its busiest node saturates (1 / load at each fraction).
§Errors
Returns an error if the distribution is invalid.
Sourcepub fn network_load(
&self,
read_fraction: Option<&Distribution>,
write_fraction: Option<&Distribution>,
) -> Result<f64>
pub fn network_load( &self, read_fraction: Option<&Distribution>, write_fraction: Option<&Distribution>, ) -> Result<f64>
Expected number of nodes contacted per operation.
§Errors
Returns an error if the distribution is invalid.
Sourcepub fn latency(
&self,
read_fraction: Option<&Distribution>,
write_fraction: Option<&Distribution>,
) -> Result<Duration>
pub fn latency( &self, read_fraction: Option<&Distribution>, write_fraction: Option<&Distribution>, ) -> Result<Duration>
Expected operation latency: for each quorum, the time until its fastest nodes form a quorum, weighted by the strategy.
§Errors
Returns an error if the distribution is invalid.
Sourcepub fn node_load(
&self,
node: &Node<T>,
read_fraction: Option<&Distribution>,
write_fraction: Option<&Distribution>,
) -> Result<f64>
pub fn node_load( &self, node: &Node<T>, read_fraction: Option<&Distribution>, write_fraction: Option<&Distribution>, ) -> Result<f64>
Expected load on node.
Capacities come from the quorum system’s copy of the node, so
passing Node::new(id) works. Nodes not in the system have load 0.
§Errors
Returns an error if the distribution is invalid.
Sourcepub fn node_utilization(
&self,
node: &Node<T>,
read_fraction: Option<&Distribution>,
write_fraction: Option<&Distribution>,
) -> Result<f64>
pub fn node_utilization( &self, node: &Node<T>, read_fraction: Option<&Distribution>, write_fraction: Option<&Distribution>, ) -> Result<f64>
Utilization of node: its load relative to the busiest node.
§Errors
Returns an error if the distribution is invalid.
Sourcepub fn node_throughput(
&self,
node: &Node<T>,
read_fraction: Option<&Distribution>,
write_fraction: Option<&Distribution>,
) -> Result<f64>
pub fn node_throughput( &self, node: &Node<T>, read_fraction: Option<&Distribution>, write_fraction: Option<&Distribution>, ) -> Result<f64>
Requests per unit time handled by node when the system runs at
full capacity.
§Errors
Returns an error if the distribution is invalid.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Strategy<T>
impl<T> RefUnwindSafe for Strategy<T>where
BTreeMap<Vec<T>, f64>: RefUnwindSafe,
Vec<(Node<T>, f64, f64)>: RefUnwindSafe,
QuorumSystem<T>: RefUnwindSafe,
impl<T> Send for Strategy<T>
impl<T> Sync for Strategy<T>
impl<T> Unpin for Strategy<T>
impl<T> UnsafeUnpin for Strategy<T>where
BTreeMap<Vec<T>, f64>: UnsafeUnpin,
Vec<(Node<T>, f64, f64)>: UnsafeUnpin,
QuorumSystem<T>: UnsafeUnpin,
impl<T> UnwindSafe for Strategy<T>where
BTreeMap<Vec<T>, f64>: UnwindSafe,
Vec<(Node<T>, f64, f64)>: UnwindSafe,
QuorumSystem<T>: UnwindSafe,
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> 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