SOLA
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
minhton::JoinAlgorithmGeneral Class Referenceabstract
Inheritance diagram for minhton::JoinAlgorithmGeneral:
minhton::JoinAlgorithmInterface minhton::AlgorithmInterface minhton::MinhtonJoinAlgorithm MinhtonJoinAlgorithmForTest

Public Member Functions

 JoinAlgorithmGeneral (std::shared_ptr< AccessContainer > access)
 
void process (const MessageVariant &msg) override
 
void initiateJoin (NodeInfo &node_info) override
 
void initiateJoin (const PhysicalNodeInfo &p_node_info) override
 
- Public Member Functions inherited from minhton::JoinAlgorithmInterface
 JoinAlgorithmInterface (std::shared_ptr< AccessContainer > access)
 
- Public Member Functions inherited from minhton::AlgorithmInterface
 AlgorithmInterface (std::shared_ptr< AccessContainer > access)
 

Protected Member Functions

virtual void processJoin (const MessageJoin &msg)=0
 
void processJoinAccept (const MessageJoinAccept &msg)
 
void processJoinAcceptAck (const MessageJoinAcceptAck &msg)
 
void performAcceptChild (minhton::NodeInfo entering_node, bool use_complete_balancing=false)
 
void continueAcceptChildProcedure (const minhton::MessageInformAboutNeighbors &message) noexcept(false) override
 
void performSendJoinAccept (const minhton::NodeInfo &entering_node, const minhton::NodeInfo &entering_node_adj_left, const minhton::NodeInfo &entering_node_adj_right)
 
virtual uint32_t performSendUpdateNeighborMessagesAboutEnteringNode (minhton::NodeInfo entering_node)=0
 
std::vector< minhton::NodeInfogetRoutingTableNeighborsForNewChild (const minhton::NodeInfo &new_child) const
 
minhton::NodeInfo calcNewChildPosition (bool use_complete_balancing=false) const
 
minhton::NodeInfo calcAdjacentLeftOfNewChild (const minhton::NodeInfo &entering_node) const
 
minhton::NodeInfo calcAdjacentRightOfNewChild (const minhton::NodeInfo &entering_node) const
 
minhton::NodeInfo calcOurNewAdjacentLeft (const minhton::NodeInfo &entering_node, const minhton::NodeInfo &entering_node_adj_right) const
 
minhton::NodeInfo calcOurNewAdjacentRight (const minhton::NodeInfo &entering_node, const minhton::NodeInfo &entering_node_adj_left) const
 
bool mustSendUpdateLeft (const minhton::NodeInfo &entering_node_adj_right) const
 
bool mustSendUpdateRight (const minhton::NodeInfo &entering_node_adj_left) const
 
minhton::NodeInfo getCloserAdjacent (const minhton::NodeInfo &entering_node, const minhton::NodeInfo &alleged_adjacent) const
 
void allUpdatesAcknowledged ()
 
- Protected Member Functions inherited from minhton::AlgorithmInterface
void send (const MessageVariant &msg)
 
std::shared_ptr< RoutingInformationgetRoutingInfo () const
 
NodeInfo getSelfNodeInfo () const
 

Protected Attributes

PhysicalNodeInfo last_join_info_
 
- Protected Attributes inherited from minhton::AlgorithmInterface
std::shared_ptr< AccessContaineraccess_
 

Additional Inherited Members

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

Member Function Documentation

◆ calcAdjacentLeftOfNewChild()

minhton::NodeInfo minhton::JoinAlgorithmGeneral::calcAdjacentLeftOfNewChild ( const minhton::NodeInfo entering_node) const
protected

Calculates the new adjacent left of the entering node, which we accept as our child.

Typical usage:

minhton::NodeInfo entering_node_new_adj_left =
routingInfo->calcAdjacentLeftOfNewChild();
Definition node_info.h:24
Parameters
entering_nodethe node that we accept as a child
Returns
NodeInfo object of adjacent left of new child, or uninitialized NodeInfo if entering_node doesn't have one

◆ calcAdjacentRightOfNewChild()

minhton::NodeInfo minhton::JoinAlgorithmGeneral::calcAdjacentRightOfNewChild ( const minhton::NodeInfo entering_node) const
protected

