[−][src]Struct hyparview::Node
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, R> Node<T, R> where
T: Clone + Eq,
R: Rng,
[src]
T: Clone + Eq,
R: Rng,
pub fn new(node_id: T, rng: R) -> Self
[src]
Makes a new Node
instance with the default options.
pub fn with_options(node_id: T, rng: R, options: NodeOptions) -> Self
[src]
Makes a new Node
instance with the given options.
pub fn id(&self) -> &T
[src]
Returns a reference to the ID of the instance.
pub fn active_view(&self) -> &[T]
[src]
Returns a reference to the active view of the instance.
pub fn passive_view(&self) -> &[T]
[src]
Returns a reference to the passive view of the instance.
pub fn options(&self) -> &NodeOptions
[src]
Returns a reference to the options of the instance.
pub fn options_mut(&mut self) -> &mut NodeOptions
[src]
Returns a mutable reference to the options of the instance.
pub fn join(&mut self, contact_node_id: T)
[src]
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, alive: bool)
[src]
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.
This is equivalent to the following code:
let message = ProtocolMessage::Disconnect(DisconnectMessage{sender: node.clone(), alive});
self.handle_protocol_message(message);
pub fn handle_protocol_message(&mut self, message: ProtocolMessage<T>)
[src]
Handles the given incoming message.
pub fn shuffle_passive_view(&mut self)
[src]
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]
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 sync_active_view(&mut self)
[src]
Sends NEIGHBOR
message to the members of the active view for
maintaining the symmetry property of the view.
This method should be invoked periodically to keep the symmetry property of the active view.
pub fn poll_action(&mut self) -> Option<Action<T>>
[src]
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.
Trait Implementations
Auto Trait Implementations
impl<T, R> Send for Node<T, R> where
R: Send,
T: Send,
R: Send,
T: Send,
impl<T, R> Sync for Node<T, R> where
R: Sync,
T: Sync,
R: Sync,
T: Sync,
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,