SOLA
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
minhton::LeaveAlgorithmGeneral Class Referenceabstract
Inheritance diagram for minhton::LeaveAlgorithmGeneral:
minhton::LeaveAlgorithmInterface minhton::AlgorithmInterface minhton::MinhtonLeaveAlgorithm MinhtonLeaveAlgorithmForTest

Public Member Functions

 LeaveAlgorithmGeneral (std::shared_ptr< AccessContainer > access)
 
void process (const MessageVariant &msg) override
 
void initiateSelfDeparture () override=0
 
- Public Member Functions inherited from minhton::LeaveAlgorithmInterface
 LeaveAlgorithmInterface (std::shared_ptr< AccessContainer > access)
 
virtual bool canLeaveWithoutReplacement ()=0
 
virtual void replaceMyself (const NodeInfo &node_to_replace, std::vector< NodeInfo > neighbors_of_node_to_replace)=0
 
- Public Member Functions inherited from minhton::AlgorithmInterface
 AlgorithmInterface (std::shared_ptr< AccessContainer > access)
 

Protected Member Functions

virtual void processFindReplacement (const minhton::MessageFindReplacement &message)=0
 
void processReplacementOffer (const minhton::MessageReplacementOffer &message)
 
void processSignOffParentRequest (const minhton::MessageSignoffParentRequest &message)
 
void processSignOffParentAnswer (const minhton::MessageSignoffParentAnswer &message)
 
void processReplacementAck (const minhton::MessageReplacementAck &message)
 
void processLockNeighborRequest (const minhton::MessageLockNeighborRequest &message)
 
void processLockNeighborResponse (const minhton::MessageLockNeighborResponse &message)
 
void processRemoveNeighborAck ()
 
void processReplacementUpdate (const minhton::MessageReplacementUpdate &message)
 
void performLeaveWithoutReplacement ()
 
void performLeaveWithReplacement (minhton::NodeInfo leaving_node, std::vector< minhton::NodeInfo > neighbors_of_leaving_node, bool leaving_node_was_locked, bool leaving_node_locked_right, bool leaving_node_locked_left)
 
void prepareLeavingAsSuccessor (const minhton::NodeInfo &node_to_replace)
 
void signOffFromParent ()
 
uint32_t signOffFromNeighborsAndAdjacents ()
 
void processUpdateForwardAck ()
 
void sendReplacementOffer ()
 
void sendNackToReplacement (uint64_t ref_event_id)
 
void replaceMyself (const minhton::NodeInfo &node_to_replace, std::vector< minhton::NodeInfo > neighbors_of_node_to_replace) override
 
void processReceiveSignoffNeighborAdjacentsAck ()
 
void processReceiveReplacementUpdateAck ()
 
void processUnlockNeighbor (const MessageUnlockNeighbor &msg)
 
- Protected Member Functions inherited from minhton::AlgorithmInterface
void send (const MessageVariant &msg)
 
std::shared_ptr< RoutingInformationgetRoutingInfo () const
 
NodeInfo getSelfNodeInfo () const
 

Static Protected Member Functions

static minhton::NodeInfo getAdjacentLeftFromVector (const minhton::NodeInfo &considered_node, std::vector< minhton::NodeInfo > neighbors)
 
static minhton::NodeInfo getAdjacentRightFromVector (const minhton::NodeInfo &considered_node, std::vector< minhton::NodeInfo > neighbors)
 

Protected Attributes

minhton::NodeInfo replacing_node_
 
uint64_t leaving_event_id_ = 0
 
bool in_leave_progress_ = false
 
bool locked_right_neighbor_ = false
 
bool locked_left_neighbor_ = false
 
uint32_t remaining_lock_neighbor_response_ = 0
 
std::shared_ptr< minhton::MessageSignoffParentRequestcurrent_signoff_request_ = nullptr
 
std::shared_ptr< minhton::MessageReplacementUpdatelast_replacement_update_ = nullptr
 
NodeInfo old_parent_
 
- Protected Attributes inherited from minhton::AlgorithmInterface
std::shared_ptr< AccessContaineraccess_
 

Additional Inherited Members

- Static Public Member Functions inherited from minhton::LeaveAlgorithmInterface
static std::vector< MessageTypegetSupportedMessageTypes ()
 

Member Function Documentation

◆ getAdjacentLeftFromVector()

