Struct AppState

Source
pub struct AppState {
Show 16 fields site_id: String, site_addr: SocketAddr, cli_peer_addrs: Vec<SocketAddr>, connected_neighbours_addrs: Vec<SocketAddr>, neighbours_socket: HashMap<SocketAddr, SocketAddr>, sync_needed: bool, nb_first_attended_neighbours: i64, pub site_ids_to_adr: HashMap<SocketAddr, String>, pub parent_addr_for_transaction_wave: HashMap<String, SocketAddr>, pub attended_neighbours_nb_for_transaction_wave: HashMap<String, i64>, clocks: Clock, pub global_mutex_fifo: HashMap<String, MutexStamp>, pub waiting_sc: bool, pub in_sc: bool, pub notify_sc: Arc<Notify>, pub pending_commands: VecDeque<CriticalCommands>,
}
Expand description

Represents the global state of a Peillute node

Fields§

§site_id: String

Unique identifier for this site

§site_addr: SocketAddr

Unique address for this site

§cli_peer_addrs: Vec<SocketAddr>

List of peer addresses given in arguments at the launch of the application

§connected_neighbours_addrs: Vec<SocketAddr>

List of deg(1) neighbours connected addresses

§neighbours_socket: HashMap<SocketAddr, SocketAddr>

Hashmap of sockets for each deg(1) neighbours

§sync_needed: bool

Synchronization boolean

§nb_first_attended_neighbours: i64

Number of attended neighbours at launch, for the discovery phase

§site_ids_to_adr: HashMap<SocketAddr, String>§parent_addr_for_transaction_wave: HashMap<String, SocketAddr>

Adress of the parent (deg(1) neighbour for this site) for a specific wave from initiator id

§attended_neighbours_nb_for_transaction_wave: HashMap<String, i64>

Number of response expected from our direct neighbours (deg(1) neighbours for this site) = nb of connected neighbours - 1 (parent) for a specific wave initiator id

§clocks: Clock

Logical clock implementation for distributed synchronization

§global_mutex_fifo: HashMap<String, MutexStamp>§waiting_sc: bool§in_sc: bool§notify_sc: Arc<Notify>§pending_commands: VecDeque<CriticalCommands>

Implementations§

Source§

impl AppState

Source

pub fn new( site_id: String, peer_addrs: Vec<SocketAddr>, local_addr: SocketAddr, ) -> Self

Creates a new AppState instance with the given configuration

Source

pub fn get_global_mutex_fifo(&self) -> &HashMap<String, MutexStamp>

Source

pub fn set_global_mutex_fifo( &mut self, global_mutex_fifo: HashMap<String, MutexStamp>, )

Source

pub fn add_site_id(&mut self, site_id: String, addr: SocketAddr)

Source

pub fn init_site_id(&mut self, site_id: String)

Sets the site ID at initialization

Source

pub fn init_site_addr(&mut self, site_addr: SocketAddr)

Sets the site address at initialization

Source

pub fn init_cli_peer_addrs(&mut self, cli_peer_addrs: Vec<SocketAddr>)

Sets the list of CLI peer addresses at initialization

Source

pub fn init_clock(&mut self, clock: Clock)

Set the clock at initialization

Source

pub fn init_sync(&mut self, sync_needed: bool)

Set the sync boolean at initialization

Source

pub fn get_sync(&self) -> bool

Get the sync boolean

Source

pub fn init_nb_first_attended_neighbours(&mut self, nb: i64)

Set the number of attended neighbours at initialization

Source

pub fn get_nb_first_attended_neighbours(&self) -> i64

Get the number of attended neighbours

Source

pub fn init_parent_addr_for_transaction_wave(&mut self)

Initialize the parent of the current site as self for the wave protocol

Source

pub fn add_incomming_peer( &mut self, new_addr: SocketAddr, new_socket: SocketAddr, received_clock: Clock, )

Adds a new peer to the network and updates the logical clock

This function should be safe to call multiple times

If a new site appear on the netword, every peers will launch a wave diffusion to announce the presence of this new site

Source

pub async fn remove_peer(&mut self, addr_to_remove: SocketAddr)

Removes a peer from the network

This function should be safe to call multiple times

If a site disappear from the network, every neighbours will detected the closing of the tcp connection and will launch a wave diffusion to announce the disappearance of this site

If a site is closed properly, it will send a disconnect message to all its neighbours

Source

pub async fn remove_peer_from_socket_closed( &mut self, socket_to_remove: SocketAddr, )

Removes a peer from the network with only an address

This function should be safe to call multiple times

If a site disappear from the network, every neighbours will detected the closing of the tcp connection and will launch a wave diffusion to announce the disappearance of this site

If a site is closed properly, it will send a disconnect message to all its neighbours

Source

pub fn get_site_addr(&self) -> SocketAddr

Returns the local address as a string

Source

pub async fn acquire_mutex(&mut self) -> Result<(), Box<dyn Error>>

Source

pub async fn release_mutex(&mut self) -> Result<(), Box<dyn Error>>

Source

pub fn try_enter_sc(&mut self)

Source

pub fn get_site_addr_as_string(&self) -> String

Returns the local address as a string

Source

pub fn get_site_id(&self) -> String

Returns a reference to the local address as &str

Source

pub fn get_cli_peers_addrs(&self) -> Vec<SocketAddr>

Returns a list of all peer addresses

Source

pub fn get_cli_peers_addrs_as_string(&self) -> Vec<String>

Returns a list of all peer addresses as strings

Source

pub fn get_connected_nei_addr(&self) -> Vec<SocketAddr>

Returns a list of conncted neibhours

Source

pub fn get_connected_nei_addr_string(&self) -> Vec<String>

Returns a list of conncted neibhours as strings

Source

pub fn add_connected_neighbour(&mut self, addr: SocketAddr)

Add a connected neighbour to the list of connected neighbours

Source

pub fn get_clock(&self) -> Clock

Returns the clock of the site

Source

pub fn set_nb_nei_for_wave(&mut self, initiator_id: String, n: i64)

Set the number of attended neighbors for the wave from initiator_id

Source

pub fn get_parent_for_wave_map(&self) -> HashMap<String, SocketAddr>

Get the list of attended neighbors for the wave from initiator_id

Source

pub fn get_nb_nei_for_wave(&self) -> HashMap<String, i64>

Get the list of attended neighbors for the wave from initiator_id

Source

pub fn get_parent_addr_for_wave(&self, initiator_id: String) -> SocketAddr

Get the parent (neighbour deg(1)) address for the wave from initiator_id

Source

pub fn set_parent_addr(&mut self, initiator_id: String, peer_adr: SocketAddr)

Set the parent (neighbour deg(1)) address for the wave from initiator_id

Source

pub fn get_nb_connected_neighbours(&self) -> i64

Returns the number of deg(1) neighbors connected

Source

pub async fn update_clock(&mut self, received_vc: Option<&Clock>)

Update the clock of the site

Source

pub async fn save_local_state(&self)

Auto Trait Implementations§

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.

§

impl<T> InitializeFromFunction<T> for T

§

fn initialize_from_function(f: fn() -> T) -> T

Create an instance of this type from an initialization function
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
§

impl<Ret> SpawnIfAsync<(), Ret> for Ret

§

fn spawn(self) -> Ret

Spawn the value into the dioxus runtime if it is an async block
§

impl<T, O> SuperFrom<T> for O
where O: From<T>,

§

fn super_from(input: T) -> O

Convert from a type to another type.
§

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

§

fn super_into(self) -> O

Convert from a type to another type.
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,