pub struct Changer<'a> { /* private fields */ }
Expand description
Changer facilitates configuration changes. It exposes methods to handle simple and joint consensus while performing the proper validation that allows refusing invalid configuration changes before they affect the active configuration.
Implementations§
source§impl Changer<'_>
impl Changer<'_>
sourcepub fn new(tracker: &ProgressTracker) -> Changer<'_>
pub fn new(tracker: &ProgressTracker) -> Changer<'_>
Creates a changer.
sourcepub fn enter_joint(
&self,
auto_leave: bool,
ccs: &[ConfChangeSingle]
) -> Result<(Configuration, MapChange)>
pub fn enter_joint( &self, auto_leave: bool, ccs: &[ConfChangeSingle] ) -> Result<(Configuration, MapChange)>
Verifies that the outgoing (=right) majority config of the joint config is empty and initializes it with a copy of the incoming (=left) majority config. That is, it transitions from
(1 2 3)&&()
to
(1 2 3)&&(1 2 3)
```.
The supplied changes are then applied to the incoming majority config,
resulting in a joint configuration that in terms of the Raft thesis[1]
(Section 4.3) corresponds to `C_{new,old}`.
[1]: https://github.com/ongardie/dissertation/blob/master/online-trim.pdf
sourcepub fn leave_joint(&self) -> Result<(Configuration, MapChange)>
pub fn leave_joint(&self) -> Result<(Configuration, MapChange)>
Transitions out of a joint configuration. It is an error to call this method if the configuration is not joint, i.e. if the outgoing majority config is empty.
The outgoing majority config of the joint configuration will be removed, that is,
the incoming config is promoted as the sole decision maker. In the notation of
the Raft thesis1 (Section 4.3), this method transitions from C_{new,old}
into
C_new
.
At the same time, any staged learners (LearnersNext) the addition of which was held back by an overlapping voter in the former outgoing config will be inserted into Learners.
sourcepub fn simple(
&mut self,
ccs: &[ConfChangeSingle]
) -> Result<(Configuration, MapChange)>
pub fn simple( &mut self, ccs: &[ConfChangeSingle] ) -> Result<(Configuration, MapChange)>
Carries out a series of configuration changes that (in aggregate) mutates the
incoming majority config Voters[0]
by at most one. This method will return an
error if that is not the case, if the resulting quorum is zero, or if the
configuration is in a joint state (i.e. if there is an outgoing configuration).