libcaf  0.14.4
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 <basp.hpp>

Classes

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

Public Types

using erase_callback = callback< const node_id & >
 Describes a function object for erase operations that is called for each indirectly lost connection. More...
 
using node_id_set = std::unordered_set< node_id >
 
using indirect_entries = std::unordered_map< node_id, node_id_set >
 

Public Member Functions

 routing_table (abstract_broker *parent)
 
maybe< 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 invalid_node_id if hdl is unknown. More...
 
connection_handle 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. More...
 
node_id lookup_indirect (const node_id &nid) const
 Returns the next hop that would be chosen for nid or invalid_node_id if there's no indirect route to nid. More...
 
void flush (const route &r)
 Flush output buffer for r.
 
void add_direct (const connection_handle &hdl, const node_id &dest)
 Adds a new direct route to the table. More...
 
bool add_indirect (const node_id &hop, const node_id &dest)
 Adds a new indirect route to the table.
 
void blacklist (const node_id &hop, const node_id &dest)
 Blacklist the route to dest via hop.
 
void erase_direct (const connection_handle &hdl, erase_callback &cb)
 Removes a direct connection and calls cb for any node that became unreachable as a result of this operation, including the node that is assigned as direct path for hdl. 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...
 
bool reachable (const node_id &dest)
 Queries whether dest is reachable.
 
size_t erase (const node_id &dest, erase_callback &cb)
 Removes all direct and indirect routes to dest and calls cb for any node that became unreachable as a result of this operation, including dest. More...
 
template<class Map , class Fallback >
Map::mapped_type get_opt (const Map &m, const typename Map::key_type &k, Fallback &&x) const
 

Public Attributes

abstract_brokerparent_
 
std::unordered_map< connection_handle, node_iddirect_by_hdl_
 
std::unordered_map< node_id, connection_handledirect_by_nid_
 
indirect_entries indirect_
 
indirect_entries blacklist_
 

Detailed Description

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

Member Typedef Documentation

Describes a function object for erase operations that is called for each indirectly lost connection.

Member Function Documentation

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

Adds a new direct route to the table.

Precondition
hdl != invalid_connection_handle && nid != invalid_node_id
size_t caf::io::basp::routing_table::erase ( const node_id dest,
erase_callback cb 
)

Removes all direct and indirect routes to dest and calls cb for any node that became unreachable as a result of this operation, including dest.

Returns
the number of removed routes (direct and indirect)
void caf::io::basp::routing_table::erase_direct ( const connection_handle hdl,
erase_callback cb 
)

Removes a direct connection and calls cb for any node that became unreachable as a result of this operation, including the node that is assigned as direct path for hdl.

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.

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

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

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.

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 invalid_node_id if there's no indirect route to nid.


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