pub struct RaftService<T: Stopwatch, L: LogData> {
    pub members_already_setup: bool,
    /* private fields */
}
Expand description

This is the implementation of the CoordinationService for the raft algorithm.

Fields§

§members_already_setup: bool

Implementations§

source§

impl<T: Stopwatch, L: LogData> RaftService<T, L>

source

pub fn is_leader(&self) -> bool

source

pub fn process( &mut self, communication_service: &mut dyn CommunicationService<RaftPackage<L>>, message: Option<Package<SystemNodeId, RaftMessage<L>>>, members: Option<LinearMap<SystemNodeId, RaftMetadata, CLUSTER_NODE_COUNT>> )

source

pub fn tick( &mut self, communication_service: &mut dyn CommunicationService<RaftPackage<L>> )

source

pub fn reject_read_request( &mut self, header: Header<SystemNodeId>, communication_service: &mut dyn CommunicationService<RaftPackage<L>> )

source

pub fn reject_write_request( &mut self, header: Header<SystemNodeId>, communication_service: &mut dyn CommunicationService<RaftPackage<L>> )

source

pub fn current_config(&self) -> UpdateClusterVec

source

pub fn update_config(&mut self, new_cluster: &UpdateClusterVec)

source

pub fn update_commit_index(&mut self)

source

pub fn replicate_entry( &mut self, entry: LogEntry<L>, communication_service: &mut dyn CommunicationService<RaftPackage<L>> )

Trait Implementations§

source§

impl<T: Stopwatch, L: LogData> CoordinationService<T, RaftMessage<L>, LinearMap<SystemNodeId, RaftMetadata, CLUSTER_NODE_COUNT>, RaftMetadata> for RaftService<T, L>

source§

fn new(id: SystemNodeId, metadata: RaftMetadata) -> Self

The id will identify this nodes and the metadata will be used to obtain the root timeout. From that value the heartbeat timeout, the candidate timeout, and the follower timeout will be computed as follows:

  • The heartbeat: this is the time between empty RaftMessage::AppendLog are sent to the followers is set to be 20% of the root timeout.
  • The candidate timeout: this is the time candidates will wait for the RaftMessage::AppendLogResponse before starting a new election. This is set to be the 75% of the root timeout
  • Follower timeout: this is the time a follower will wait for heartbeats, this is, AppendLog messages. This is set to be equal to the root timeout.
source§

fn leader(&self) -> Option<SystemNodeId>

Returns the ID of the cluster leader, or None if it is not set.
source§

fn get_state(&self) -> SystemState

Returns the coordinated state of the system
source§

fn get_current_rule(&self) -> Option<Rule>

Returns the current rule coordinated by the system
source§

fn update_rule( &mut self, communication_service: &mut dyn CommunicationService<Package<SystemNodeId, RaftMessage<L>>>, new_rule: Rule )

Updates the nodes in the cluster based on [new_config].
source§

fn update_members( &mut self, communication_service: &mut dyn CommunicationService<RaftPackage<L>>, new_config: UpdateClusterVec )

Updates the nodes in the cluster based on [new_config].
source§

fn update_state( &mut self, communication_service: &mut dyn CommunicationService<RaftPackage<L>>, measurement: Measurement )

Updates the coordinated state of the system based on measurement
source§

fn process( &mut self, communication_service: &mut dyn CommunicationService<RaftPackage<L>>, package: Option<CoordinationPackage<RaftMessage<L>>>, members: LinearMap<SystemNodeId, RaftMetadata, CLUSTER_NODE_COUNT> )

Receives a message from another node so that the coordination can occur.

Auto Trait Implementations§

§

impl<T, L> RefUnwindSafe for RaftService<T, L>

§

impl<T, L> Send for RaftService<T, L>
where L: Send, T: Send,

§

impl<T, L> Sync for RaftService<T, L>
where L: Sync, T: Sync,

§

impl<T, L> Unpin for RaftService<T, L>
where L: Unpin, T: Unpin,

§

impl<T, L> UnwindSafe for RaftService<T, L>
where L: UnwindSafe, 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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V