RaftMessage

Enum RaftMessage 

Source
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>
where T: LogData + Clone,

Source§

fn clone(&self) -> RaftMessage<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
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.
Source§

impl<T> Debug for RaftMessage<T>
where T: LogData + Debug,

Source§

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

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

impl<T: Clone + Debug + Default + Serialize + DeserializeOwned + LogData> Default for RaftMessage<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

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>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T: LogData> Display for RaftMessage<T>

Source§

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

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

impl<T: LogData + Clone + Debug + Default + Serialize + DeserializeOwned> IdentificableMessage for RaftMessage<T>

Source§

fn id() -> u8

Source§

impl<T> PartialEq for RaftMessage<T>
where T: LogData + PartialEq,

Source§

fn eq(&self, other: &RaftMessage<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Serialize for RaftMessage<T>
where T: LogData + Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> Eq for RaftMessage<T>
where T: LogData + Eq,

Source§

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> 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> 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 = 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>,

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

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

Source§

fn vzip(self) -> V

Source§

impl<T> Body for T
where T: Clone + Debug,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Readable for T
where T: Debug,

Source§

impl<T> Writable for T
where T: Debug,