Skip to main content

QuorumSystem

Struct QuorumSystem 

Source
pub struct QuorumSystem<T: Element> { /* private fields */ }
Expand description

A read-write quorum system.

Implementations§

Source§

impl<T: Element> QuorumSystem<T>

Source

pub fn from_reads(reads: Expr<T>) -> Self

Build a quorum system from reads only; writes are the dual.

Source

pub fn from_writes(writes: Expr<T>) -> Self

Build a quorum system from writes only; reads are the dual.

Source

pub fn new(reads: Expr<T>, writes: Expr<T>) -> Result<Self>

Build a quorum system from both read and write expressions.

§Errors

Returns Error::NonOverlappingQuorums unless every read quorum intersects every write quorum.

Source

pub fn reads(&self) -> &Expr<T>

The read expression.

Source

pub fn writes(&self) -> &Expr<T>

The write expression.

Source

pub fn read_quorums(&self) -> Box<dyn Iterator<Item = HashSet<T>> + '_>

Iterate over all read quorums.

Source

pub fn write_quorums(&self) -> Box<dyn Iterator<Item = HashSet<T>> + '_>

Iterate over all write quorums.

Source

pub fn is_read_quorum(&self, xs: &HashSet<T>) -> bool

Whether xs contains a read quorum.

Source

pub fn is_write_quorum(&self, xs: &HashSet<T>) -> bool

Whether xs contains a write quorum.

Source

pub fn node(&self, x: &T) -> Result<&Node<T>>

Look up a node by its identifier.

§Errors

Returns Error::InvalidQuorumSystem if x is not in the system.

Source

pub fn nodes(&self) -> HashSet<Node<T>>

All nodes in the system.

Source

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

All node identifiers in the system.

Source

pub fn resilience(&self) -> usize

The resilience of the system: the minimum of read and write resilience.

Source

pub fn read_resilience(&self) -> usize

The resilience of the read expression.

Source

pub fn write_resilience(&self) -> usize

The resilience of the write expression.

Source

pub fn dup_free(&self) -> bool

Whether both read and write expressions are duplicate-free.

Source

pub fn uniform_strategy(&self, f: usize) -> Result<Strategy<T>>

A strategy that picks uniformly among the minimal f-resilient quorums.

§Errors

Returns Error::NoStrategyFound if there are no f-resilient read or write quorums.

Source

pub fn make_strategy( &self, sigma_r: BTreeMap<Quorum<T>, f64>, sigma_w: BTreeMap<Quorum<T>, f64>, ) -> Result<Strategy<T>>

Build a strategy from explicit quorum weights.

Each key is a list of node identifiers (order and duplicates do not matter); weights for the same set are added together, and weights are normalized to sum to 1. Zero-weight quorums are dropped.

§Errors

Returns Error::InvalidQuorumSystem if a key is not a read (or write) quorum, a weight is negative or not finite, or all weights are zero.

Source

pub fn strategy( &self, objective: Objective, read_fraction: Option<&Distribution>, write_fraction: Option<&Distribution>, limits: &StrategyLimits, f: usize, ) -> Result<Strategy<T>>

Compute the optimal strategy by linear programming.

Minimizes objective subject to limits, considering only f-resilient quorums (quorums that still contain a quorum after any f of their nodes fail). Exactly one of read_fraction and write_fraction must be Some.

§Errors

Trait Implementations§

Source§

impl<T: Clone + Element> Clone for QuorumSystem<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 QuorumSystem<T>

Source§

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

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

impl<T: Element> Display for QuorumSystem<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 QuorumSystem<T>
where Expr<T>: Freeze, HashMap<T, Node<T>>: Freeze,

§

impl<T> RefUnwindSafe for QuorumSystem<T>
where Expr<T>: RefUnwindSafe, HashMap<T, Node<T>>: RefUnwindSafe,

§

impl<T> Send for QuorumSystem<T>
where Expr<T>: Send, HashMap<T, Node<T>>: Send,

§

impl<T> Sync for QuorumSystem<T>
where Expr<T>: Sync, HashMap<T, Node<T>>: Sync,

§

impl<T> Unpin for QuorumSystem<T>
where Expr<T>: Unpin, HashMap<T, Node<T>>: Unpin,

§

impl<T> UnsafeUnpin for QuorumSystem<T>
where Expr<T>: UnsafeUnpin, HashMap<T, Node<T>>: UnsafeUnpin,

§

impl<T> UnwindSafe for QuorumSystem<T>
where Expr<T>: UnwindSafe, HashMap<T, Node<T>>: UnwindSafe,

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.