pub enum RaftMessage<T>where
T: LogData,{
RequestVote(RequestVoteArgs),
RequestVoteResponse(RequestVoteResponseResult),
AppendLog(AppendLogArgs<T>),
AppendLogResponse(AppendLogResponseResult),
ReadRequest,
ReadRequestReply(ReadRequestReplyArgs<T>),
WriteRequest(WriteRequestArgs),
WriteRequestReply(bool, Option<SystemNodeId>),
ConfigChange(UpdateClusterVec),
ConfigChangeACK(bool),
InstallSnapshot(InstallSnapshotArgs<T>),
InstallSnapshotResponse(Term),
}Variants§
RequestVote(RequestVoteArgs)
RequestVoteResponse(RequestVoteResponseResult)
AppendLog(AppendLogArgs<T>)
AppendLogResponse(AppendLogResponseResult)
ReadRequest
ReadRequestReply(ReadRequestReplyArgs<T>)
WriteRequest(WriteRequestArgs)
WriteRequestReply(bool, Option<SystemNodeId>)
ConfigChange(UpdateClusterVec)
ConfigChangeACK(bool)
InstallSnapshot(InstallSnapshotArgs<T>)
InstallSnapshotResponse(Term)
Trait Implementations§
Source§impl<T> Clone for RaftMessage<T>
impl<T> Clone for RaftMessage<T>
Source§fn clone(&self) -> RaftMessage<T>
fn clone(&self) -> RaftMessage<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Stopwatch, L: LogData> CoordinationService<T, RaftMessage<L>, LinearMap<SystemNodeId, RaftMetadata, CLUSTER_NODE_COUNT>, RaftMetadata> for RaftService<T, L>
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
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::AppendLogare 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::AppendLogResponsebefore 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,
AppendLogmessages. This is set to be equal to the root timeout.
Source§fn leader(&self) -> Option<SystemNodeId>
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
fn get_state(&self) -> SystemState
Returns the coordinated state of the system
Source§fn get_current_rule(&self) -> Option<Rule>
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,
)
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,
)
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,
)
fn update_state( &mut self, communication_service: &mut dyn CommunicationService<RaftPackage<L>>, measurement: Measurement, )
Updates the coordinated state of the system based on
measurementSource§fn process(
&mut self,
communication_service: &mut dyn CommunicationService<RaftPackage<L>>,
package: Option<CoordinationPackage<RaftMessage<L>>>,
members: LinearMap<SystemNodeId, RaftMetadata, CLUSTER_NODE_COUNT>,
)
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.
Source§impl<T> Debug for RaftMessage<T>
impl<T> Debug for RaftMessage<T>
Source§impl<T: Clone + Debug + Default + Serialize + DeserializeOwned + LogData> Default for RaftMessage<T>
impl<T: Clone + Debug + Default + Serialize + DeserializeOwned + LogData> Default for RaftMessage<T>
Source§impl<'de, T> Deserialize<'de> for RaftMessage<T>where
T: LogData + Deserialize<'de>,
impl<'de, T> Deserialize<'de> for RaftMessage<T>where
T: LogData + Deserialize<'de>,
Source§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
Source§impl<T: LogData> Display for RaftMessage<T>
impl<T: LogData> Display for RaftMessage<T>
Source§impl<T: LogData + Clone + Debug + Default + Serialize + DeserializeOwned> IdentificableMessage for RaftMessage<T>
impl<T: LogData + Clone + Debug + Default + Serialize + DeserializeOwned> IdentificableMessage for RaftMessage<T>
Source§impl<T> PartialEq for RaftMessage<T>
impl<T> PartialEq for RaftMessage<T>
Source§impl<T> Serialize for RaftMessage<T>
impl<T> Serialize for RaftMessage<T>
impl<T> Eq for RaftMessage<T>
impl<T> StructuralPartialEq for RaftMessage<T>where
T: LogData,
Auto Trait Implementations§
impl<T> Freeze for RaftMessage<T>where
T: Freeze,
impl<T> RefUnwindSafe for RaftMessage<T>where
T: RefUnwindSafe,
impl<T> Send for RaftMessage<T>where
T: Send,
impl<T> Sync for RaftMessage<T>where
T: Sync,
impl<T> Unpin for RaftMessage<T>where
T: Unpin,
impl<T> UnwindSafe for RaftMessage<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more