CAF  0.17.6
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
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. More...
 
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. More...
 
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. More...
 
void add_direct (const connection_handle &hdl, const node_id &nid)
 Adds a new direct route to the table. More...
 
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. More...
 
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. More...
 
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. More...
 
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

◆ erase_direct()

node_id caf::io::basp::routing_table::erase_direct ( const connection_handle hdl)

Removes a direct connection and return the node ID that became unreachable as a result of this operation.

◆ erase_indirect()

bool caf::io::basp::routing_table::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.

◆ lookup_direct() [1/2]

node_id caf::io::basp::routing_table::lookup_direct ( const connection_handle hdl) const

Returns the ID of the peer connected via hdl or none if hdl is unknown.

◆ lookup_direct() [2/2]

optional<connection_handle> caf::io::basp::routing_table::lookup_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.

◆ lookup_indirect()

node_id caf::io::basp::routing_table::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.


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