7 #include "../derecho_type_definitions.hpp" 19 const std::pair<ip_addr_t, uint16_t>& other_ip_and_port);
21 const std::map<
node_id_t, std::pair<ip_addr_t, uint16_t>>& ip_addrs_and_ports);
31 const std::map<
node_id_t, std::pair<ip_addr_t, uint16_t>> ip_addrs_and_ports);
52 bool write_all(
char const* buffer,
size_t size);
75 const std::pair<ip_addr_t, uint16_t>& new_ip_addr_and_port);
95 std::lock_guard<std::mutex> lock(sockets_mutex);
96 const auto it = sockets.find(node_id);
97 assert(it != sockets.end());
98 return it->second.exchange(local, remote);
117 void filter_to(
const std::vector<node_id_t>& live_nodes_list);
bool contains_node(node_id_t node_id)
Checks whether this connection manager currently has a socket connected to the node with the specifie...
bool add_node(node_id_t new_id, const std::pair< ip_addr_t, uint16_t > &new_ip_addr_and_port)
Adds a TCP connection to a new node.
A little helper class that wraps together a reference and a lock on a related mutex.
bool write_all(char const *buffer, size_t size)
Writes size bytes from a buffer to all the other nodes currently connected, in ascending order of nod...
bool exchange(node_id_t node_id, T local, T &remote)
std::unique_ptr< connection_listener > conn_listener
bool read(node_id_t node_id, char *buffer, size_t size)
Receives size bytes from the node with ID node_id, over the TCP socket connected to that node...
tcp_connections(node_id_t my_id, const std::map< node_id_t, std::pair< ip_addr_t, uint16_t >> ip_addrs_and_ports)
Creates a TCP connection manager for a set of connections to all of the initial set of addresses...
void establish_node_connections(const std::map< node_id_t, std::pair< ip_addr_t, uint16_t >> &ip_addrs_and_ports)
derecho::LockedReference< std::unique_lock< std::mutex >, socket > get_socket(node_id_t node_id)
Gets a locked reference to the TCP socket connected to a particular node.
bool write(node_id_t node_id, char const *buffer, size_t size)
Writes size bytes from a buffer to the node with ID node_id, using the TCP socket connected to that n...
bool delete_node(node_id_t remove_id)
Removes a node from the managed set of TCP connections, closing the socket connected to it...
void filter_to(const std::vector< node_id_t > &live_nodes_list)
Compares the set of TCP connections to a list of known live nodes and removes any connections to node...
uint32_t node_id_t
Type alias for Node IDs in a Derecho group.
std::map< node_id_t, socket > sockets
int32_t probe_all()
Checks all of the TCP connections managed by this object for new incoming data, and returns the ID of...
bool add_connection(const node_id_t other_id, const std::pair< ip_addr_t, uint16_t > &other_ip_and_port)