Calculates the new adjacent right of the entering node, which we accept as our child.

Typical usage:

minhton::NodeInfo entering_node_new_adj_right =
routingInfo->calcAdjacentRightOfNewChild();
Parameters
entering_nodethe node that we accept as a child
Returns
NodeInfo object of adjacent right of new child, or uninitialized NodeInfo if entering_node doesn't have one

◆ calcNewChildPosition()

minhton::NodeInfo minhton::JoinAlgorithmGeneral::calcNewChildPosition ( bool  use_complete_balancing = false) const
protected

Looks for the position of a new free child. The position which is horizontally closest to root is chosen when the tree has a general null balance. For complete balancing the first free position from left to right is chosen. This method is only used in the perform accept child procedure.

Typical usage:

minhton::NodeInfo new_child = routingInfo->calcNewChildPosition();
Parameters
use_complete_balancingchoose if the complete balancing (necessary for the MINHTON join algorithm) has to be used
Returns
NodeInfo object or nullptr if there is no free child position

First we have to intialize the worst case distance to root, because we want to find the child position with the shortest horizontal distance to root.

In the for loop we are looking at each child position, which is uninitialized (nullptr). The distance to root gets calculated with the tree mapper. If our distance is shorter, we save it. In the end we create a NodeInfo object with the calculated position.

If there is no free child position, we return nullptr.

◆ calcOurNewAdjacentLeft()

minhton::NodeInfo minhton::JoinAlgorithmGeneral::calcOurNewAdjacentLeft ( const minhton::NodeInfo entering_node,
const minhton::NodeInfo entering_node_adj_right 
) const
protected

Calculates the new adjacent left for us, which might change when we accept the entering node as a new child.

For this we must have already calculated the new adjacent right of the entering node.

Typical usage:

minhton::NodeInfo our_new_adj_left = this->routingInfo_.calcOurNewAdjacentLeft();
Parameters
entering_nodethe node that we accept as a child
Returns
NodeInfo of our new adjacent left, or our old adjacent left, if it hasn't changed

Helper method to calculatet our own adjacent left in the accept child procedure

◆ calcOurNewAdjacentRight()

minhton::NodeInfo minhton::JoinAlgorithmGeneral::calcOurNewAdjacentRight ( const minhton::NodeInfo entering_node,
const minhton::NodeInfo entering_node_adj_left 
) const
protected

Calculates the new adjacent right for us, which might change when we accept the entering node as a new child.

For this we must have already calculated the new adjacent left of the entering node.

Typical usage:

minhton::NodeInfo our_new_adj_right = this->routingInfo_.calcOurNewAdjacentRight();
Parameters
entering_nodethe node that we accept as a child
Returns
NodeInfo of our new adjacent right, or our old adjacent right, if it hasn't changed

Helper method to calculatet our own adjacent left in the accept child procedure

◆ continueAcceptChildProcedure()

void minhton::JoinAlgorithmGeneral::continueAcceptChildProcedure ( const minhton::MessageInformAboutNeighbors message)
overrideprotectedvirtualnoexcept

We had to pause the join accept procedure to get information about the correct adjacents for the entering node.

We received this information in the InformAboutNeighbors message and check if we now got actually the closest adjacent.

If yes we can procede and send the join accept message to the entering node.

Typical Usage:

this->continueAcceptChildProcedure(incoming_message);
void continueAcceptChildProcedure(const minhton::MessageInformAboutNeighbors &message) noexcept(false) override
Definition join_algorithm_general.cpp:140
Parameters
messagethe message contining information about the correct adjacents

Implements minhton::JoinAlgorithmInterface.

◆ getCloserAdjacent()

minhton::NodeInfo minhton::JoinAlgorithmGeneral::getCloserAdjacent ( const minhton::NodeInfo entering_node,
const minhton::NodeInfo alleged_adjacent 
) const
protected

Helper method for the join accept procedure.

With higher fanouts in some cases the parent is not able to calculate the correct adjacent neighbor of an entering node.

In this case we must check with the horizontal value if there might be another node which is closer to the entering node, than the allegedly adjacent node the parent calculated.

For this our children have to be set correctly, because we may not calculate a closer adjacent as one of our children which do not exist yet.

