Skip to main content

Strategy

Struct Strategy 

Source
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>

Source

pub fn quorum_system(&self) -> &QuorumSystem<T>

The quorum system this strategy is for.

Source

pub fn sigma_r(&self) -> &BTreeMap<Quorum<T>, f64>

Read quorum probabilities (they sum to 1).

Source

pub fn sigma_w(&self) -> &BTreeMap<Quorum<T>, f64>

Write quorum probabilities (they sum to 1).

Source

pub fn get_read_quorum(&self) -> HashSet<T>

Sample a read quorum according to the strategy.

Source

pub fn get_write_quorum(&self) -> HashSet<T>

Sample a write quorum according to the strategy.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl<T: Clone + Element> Clone for Strategy<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Element> Debug for Strategy<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Element> Display for Strategy<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Strategy<T>
where BTreeMap<Vec<T>, f64>: Freeze, Vec<(Node<T>, f64, f64)>: Freeze, QuorumSystem<T>: Freeze,

§

impl<T> RefUnwindSafe for Strategy<T>

§

impl<T> Send for Strategy<T>
where BTreeMap<Vec<T>, f64>: Send, Vec<(Node<T>, f64, f64)>: Send, QuorumSystem<T>: Send,

§

impl<T> Sync for Strategy<T>
where BTreeMap<Vec<T>, f64>: Sync, Vec<(Node<T>, f64, f64)>: Sync, QuorumSystem<T>: Sync,

§

impl<T> Unpin for Strategy<T>
where BTreeMap<Vec<T>, f64>: Unpin, Vec<(Node<T>, f64, f64)>: Unpin, QuorumSystem<T>: Unpin,

§

impl<T> UnsafeUnpin for Strategy<T>

§

impl<T> UnwindSafe for Strategy<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.