NodeInfo minhton::LeaveAlgorithmGeneral::getAdjacentLeftFromVector ( const minhton::NodeInfo considered_node,
std::vector< minhton::NodeInfo neighbors 
)
staticprotected

Calculating the adjacent left of the considered node, by looking which node is closest to its left, by using the tree mapper.

Typical usage:

auto adj_left = this->routing_info_.getAdjacentLeftFromVector(considered_node,
considered_node_neighbors);
Parameters
considered_nodeof whom we want to calculate the adjacent left
neighborswe know of the considered node
Returns
NodeInfo object which should be the adjacent left

node is actually on the left side

◆ getAdjacentRightFromVector()

NodeInfo minhton::LeaveAlgorithmGeneral::getAdjacentRightFromVector ( const minhton::NodeInfo considered_node,
std::vector< minhton::NodeInfo neighbors 
)
staticprotected

Calculating the adjacent right of the considered node, by looking which node is closest to its right, by using the tree mapper.

Typical usage:

auto adj_right = this->routing_info_.getAdjacentRightFromVector(considered_node,
considered_node_neighbors);
Parameters
considered_nodeof whom we want to calculate the adjacent right
neighborswe know of the considered node
Returns
NodeInfo object which should be the adjacent right

node is actually on the right side

◆ initiateSelfDeparture()

void minhton::LeaveAlgorithmGeneral::initiateSelfDeparture ( )
overridepure virtual

We decide ourselves that we want to leave the network and initiate the leave procedure.

This method gets called when we receive a leave signal.

Typical Usage:

node->initiateSelfDeparture();

Implements minhton::LeaveAlgorithmInterface.

Implemented in minhton::MinhtonLeaveAlgorithm.

◆ performLeaveWithoutReplacement()

void minhton::LeaveAlgorithmGeneral::performLeaveWithoutReplacement ( )
protected

We know that we can leave the network without making the tree unbalanced.

For this we only have to send RemoveNeighbor messages to each neighbor who knows us and update our adjacents.

We can update the adjacents by linking our adjacent left and adjacent right together.

◆ performLeaveWithReplacement()

void minhton::LeaveAlgorithmGeneral::performLeaveWithReplacement ( minhton::NodeInfo  leaving_node,
std::vector< minhton::NodeInfo neighbors_of_leaving_node,
bool  leaving_node_was_locked,
bool  leaving_node_locked_right,
bool  leaving_node_locked_left 
)
protected

Performing the update of every PhysicalNodeInfo in a leave with replacement while we are the node replacing the leaving node.

Sending RemoveNeighbor messages to nodes who only know the removed position, and ReplacementUpdate messages to nodes who know the replaced (and removed) position. If we do not have the network information about the nodes, we send via SearchExact.

We also must update the adjacents of the removed position

Parameters
leaving_nodeThe node leaving the network and position we will replace
neighbors_of_leaving_nodeAll neighbors the leaving node knows

◆ prepareLeavingAsSuccessor()

void minhton::LeaveAlgorithmGeneral::prepareLeavingAsSuccessor ( const minhton::NodeInfo node_to_replace)
protected

Helper method to prepare leaving the network in order to replace another node. This calls signOffFromParent

Parameters
node_to_replaceThe node leaving the network

◆ process()

void minhton::LeaveAlgorithmGeneral::process ( const MessageVariant &  msg)
overridevirtual

◆ processFindReplacement()

virtual void minhton::LeaveAlgorithmGeneral::processFindReplacement ( const minhton::MessageFindReplacement message)
protectedpure virtual

This method will be called when we receive a FIND_REPLACEMENT message.

Typical Usage:

this->processFindReplacement(incoming_message);
virtual void processFindReplacement(const minhton::MessageFindReplacement &message)=0
Parameters
messagethe message we received and want to process

Implemented in minhton::MinhtonLeaveAlgorithm.

◆ processLockNeighborRequest()

void minhton::LeaveAlgorithmGeneral::processLockNeighborRequest ( const minhton::MessageLockNeighborRequest message)
protected

This method will be called when we receive a LOCK_NEIGHBOR_REQUEST message.

We are the left or right neighbor of the parent of a successor node. We try to lock ourselves for the leave procedure and respond with a MessageLockNeighborResponse, indicating success or failure of locking ourselves.

Typical Usage:

this->processLockNeighborRequest(incoming_message);
void processLockNeighborRequest(const minhton::MessageLockNeighborRequest &message)
Definition leave_algorithm_general.cpp:442
Parameters
messagethe message we received and want to process