This method is probably taking A LOT OF TIME in bigger trees and must be optimized eventually! We iterate through almost the whole tree and calculate all tree mapper values. It should be possible to reduce the calculation to only a part of the tree.

Typical usage:

auto closer_node = this->routing_info.getCloserAdjacent(entering_node,
entering_node_adj_left); if(!closer_node.isInitialized()) {
// executing procedure to get the right adjacent
}
Parameters
entering_nodenew child of the parent which wants to enter the network
alleged_adjacentthe closest adjacent node the parent knows for the new child
Returns
NodeInfo object with a closer position if one if found, otherwise uninitialized object

◆ getRoutingTableNeighborsForNewChild()

std::vector< minhton::NodeInfo > minhton::JoinAlgorithmGeneral::getRoutingTableNeighborsForNewChild ( const minhton::NodeInfo new_child) const
protected

Returning all existing routing table neighbor information for a new given child.

When we accept a new child we need to give it also its routing table information.

Because of the BATON theorem we have information about all the existing routing table neighbors of the new child through out routing table neighbor children, because we are its parent.

Typical usage:

this->routing_info_.getRoutingTableNeighborsForNewChild(new_child);
Parameters
new_childthat we are the parent of
Returns
vector of all NodeInfo objects for the routing table neighbors of the new child

e.g. fanout 2, we are 1:0 and entering node is 2:0 if 2:1 and 2:2 will be rt routing table neighbors of 2:0 if they exist, we know them through routing table neighbor children and return them

◆ initiateJoin() [1/2]

void minhton::JoinAlgorithmGeneral::initiateJoin ( const PhysicalNodeInfo p_node_info)
overridevirtual

Sending the initial Join message for a node to join the network. Only for join via address, not bootstrap.

Parameters
p_node_infoaddress to send initial join to

Implements minhton::JoinAlgorithmInterface.

◆ initiateJoin() [2/2]

void minhton::JoinAlgorithmGeneral::initiateJoin ( NodeInfo node_info)
overridevirtual

Sending the initial Join message for a node to join the network. Only for join via nodeinfo with address, not bootstrap.

Parameters
node_infonode to send initial join to

Implements minhton::JoinAlgorithmInterface.

◆ mustSendUpdateLeft()

bool minhton::JoinAlgorithmGeneral::mustSendUpdateLeft ( const minhton::NodeInfo entering_node_adj_right) const
protected

Calculates whether we have to send a update left message or not.

Typical usage:

bool send_upate_left = routingInfo->mustSendUpdateLeft(entering_node_adj_right);
Parameters
entering_node_adj_rightthe adjacent right of the entering node, as calculated previously
Returns
true if we have to send an update left message, false if not

Checking if we must send an update to the adjacent left in the accept child procedure

◆ mustSendUpdateRight()

bool minhton::JoinAlgorithmGeneral::mustSendUpdateRight ( const minhton::NodeInfo entering_node_adj_left) const
protected

Calculates whether we have to send a update right message or not.

Typical usage:

bool send_upate_right = routingInfo->mustSendUpdateRight(entering_node_adj_left);
Parameters
entering_node_adj_leftthe adjacent left of the entering node, as calculated previously
Returns
true if we have to send an update right message, false if not

Checking if we must send an update to the adjacent right in the accept child procedure

◆ performAcceptChild()

void minhton::JoinAlgorithmGeneral::performAcceptChild ( minhton::NodeInfo  entering_node,
bool  use_complete_balancing = false 
)
protected

Initializing the procedure to accept a child.

Calculating all relevant information for the entering_node / new child and sending those information via a JOIN_ACCEPT Message to the entering_node.

If we do not have information to the adjacents we need to send GET_NEIGHBORS messages to get the information and pause the procedure.

Typical Usage:

this->performAcceptChild(entering_node);
void performAcceptChild(minhton::NodeInfo entering_node, bool use_complete_balancing=false)
Definition join_algorithm_general.cpp:51
Parameters
entering_nodethe node who wants to enter the network
use_complete_balancingchoose if the complete balancing (necessary for the MINHTON join algorithm) has to be used

CHECK

