Class ConnectionManager

Nested Relationships

Nested Types

Inheritance Relationships

Base Type

  • public std::enable_shared_from_this< ConnectionManager >

Class Documentation

class ConnectionManager : public std::enable_shared_from_this<ConnectionManager>

The ConnectionManager class manages the listen, receive and send connections.

The ConnectionManager class provides functionality to open and close network connections over libfabric. It offers an API to request opening listen and send sockets. All incoming connection requests on opened listen sockets are accepted (if possible). Listen and send connections can be requested to be closed. Closing a listen connection closes all receive connections that were opened through that listen connection.

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 send and listen domains.

This object should be managed by a shared pointer to make sure its lifetime is correctly controlled when callback capturing this are registered to the event loop.

Public Functions

explicit ConnectionManager(BaseEventLoop *event_loop, NetworkConfig config)

Constructs a ConnectionManager object.

Do not call directly, use create() instead.

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
void init()

Initializes the ConnectionManager object.

Creates the signal to handle close requests which needs to be done after construction.

EndPointAddress open_listen_endpoint(const EndPointAddress &address, ConnectionParametersRecv conn_params)

Opens a listen endpoint for incoming connections.

If port 0 was specified for the listen socket, 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 receive sockets spawned from the listen socket.

Throws:
  • ListenEndpointAlreadyExists – if the listen endpoint already exists

  • FailedOpenListenEndpoint – if the listen endpoint could not be opened

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_send_endpoint_buffered(const EndPointAddress &address, ConnectionParameters conn_params)

Opens a send endpoint for sending buffered data.

Throws:
  • SendEndpointAlreadyExists – if the send endpoint already exists

  • FailedOpenSendEndpoint – if the send endpoint could not be opened

Parameters:
  • address – The address of the remote peer

  • conn_params – The connection parameters specifying the send buffers

void open_send_endpoint_zero_copy(const EndPointAddress &address, ConnectionParameters conn_params)

Opens a send endpoint for sending data in zero copy mode.

Throws:
  • SendEndpointAlreadyExists – if the send endpoint already exists

  • FailedOpenSendEndpoint – if the send endpoint could not be opened

Parameters:
  • address – The address of the remote peer

  • conn_params – The connection parameters specifying the send buffer

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 receive sockets that were spawned by this listen socket. 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_send_endpoint(const EndPointAddress &address)

Closes the send endpoint for the specified address.

This function initiates closing the send 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:
  • UnknownSendEndpoint – if the send endpoint does not exist

  • FailedCloseSendEndpoint – if closing the send socket 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:

UnknownSendEndpoint – if the send endpoint does not exist

Parameters:

address – The address of the endpoint to retrieve the buffer count for

Returns:

The number of available buffers

inline auto apply_to_send_socket_buffered(const EndPointAddress &address, const std::invocable<SendSocketBuffered&> auto &func) -> decltype(func(std::declval<SendSocketBuffered&>()))

Call a function on the SendSocketBuffered 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:

UnknownSendEndpoint – if the send endpoint does not exist

Parameters:
  • address – Address of the desired send socket

  • func – Function to apply

Returns:

The return value of the function

inline auto apply_to_send_socket_zero_copy(const EndPointAddress &address, const std::invocable<SendSocketZeroCopy&> auto &func) -> decltype(func(std::declval<SendSocketZeroCopy&>()))

Call a function on the SendSocketZeroCopy 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:

UnknownSendEndpoint – if the send endpoint does not exist

Parameters:
  • address – Address of the desired send socket

  • func – Function to apply

Returns:

The return value of the function

Public Static Functions

static std::shared_ptr<ConnectionManager> create(BaseEventLoop *event_loop, NetworkConfig config)

Creates a ConnectionManager object.

Constructs and initializes a ConnectionManager object.

Parameters:
  • event_loop – The event loop to register callbacks to

  • config – The network configuration

Returns:

A shared pointer to the ConnectionManager object