SOLA
|
#include <routing_information.h>
Static Public Member Functions | |
static std::vector< minhton::NodeInfo > | calcRoutingTableNeighborParents (const minhton::NodeInfo &node) |
static std::vector< minhton::NodeInfo > | combiningNodeVectorsWithoutDuplicate (std::vector< minhton::NodeInfo > v1, const std::vector< minhton::NodeInfo > &v2) |
static std::vector< minhton::NodeInfo > | removeRoutingTableNeighborChildrenFromVector (minhton::NodeInfo node, std::vector< minhton::NodeInfo > neighbors) |
The RoutingInformation contain all information relevant to the routing in the network. This includes information about ourselves and about our neighbors (parent, children, right and left adjacents, and right and left routing tables).
|
default |
Constructor for invalid, non-existent RoutingInformation. To be used only for initialization purposes.
Typical usage:
minhton::RoutingInformation::RoutingInformation | ( | minhton::NodeInfo | self_node_info, |
Logger | logger | ||
) |
Constructor for RoutingInformation. To be re-initialized as soon as the own position in the tree is known.
Typical usage:
self_node_info | reference to the own node information |
logger | reference to the logger instance |
bool minhton::RoutingInformation::areChildrenFull | ( | ) | const |
bool minhton::RoutingInformation::areRoutingTableNeighborChildrenEmpty | ( | ) | const |
bool minhton::RoutingInformation::areRoutingTableNeighborChildrenFull | ( | ) | const |
bool minhton::RoutingInformation::areRoutingTableNeighborsFull | ( | ) | const |
bool minhton::RoutingInformation::atLeastOneChildExists | ( | ) | const |
bool minhton::RoutingInformation::atLeastOneChildIsFree | ( | ) | const |
bool minhton::RoutingInformation::atLeastOneRoutingTableNeighborChildExists | ( | ) | const |
bool minhton::RoutingInformation::atLeastOneRoutingTableNeighborChildIsFree | ( | ) | const |
|
static |
Helper method to calculate all routing table neighbor parents (those neighbors who know one node as a routing table neighbor child, but the node does not always know those neighbors (asymmetrical)).
Creates a vector of all of those neighbors, but all PhysicalNodeInfos are uninitialized.
Typical usage:
node | of which to get the parents |
|
static |
Helper method to easily add vectors of NodeInfo objects together. If there are dublicates, only one object will be added. And if one of those duplicates has PhysicalNodeInfo initialized, the one with initialized PhysicalNodeInfo will be chosen.
Typical usage:
If there is a duplicate, we will choose the node where PhysicalNodeInfo is initialized
minhton::NodeInfo minhton::RoutingInformation::getAdjacentLeft | ( | ) | const |
minhton::NodeInfo minhton::RoutingInformation::getAdjacentRight | ( | ) | const |
std::vector< minhton::NodeInfo > minhton::RoutingInformation::getAllInitializedLeftRoutingTableNeighborsAndChildren | ( | ) | const |
std::vector< minhton::NodeInfo > minhton::RoutingInformation::getAllInitializedRightRoutingTableNeighborsAndChildren | ( | ) | const |
std::vector< minhton::NodeInfo > minhton::RoutingInformation::getAllInitializedRoutingTableNeighborChildren | ( | ) | const |
std::vector< minhton::NodeInfo > minhton::RoutingInformation::getAllInitializedRoutingTableNeighbors | ( | ) | const |
std::vector< minhton::NodeInfo > minhton::RoutingInformation::getAllLeftRoutingTableNeighborsAndChildren | ( | ) | const |
std::vector< minhton::NodeInfo > minhton::RoutingInformation::getAllRightRoutingTableNeighborsAndChildren | ( | ) | const |
std::vector< minhton::NodeInfo > minhton::RoutingInformation::getAllUniqueKnownExistingNeighbors | ( | ) | const |
Returns a vector of every neighbor that we know which exists. Every neighbor will occur only once. If a neighbor is not initialized, it will not be added in the vector.
This will be used in the replacement process to tell the replacing node about every neighbor of the leaving node.
Typical usage:
std::vector< minhton::NodeInfo > minhton::RoutingInformation::getAllUniqueSymmetricalExistingNeighbors | ( | ) | const |
Returns a vector of every neighbor that we know which exists. Additionally the neighbor needs to be symmetrical. This means that if we know neigbhor A, neighbor A also needs to know us. Every neighbor will occur only once. If a neighbor is not initialized, it will not be added in the vector.
This will be used in the leaving process when sending node departure messages to address every neighbor which needs this information.
Typical usage:
minhton::NodeInfo minhton::RoutingInformation::getChild | ( | uint16_t | child_position | ) |
child_position | position of the node, 0 <= child_position < fanout |
std::vector< minhton::NodeInfo > minhton::RoutingInformation::getChildren | ( | ) | const |
minhton::NodeInfo minhton::RoutingInformation::getDirectLeftNeighbor | ( | ) | const |
minhton::NodeInfo minhton::RoutingInformation::getDirectRightNeighbor | ( | ) | const |
uint16_t minhton::RoutingInformation::getFanout | ( | ) | const |
std::vector< minhton::NodeInfo > minhton::RoutingInformation::getInitializedChildren | ( | ) | const |
std::vector< minhton::NodeInfo > minhton::RoutingInformation::getInitializedRoutingTableNeighborsAndChildren | ( | ) | const |
minhton::NodeInfo minhton::RoutingInformation::getLeftmostNeighbor | ( | ) | const |
minhton::NodeInfo minhton::RoutingInformation::getLeftmostNeighborChild | ( | ) | const |
std::vector< minhton::NodeInfo > minhton::RoutingInformation::getLeftRoutingTableNeighborChildrenLeftToRight | ( | ) | const |
std::vector< minhton::NodeInfo > minhton::RoutingInformation::getLeftRoutingTableNeighborChildrenRightToLeft | ( | ) | const |
std::vector< minhton::NodeInfo > minhton::RoutingInformation::getLeftRoutingTableNeighborsLeftToRight | ( | ) | const |
std::vector< minhton::NodeInfo > minhton::RoutingInformation::getLeftRoutingTableNeighborsRightToLeft | ( | ) | const |
minhton::NodeInfo minhton::RoutingInformation::getLowestNode | ( | ) | const |
Searches in all of our routing information for the lowest node we know, but only in nodes which are on the same level as us or lower than us in the tree (higher level number).
If such a node does not exist, an uninitialized node is returned.
Typical usage:
minhton::NodeInfo minhton::RoutingInformation::getNodeInfoByPosition | ( | uint32_t | level, |
uint32_t | number | ||
) |
Helper method for various procedures to find a NodeInfo object in the Routing Information with the given level and number. If such a node does not exist an uninitialized NodeInfo object is being returned.
level | level of the required node |
number | number of the required node |
minhton::NodeInfo minhton::RoutingInformation::getParent | ( | ) | const |
minhton::NodeInfo minhton::RoutingInformation::getRightmostNeighbor | ( | ) | const |
std::vector< minhton::NodeInfo > minhton::RoutingInformation::getRightRoutingTableNeighborChildrenLeftToRight | ( | ) | const |
std::vector< minhton::NodeInfo > minhton::RoutingInformation::getRightRoutingTableNeighborChildrenRightToLeft | ( | ) | const |
std::vector< minhton::NodeInfo > minhton::RoutingInformation::getRightRoutingTableNeighborsLeftToRight | ( | ) | const |
std::vector< minhton::NodeInfo > minhton::RoutingInformation::getRightRoutingTableNeighborsRightToLeft | ( | ) | const |
std::vector< minhton::NodeInfo > minhton::RoutingInformation::getRoutingTableNeighborChildren | ( | ) | const |
std::vector< minhton::NodeInfo > minhton::RoutingInformation::getRoutingTableNeighbors | ( | ) | const |
std::vector< minhton::NodeInfo > minhton::RoutingInformation::getRoutingTableNeighborsAndChildren | ( | ) | const |
minhton::NodeInfo minhton::RoutingInformation::getSelfNodeInfo | ( | ) | const |
std::string minhton::RoutingInformation::getString | ( | ) | const |
void minhton::RoutingInformation::removeNeighbor | ( | const minhton::NodeInfo & | position_to_remove, |
uint64_t | ref_event_id = 0 |
||
) |
Uninitializing the given position to remove. We need to have the LogicalNodeInfo position set somewhere.
When we remove an adjacent, we reset the full NodeInfo. When we remove a non adjacent, we reset only PhysicalNodeInfo. If a node has multiple roles (e.g. child and adjacent), both will be reset appropriately.
We cannot remove the parent, because that would not make any sense.
Typical usage:
position_to_remove | NodeInfo with the position to remove |
ref_event_id | ID of the event which is the reason for this change |
|
static |
Helper method to remove routing table neighbor children from a given nodes perspective from a given vector of nodes.
node | the node from whichs perspective we want to remove the routing table neighbor children |
neighbors | vector of known neighbors from which the routing table neighbor children need to be removed |
TODO unittests
void minhton::RoutingInformation::resetAdjacentLeft | ( | uint64_t | ref_event_id = 0 | ) |
Resetting information about our adjacent left. We will reset PhysicalNodeInfo and LogicalNodeInfo.
RoutingInformation needs to be initialized properly beforehand.
Typical usage:
ref_event_id | ID of the event which is the reason for this change |
void minhton::RoutingInformation::resetAdjacentRight | ( | uint64_t | ref_event_id = 0 | ) |
Resetting information about our adjacent right. We will reset PhysicalNodeInfo and LogicalNodeInfo.
RoutingInformation needs to be initialized properly beforehand.
Typical usage:
ref_event_id | ID of the event which is the reason for this change |
void minhton::RoutingInformation::resetChild | ( | uint16_t | position, |
uint64_t | ref_event_id = 0 |
||
) |
Resetting information about our child at the given position. We will only reset the PhysicalNodeInfo. LogicalNodeInfo always stays the same.
RoutingInformation needs to be initialized properly beforehand.
Typical usage:
position | position of the new child within the parent |
ref_event_id | ID of the event which is the reason for this change |
bool minhton::RoutingInformation::resetChildOrRoutingTableNeighborChild | ( | const minhton::NodeInfo & | routing_table_neighbor_child_or_child, |
uint64_t | ref_event_id = 0 |
||
) |
Resetting information about a routing table neighbor child or child. We do not need to know whether its in the left or right routing table or if its a child. Only LogicalNodeInfo is relevant, we ignore PhysicalNodeInfo. We will only reset the PhysicalNodeInfo. LogicalNodeInfo always stays the same.
RoutingInformation needs to be initialized properly beforehand.
Typical usage:
routing_table_neighbor_child_or_child | with the LogicalNodeInfo position which we want to reset |
ref_event_id | ID of the event which is the reason for this change |
bool minhton::RoutingInformation::resetRoutingTableNeighbor | ( | const minhton::NodeInfo & | routing_table_neighbor, |
uint64_t | ref_event_id = 0 |
||
) |
Resetting information about a routing table neighbor. We do not need to know whether its in the left or right routing table. Only LogicalNodeInfo is relevant, we ignore PhysicalNodeInfo. We will only reset the PhysicalNodeInfo. LogicalNodeInfo always stays the same.
RoutingInformation needs to be initialized properly beforehand.
Typical usage:
routing_table_neighbor | with the LogicalNodeInfo position which we want to reset |
ref_event_id | ID of the event which is the reason for this change |
bool minhton::RoutingInformation::resetRoutingTableNeighborChild | ( | const minhton::NodeInfo & | routing_table_neighbor_child, |
uint64_t | ref_event_id = 0 |
||
) |
Removing a routing table neighbor child by its position. This entails setting the node info object at the given position in the routing table neighbor children vector to uninitialized
routing_table_neighbor_child | position that we want to remove |
ref_event_id | ID of the event which is the reason for this change |
void minhton::RoutingInformation::setAdjacentLeft | ( | const minhton::NodeInfo & | adjacent_left, |
uint64_t | ref_event_id = 0 |
||
) |
Sets the adjacent left routing table neighbor.
Typical usage:
adjacent_left | new information about the adjacent left node, and needs to be initialized |
ref_event_id | ID of the event which is the reason for this change |
void minhton::RoutingInformation::setAdjacentRight | ( | const minhton::NodeInfo & | adjacent_right, |
uint64_t | ref_event_id = 0 |
||
) |
Sets the adjacent right routing table neighbor.
Typical usage:
adjacent_right | new information about the adjacent right node, and needs to be initialized |
ref_event_id | ID of the event which is the reason for this change |
void minhton::RoutingInformation::setChild | ( | const minhton::NodeInfo & | child, |
uint16_t | position, | ||
uint64_t | ref_event_id = 0 |
||
) |
Setting information about one new or updated child. For this we also need the position of the child.
E.g. with fanout 2 a parent has the positions 0 and 1 for the children. At 0 is the left-most child and 1 the right-most child of this parent.
We are also checking here if the logical position of the child is correct.
RoutingInformation needs to be initialized properly beforehand.
Typical usage:
child | reference to NodeInfo of the new child, and needs to be initialized |
position | position of the new child within the parent |
ref_event_id | ID of the event which is the reason for this change |
void minhton::RoutingInformation::setNodeStatus | ( | NodeStatus | status, |
uint64_t | event_id | ||
) |
Setting the status of our NodeInfo object.
status | NodeStatus that the node will be set to |
event_id | EventId which triggered this change (used only for logging) |
void minhton::RoutingInformation::setParent | ( | const minhton::NodeInfo & | parent, |
uint64_t | ref_event_id = 0 |
||
) |
Sets the parent node. The LogicalNodeInfo need to have set the correct position. RoutingInformation needs to be initialized properly beforehand.
We cannot set a parent if we are root.
Typical usage:
parent | new information about the parent node with the correct position, and needs to be initialized |
ref_event_id | ID of the event which is the reason for this change |
void minhton::RoutingInformation::setPosition | ( | const minhton::LogicalNodeInfo & | peer_position | ) |
Calling this method if our position has changed. It resets all neighbors, but we keep our PhysicalNodeInfo!
peer_position | information about our new position and fanout has to be set |
void minhton::RoutingInformation::updateNeighbor | ( | const minhton::NodeInfo & | position_to_update, |
uint64_t | ref_event_id = 0 |
||
) |
Setting the new PhysicalNodeInfo at the appropriate position. We need to have the LogicalNodeInfo position set somewhere.
If a node has multiple roles (e.g. child and adjacent), both will be updated.
Typical usage:
position_to_update | NodeInfo with the position to update |
ref_event_id | ID of the event which is the reason for this change |
void minhton::RoutingInformation::updateRoutingTableNeighbor | ( | minhton::NodeInfo | routing_table_neighbor, |
uint64_t | ref_event_id = 0 |
||
) |
Updates a routing table neighbor entry with the given PhysicalNodeInfo information.
Is being used when we receive a new information about our routing table neighbors.
Typical usage:
routing_table_neighbor | the NodeInfo with new PhysicalNodeInfo, and needs to be initialized |
ref_event_id | ID of the event which is the reason for this change |
void minhton::RoutingInformation::updateRoutingTableNeighborChild | ( | minhton::NodeInfo | routing_table_neighbor_child, |
uint64_t | ref_event_id = 0 |
||
) |
Updates a routing table neighbor child entry with the given PhysicalNodeInfo information.
Is being used when we receive a new information about our routing table neighbors children.
Typical usage:
routing_table_neighbor_child | the NodeInfo with new PhysicalNodeInfo, and needs to be initialized |
ref_event_id | ID of the event which is the reason for this change |