We need to check here first that our FSM state is kConnected. Nothing else! E.g. if we are in the kConnectedReplacing, we are just trying to replace another node, and accepting a new child at the same time would be a very bad idea. How would we forward the join message backwards if this happens?

Also if we are in kConnectedAcceptingChild state, we might be accepting too many children at the same time. Important Question: What should we do, if the network is getting too many join requests at the same time, and the join algorithm is forwarding all of them to the same node - so that all join messages end up at the same node, who thinks he could accept all of them.

◆ performSendJoinAccept()

void minhton::JoinAlgorithmGeneral::performSendJoinAccept ( const minhton::NodeInfo entering_node,
const minhton::NodeInfo entering_node_adj_left,
const minhton::NodeInfo entering_node_adj_right 
)
protected

Gathering all information for the entering node and sending a JOIN_ACCEPT message.

Typical Usage:

this->performSendJoinAccept(entering_node, entering_node_adj_left, entering_node_adj_right);
void performSendJoinAccept(const minhton::NodeInfo &entering_node, const minhton::NodeInfo &entering_node_adj_left, const minhton::NodeInfo &entering_node_adj_right)
Definition join_algorithm_general.cpp:181
Parameters
entering_nodethe node who wants to enter the network
entering_node_adj_leftadjacent left neighbor of the entering node
entering_node_adj_rightadjacent right neighbor of the entering node

◆ performSendUpdateNeighborMessagesAboutEnteringNode()

virtual uint32_t minhton::JoinAlgorithmGeneral::performSendUpdateNeighborMessagesAboutEnteringNode ( minhton::NodeInfo  entering_node)
protectedpure virtual

Helper method for the perform accept child procedure.

Sending UPDATE_ROUTING_TABLE_NEIGHBOR_CHILD messages with the entering_node as the node to inform to each of our routing table neighbors, because those nodes have the entering_node as a routing table neighbor child.

Typical Usage:

virtual uint32_t performSendUpdateNeighborMessagesAboutEnteringNode(minhton::NodeInfo entering_node)=0
Parameters
entering_nodethe node who wants to enter the network
Returns
number of nodes that we contacted with the update

Implemented in minhton::MinhtonJoinAlgorithm, and MinhtonJoinAlgorithmForTest.

◆ process()

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

◆ processJoin()

virtual void minhton::JoinAlgorithmGeneral::processJoin ( const MessageJoin msg)
protectedpure virtual

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

Forwarding JOIN Messages according to the fill join algorithm.

When this node is a fitting position to accept the entering node, it will call initialize the JoinAccept procedure. Otherwise it will further forward the message to the next node.

Typical Usage:

this->processJoin(incoming_message);
virtual void processJoin(const MessageJoin &msg)=0
Parameters
msgthe message we received and want to process
Exceptions
AlgorithmException if join case couldn't be handled

Implemented in minhton::MinhtonJoinAlgorithm.

◆ processJoinAccept()

void minhton::JoinAlgorithmGeneral::processJoinAccept ( const MessageJoinAccept msg)
protected

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

We previously sent a JOIN message and now get an answer from our new parent node. The message contains all relevant information about the network we need to know.

In the end we must send a processJoinAcceptAck message pack to the parent. Only after that the parent will update the network informing everybody that we joined.

Typical Usage:

this->processJoinAccept(incoming_message);
void processJoinAccept(const MessageJoinAccept &msg)
Definition join_algorithm_general.cpp:207
Parameters
msgthe message we received and want to process

We are the entering node and received this message from our new parent.

Target contains the logical position about ourselves which our parent calculated for us.

The sender is our parent.

◆ processJoinAcceptAck()

void minhton::JoinAlgorithmGeneral::processJoinAcceptAck ( const MessageJoinAcceptAck msg)
protected

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

We are the parent of the entering node. Now we must send update messages to update the routing information of the whole network.

For this we sent UPDATE_NEIGHBOR messages.

Typical Usage:

this->processJoinAcceptAck(incoming_message);
void processJoinAcceptAck(const MessageJoinAcceptAck &msg)
Definition join_algorithm_general.cpp:253
Parameters
msgthe message we received and want to process

We are the parent of the node that has entered the network and now need to send around information through the network to inform other nodes about the entered node and update our own adjacent information.


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