Struct hyparview::Node [−][src]
pub struct Node<T, R = ThreadRng> { /* fields omitted */ }
HyParView node.
Note on the guarantee of the connectivity of a HyParView cluster
Because HyParView is a probabilistic algorithm, there is no strong guarantee about the connectivity of the nodes which consist a cluster.
If the membership of a cluster changes drastically, there is a (usually very low) possibility that the cluster will be splitted to some sub-clusters.
For recovering the connectivity,
an upper layer have to provide some kind of connectivity checking mechanism.
And when the cluster division is detected, Node::join
method should be called in some nodes.
Methods
impl<T> Node<T, ThreadRng> where
T: Clone + Eq,
[src]
impl<T> Node<T, ThreadRng> where
T: Clone + Eq,
impl<T, R> Node<T, R> where
T: Clone + Eq,
R: Rng,
[src]
impl<T, R> Node<T, R> where
T: Clone + Eq,
R: Rng,
pub fn with_options(node_id: T, options: NodeOptions<R>) -> Self
[src]
pub fn with_options(node_id: T, options: NodeOptions<R>) -> Self
Makes a new Node
instance with the given options.
pub fn id(&self) -> &T
[src]
pub fn id(&self) -> &T
Returns a reference to the ID of the instance.
pub fn active_view(&self) -> &[T]
[src]
pub fn active_view(&self) -> &[T]
Returns a reference to the active view of the instance.
pub fn passive_view(&self) -> &[T]
[src]
pub fn passive_view(&self) -> &[T]
Returns a reference to the passive view of the instance.
pub fn options(&self) -> &NodeOptions<R>
[src]
pub fn options(&self) -> &NodeOptions<R>
Returns a reference to the options of the instance.
pub fn options_mut(&mut self) -> &mut NodeOptions<R>
[src]
pub fn options_mut(&mut self) -> &mut NodeOptions<R>
Returns a mutable reference to the options of the instance.
pub fn join(&mut self, contact_node_id: T)
[src]
pub fn join(&mut self, contact_node_id: T)
Starts joining the cluster to which contact_node_id
belongs.
This method may be called multiple times for recovering cluster connectivity if an upper layer detects the cluster is splitted to sub-clusters.
pub fn disconnect(&mut self, node: &T)
[src]
pub fn disconnect(&mut self, node: &T)
Removes node
from the active view of the instance.
If there is no such node, it is simply ignored.
If the active view is not full, a node randomly selected from the passive view will be promoted to the active view if possible.
pub fn leave(&mut self)
[src]
pub fn leave(&mut self)
Leaves the cluster.
For disconnecting the neighbors correctly,
you need to handle the results of poll_action
method until it returns None
.
pub fn handle_protocol_message(&mut self, message: ProtocolMessage<T>)
[src]
pub fn handle_protocol_message(&mut self, message: ProtocolMessage<T>)
Handles the given incoming message.
pub fn shuffle_passive_view(&mut self)
[src]
pub fn shuffle_passive_view(&mut self)
Starts shuffling the passive view of the instance.
This method should be invoked periodically to keep the passive view fresh.
pub fn fill_active_view(&mut self)
[src]
pub fn fill_active_view(&mut self)
Promotes a node from the passive view to the active view if the latter is not full.
This method should be invoked periodically to keep the active view full.
pub fn poll_action(&mut self) -> Option<Action<T>>
[src]
pub fn poll_action(&mut self) -> Option<Action<T>>
Polls the next action that the node wants to execute.
For running the HyParView node correctly, this method must be called periodically and the resulting action must be executed by the caller.