CAF 0.17.6
Loading...
Searching...
No Matches
caf::io::basp::routing_table Class Reference

Stores routing information for a single broker participating as BASP peer and provides both direct and indirect paths. More...

#include <routing_table.hpp>

Classes

struct  route
 Describes a routing path to a node. More...

Public Types

using handle_to_node_map = std::unordered_map<connection_handle, node_id>
using node_to_handle_map = std::unordered_map<node_id, connection_handle>
using node_id_set = std::unordered_set<node_id>

Public Member Functions

 routing_table (abstract_broker *parent)
optional< routelookup (const node_id &target)
 Returns a route to target or none on error.
node_id lookup_direct (const connection_handle &hdl) const
 Returns the ID of the peer connected via hdl or none if hdl is unknown.
optional< connection_handlelookup_direct (const node_id &nid) const
 Returns the handle offering a direct connection to nid or invalid_connection_handle if no direct connection to nid exists.
node_id lookup_indirect (const node_id &nid) const
 Returns the next hop that would be chosen for nid or none if there's no indirect route to nid.
void add_direct (const connection_handle &hdl, const node_id &nid)
 Adds a new direct route to the table.
void add_alternative (const connection_handle &hdl, const node_id &nid)
 When two CAF nodes connect to each other, multiple connections might spin up simultaneously until both sides agree to a single connection.
void select_alternative (const connection_handle &hdl, const node_id &nid)
 Forces lookup_direct to always resolve nid to hdl.
bool add_indirect (const node_id &hop, const node_id &dest)
 Adds a new indirect route to the table.
node_id erase_direct (const connection_handle &hdl)
 Removes a direct connection and return the node ID that became unreachable as a result of this operation.
bool erase_indirect (const node_id &dest)
 Removes any entry for indirect connection to dest and returns true if dest had an indirect route, otherwise false.
abstract_brokerparent ()
 Returns the parent broker.

Public Attributes

abstract_brokerparent_
std::mutex mtx_
handle_to_node_map direct_by_hdl_
node_to_handle_map direct_by_nid_
std::unordered_map< node_id, node_id_set > indirect_

Detailed Description

Stores routing information for a single broker participating as BASP peer and provides both direct and indirect paths.

Member Function Documentation

◆ add_alternative()

void caf::io::basp::routing_table::add_alternative ( const connection_handle & hdl,
const node_id & nid )

When two CAF nodes connect to each other, multiple connections might spin up simultaneously until both sides agree to a single connection.

Precondition
lookup_direct(hdl == nid)

◆ add_direct()

void caf::io::basp::routing_table::add_direct ( const connection_handle & hdl,
const node_id & nid )

Adds a new direct route to the table.

Precondition
hdl != invalid_connection_handle && nid != none

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