Class ConnectionManager
Defined in File ConnectionManager.hpp
Nested Relationships
Nested Types
Class Documentation
-
class ConnectionManager
The ConnectionManager class manages the listen and active endpoints.
The ConnectionManager class provides functionality to open and close network connections over libfabric. It offers an API to request opening listen and active endpoints. All incoming connection requests on opened listen endpoints are accepted (if possible). Listen and active connections (both sellf-initiated and ones spawned by listen endpoints) can be requested to be closed. Closing a listen endpoint closes all active connections that were opened through that listen endpoint.
In addition, this class handles all event queue (EQ) callbacks of the libfabric connection manager (CM). All callbacks are registered to the event loop that is passed to the constructor.
On the first connection request, it initializes the fabric and domain.
Public Functions
-
explicit ConnectionManager(BaseEventLoop *event_loop, NetworkConfig config)
Constructs a ConnectionManager object.
- Parameters:
event_loop – The event loop to register callbacks to
config – The network configuration
-
~ConnectionManager()
Destructor.
Unregister all callbacks from the event loop on the event loop thread before destructing the object.
-
ConnectionManager(const ConnectionManager&) = delete
-
ConnectionManager(ConnectionManager&&) = delete
-
ConnectionManager &operator=(const ConnectionManager&) = delete
-
ConnectionManager &operator=(ConnectionManager&&) = delete
-
EndPointAddress open_listen_endpoint(const EndPointAddress &address, ConnectionParameters conn_params)
Opens a listen endpoint for incoming connections.
If port 0 was specified for the listen endpoint, the system decides which port to use. Therefore, the function returns the actual address of the opened listen endpoint.
The connection parameters are used to configure active endpoints spawned from the listen endpoint.
- Throws:
ListenEndpointAlreadyExists – if the listen endpoint already exists
FailedOpenListenEndpoint – if the listen endpoint could not be opened
InvalidConnectionParameters – if the capabilities are not supported
- Parameters:
address – The address of the listen endpoint
conn_params – The connection parameters for the listen endpoint
- Returns:
The address of the opened listen endpoint
-
void open_active_endpoint(const EndPointAddress &address, const ConnectionParameters &connection_params)
Opens an active endpoint for sending and receiving data.
Opens an endpoint connecting to a remote listen endpoint. The active endpoint can be used to send and receive data. Capabilities of the endpoint are defined by the connection parameters.
- Throws:
ActiveEndpointAlreadyExists – if an active endpoint with the same address already exists
FailedOpenActiveEndpoint – if the active endpoint could not be opened
InvalidConnectionParameters – if the capabilities are not supported
- Parameters:
address – The address of the active endpoint
connection_params – The connection parameters for the endpoint
-
void close_listen_endpoint(const EndPointAddress &address)
Closes the listen endpoint for the specified address.
This function initiates closing the listen endpoint for the specified address and all active endpoints that were spawned by this listen endppint. Callbacks will be unregistered from the event loop.
The endpoint is not closed immediately but is queued to be closed by the event loop for thread synchronization purposes.
- Throws:
UnknownListenEndpoint – if the listen endpoint does not exist
- Parameters:
address – The address of the listen endpoint to close.
-
void close_active_endpoint(const EndPointAddress &address)
Closes the active endpoint for the specified address.
This function initiates closing the active endpoint for the specified address and unregistering callbacks from the event loop.
The endpoint is not closed immediately but is queued to be closed by the event loop for thread synchronization purposes.
- Throws:
UnknownActiveEndpoint – if the active endpoint does not exist
FailedCloseActiveEndpoint – if closing the active endpoint failed
- Parameters:
address – The address of the endpoint to close.
-
std::size_t get_num_available_buffers(const EndPointAddress &address)
Retrieves the number of available buffers for the specified endpoint address.
Returns the number of availble buffers for buffered sending and the number of available header slots for zero-copy sending. Returns the mininum number of available buffers since the last call to this function.
- Throws:
UnknownActiveEndpoint – if the active endpoint does not exist or has no send capabilities
- Parameters:
address – The address of the endpoint to retrieve the buffer count for
- Returns:
The number of available buffers
-
inline auto apply_to_send_endpoint_buffered(const EndPointAddress &address, const std::invocable<std::unique_ptr<SendEndpointBuffered>&> auto &func) -> decltype(func(std::declval<std::unique_ptr<SendEndpointBuffered>&>()))
Call a function on the SendEndpointBuffered object associated with the specified address.
If the backend is configured to be thread safe the function is called in a thread safe context.
- Throws:
UnknownActiveEndpoint – if the endpoint does not exist or has no buffered send capabilities
- Parameters:
address – Address of the desired endpoint
func – Function to apply
- Returns:
The return value of the function
-
inline auto apply_to_send_endpoint_zero_copy(const EndPointAddress &address, const std::invocable<std::unique_ptr<SendEndpointZeroCopy>&> auto &func) -> decltype(func(std::declval<std::unique_ptr<SendEndpointZeroCopy>&>()))
Call a function on the SendEndpointZeroCopy object associated with the specified address.
If the backend is configured to be thread safe the function is called in a thread safe context.
- Throws:
UnknownActiveEndpoint – if the endpoint does not exist or has no zero-copy send capabilities
- Parameters:
address – Address of the desired send endpoint
func – Function to apply
- Returns:
The return value of the function
-
explicit ConnectionManager(BaseEventLoop *event_loop, NetworkConfig config)