◆ processLockNeighborResponse()

void minhton::LeaveAlgorithmGeneral::processLockNeighborResponse ( const minhton::MessageLockNeighborResponse message)
protected

This method will be called when we receive a LOCK_NEIGHBOR_RESPONSE message.

We are the parent of a successor node. When the message indicates a failure, we inform the successor about it and abort the leave. If the response comes from the right neighbor, we continue by sending a MessageLockNeighborRequest to our left neighbor. If the response comes from the left neighbor, we send a MessageRemoveNeighbor to our level neighbors and wait for all acknowledgements.

Typical Usage:

this->processLockNeighborResponse(incoming_message);
void processLockNeighborResponse(const minhton::MessageLockNeighborResponse &message)
Definition leave_algorithm_general.cpp:458
Parameters
messagethe message we received and want to process

◆ processReceiveReplacementUpdateAck()

void minhton::LeaveAlgorithmGeneral::processReceiveReplacementUpdateAck ( )
protected

This method is called after we received all acknowledgements for each MessageReplacementUpdate we sent to our neighbors.

We are the successor which is now at the position of the left node and we can unlock our parent.

◆ processReceiveSignoffNeighborAdjacentsAck()

void minhton::LeaveAlgorithmGeneral::processReceiveSignoffNeighborAdjacentsAck ( )
protected

This method is called after we received all acknowledgements from our neighbors and adjacents where we updated their routing information.

We are the sucessor for a leave procedure and continue by sending a replacement offer to the node we want to replace. But if we can leave without a replacement, we are the leaving node and can leave directly, finishing our part of the leave by going into idle and unlocking our parent.

◆ processRemoveNeighborAck()

void minhton::LeaveAlgorithmGeneral::processRemoveNeighborAck ( )
protected

This method will be called after we received all expected REMOVE_NEIGHBOR_ACK messages.

We are the parent of a successor node and inform the successor about the successful updates of all our level neighbors with a MessageSignoffParentAnswer.

◆ processReplacementAck()

void minhton::LeaveAlgorithmGeneral::processReplacementAck ( const minhton::MessageReplacementAck message)
protected

This method will be called when we receive a REPLACEMENT_ACK message.

We are the node which is replacing the leaving node. We can now initialize the whole replacement procedure.

Typical Usage:

this->processReplacementAck(incoming_message);
void processReplacementAck(const minhton::MessageReplacementAck &message)
Definition leave_algorithm_general.cpp:173
Parameters
messagethe message we received and want to process

◆ processReplacementOffer()

void minhton::LeaveAlgorithmGeneral::processReplacementOffer ( const minhton::MessageReplacementOffer message)
protected

This method will be called when we receive a REPLACEMENT_OFFER message.

We are the node which wants to leave the network. A node which can replace our position gave us an offer. If we send back a ReplacementAck we can just leave the network.

Typical Usage:

this->processReplacementOffer(incoming_message);
void processReplacementOffer(const minhton::MessageReplacementOffer &message)
Definition leave_algorithm_general.cpp:99
Parameters
messagethe message we received and want to process

◆ processReplacementUpdate()

void minhton::LeaveAlgorithmGeneral::processReplacementUpdate ( const minhton::MessageReplacementUpdate message)
protected

This method will be called when we receive a REPLACEMENT_UPDATE message.

Removing the node of the removed position from our routing information if we have it.

Replacing the PhysicalNodeInfo from the neighbor at the replaced position with those from the removed position. (Exchanging PhysicalNodeInfo of the leaving node with that of the replacing node.)

Typical Usage:

this->processReplacementUpdate(incoming_message);
void processReplacementUpdate(const minhton::MessageReplacementUpdate &message)
Definition leave_algorithm_general.cpp:129
Parameters
messagethe message we received and want to process

◆ processSignOffParentAnswer()

void minhton::LeaveAlgorithmGeneral::processSignOffParentAnswer ( const minhton::MessageSignoffParentAnswer message)
protected

This method will be called when we receive a SIGN_OFF_PARENT_ANSWER message.

We are the selected successor node for a leave procedure. If the message informs us of a failure, we abort the leave. Otherwise, we continue by calling the method signOffFromNeighborsAndAdjacents. Then we wait for all acknowledgements for the routing information updates of the nodes we sent messages to. We continue by calling the method processReceiveSignoffNeighborAdjacentsAck.

Typical Usage:

