Struct paxakos::cluster::Cluster [−][src]
pub struct Cluster<N> { /* fields omitted */ }
Expand description
Utility to ease the implementation of changes in cluster membership, i.e. joining and parting of nodes, and concurrency.
This utility is most useful to implementors of the State
trait. Whenever a log entry is applied it should also
be applied to this Cluster
. If done consistently,
concurrency_at_offset_one
and
nodes_at
can be used to trivially implement the
methods concurrency
and
cluster_at
.
Membership Changes
No limits are placed on membership changes. Practically speaking, however, it is wise not to make significant changes quickly. Nodes should not become voting members of a cluster until they can be certain they won’t break an earlier commitment.
Concurrency Increases
The implementation is “optimal” in that it takes advantage of concurrency increases the moment they become known.
Round | r | r + 1 | r + 2 | … |
---|---|---|---|---|
Log Entry | c ≔ 5 | |||
Target Concurrency | 2 | 5 | 5 | … |
Effective Concurrency | 2 | 5 | 5 | … |
Concurrency Decreases
When concurrency is decreased, it cannot be assumed that everyone knows of
this reduction until the the previous concurrency window is exhausted.
Consider that the concurrency level is 5
in round r
and is then reduced
by a log entry in round r + 1
. Any node that does not see that log entry
in time may think the concurrency level is unchanged, at least until it
exhausts the concurrency of 5
in round r + 5
. Any further append to the
log is only allowed while taking the reduction into account. That means that
in effect the concurrency level slowly reduces from 5
to 2
, as if the
5
throws a shadow along the axis of concurrency.
Round | r | r + 1 | r + 2 | r + 3 | r + 4 | r + 5 | … |
---|---|---|---|---|---|---|---|
Log Entry | c ≔ 2 | ||||||
Target Concurrency | 5 | 2 | 2 | 2 | 2 | 2 | … |
Effective Concurrency | 5 | 5 | 4 | 3 | 2 | 2 | … |
Implementations
Returns a new cluster with the given initial state.
Applies the given log entry, making the appropiate updates.
Returns the concurrency at offset one.
Equivalent to c.nodes_at(NonZeroUsize::new(1).unwrap()).unwrap()
.
Returns effective set of nodes of the cluster for the given round number
or None
when the level of concurrency does not allow the node set to
be determined yet.
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl<N> RefUnwindSafe for Cluster<N> where
N: RefUnwindSafe,
impl<N> UnwindSafe for Cluster<N> where
N: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more