this->processSignOffParentAnswer(incoming_message);
void processSignOffParentAnswer(const minhton::MessageSignoffParentAnswer &message)
Definition leave_algorithm_general.cpp:547
Parameters
messagethe message we received and want to process

◆ processSignOffParentRequest()

void minhton::LeaveAlgorithmGeneral::processSignOffParentRequest ( const minhton::MessageSignoffParentRequest message)
protected

This method will be called when we receive a SIGN_OFF_PARENT_REQUEST message.

We are the parent of a selected successor node for a leave procedure. We might respond with a MessageSignoffParentAnswer in case we are already involved in another leave procedure. Otherwise, we continue the leave by locking our right neighbor with a MessageLockNeighborRequest. If we and the successor are the only nodes in the network, we skip the locking of our neighbors and send a MessageLockNeighborResponse to ourselves to continue.

Typical Usage:

this->processSignOffParentRequest(incoming_message);
void processSignOffParentRequest(const minhton::MessageSignoffParentRequest &message)
Definition leave_algorithm_general.cpp:393
Parameters
messagethe message we received and want to process

◆ processUnlockNeighbor()

void minhton::LeaveAlgorithmGeneral::processUnlockNeighbor ( const MessageUnlockNeighbor msg)
protected

This method will be called when we receive a UNLOCK_NEIGHBOR message.

We are either the parent of a successor of the left/right neighbor of the parent of a successor and are now allowed to unlock ourselves. In case we are the parent, we need to forward this message to our left and right neighbor.

Typical Usage:

this->processUnlockNeighbor(incoming_message);
void processUnlockNeighbor(const MessageUnlockNeighbor &msg)
Definition leave_algorithm_general.cpp:47
Parameters
messagethe message we received and want to process

◆ processUpdateForwardAck()

void minhton::LeaveAlgorithmGeneral::processUpdateForwardAck ( )
protected

This method is called after we received all expected acknowledgements for a MessageReplacementUpdate, or directly after receiving a MessageReplacementUpdate, if we don't have to forward it.

In this method we simply send a MessageRemoveNeighborAck to the node which sent us the last MessageReplacementUpdate.

◆ replaceMyself()

void minhton::LeaveAlgorithmGeneral::replaceMyself ( const minhton::NodeInfo node_to_replace,
std::vector< minhton::NodeInfo neighbors_of_node_to_replace 
)
overrideprotected

Replacing our own self_node_info and routing_info with the information that we got from the node to replace positions with.

But we keep our current PhysicalNodeInfo!

We have to iterate through the given neighbor information and determine if the neighbor is a parent, child, adjacent, routing table neighbor etc.

Parameters
node_to_replacethe node position we want to replace
neighbors_of_node_to_replaceevery neighbor the node to replace knew of

TODO sts

Determining what role each neighbor has: parent, child, routing table neighor, routing table neighbor child

Updating our Adjacent Information separately

◆ sendNackToReplacement()

void minhton::LeaveAlgorithmGeneral::sendNackToReplacement ( uint64_t  ref_event_id)
protected

This method sends a MessageReplacementNack to the successor, if we need to abort the leave procedure.

Parameters
ref_event_idref event id of the relevant leave procedure

◆ sendReplacementOffer()

void minhton::LeaveAlgorithmGeneral::sendReplacementOffer ( )
protected

Helper method to send the replacement offer message to the node who wants to leave the network.

Also setting the correct event id for the message and setting the replacement ack timeout.

◆ signOffFromNeighborsAndAdjacents()

uint32_t minhton::LeaveAlgorithmGeneral::signOffFromNeighborsAndAdjacents ( )
protected

This method is called from the processSignOffParentAnswer method.

We are a successor for a leave procedure and are now updating our neighbors. Our level neighbors receive a MessageRemoveNeighbor, which they have to acknowledge. Next, we update our adjacents by sending the left one a MessageRemoveAndUpdateNeighbors (if it is also our left neighbor) or MessageUpdateNeighbors. We send the right adjacent MessageUpdateNeighbors. The adjacents have to acknowledge their routing information update as well.

Returns
uint32_t number of nodes we expect an acknowledgement from

◆ signOffFromParent()

void minhton::LeaveAlgorithmGeneral::signOffFromParent ( )
protected

Send a MessageSignoffParentRequest to own parent. This helper method can be called from the successor or the leaving node itself if it doesn't need a successor.


The documentation for this class was generated from the following files: