Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init_monitor for eProsima Fast DDS Discovery Server networks #103

Merged
merged 11 commits into from
Jul 21, 2021
Merged
66 changes: 58 additions & 8 deletions docs/code/StatisticsBackendTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,54 @@ void init_monitor_examples()
{
{
//CONF-INIT-MONITOR-EXAMPLE
// Init a monitor in DDS domain 0 with no listener associated
EntityId domain_monitor_id = StatisticsBackend::init_monitor(0);
// Init a monitor in DDS domain 0 with no listener associated.
EntityId domain_monitor_id =
StatisticsBackend::init_monitor(0);

// Init a monitor for a Fast DDS Discovery Server network which server is located in IPv4
// address 127.0.0.1 and port 11811. The monitor has no listener associated
EntityId disc_server_monitor_id = StatisticsBackend::init_monitor("127.0.0.1:11811");
// address 127.0.0.1 and port 11811, and that uses the default GUID prefix
// eprosima::fastdds::rtps::DEFAULT_ROS2_SERVER_GUIDPREFIX.
// The monitor has no listener associated.
EntityId disc_server_monitor_id =
StatisticsBackend::init_monitor("127.0.0.1:11811");

// Init a monitor for a Fast DDS Discovery Server network which serveris located in IPv4
// address 127.0.0.1 and port 11811, and that uses the GUID prefix
// "44.53.01.5f.45.50.52.4f.53.49.4d.41".
// The monitor has no listener associated.
EntityId disc_server_prefix_monitor_id =
StatisticsBackend::init_monitor("44.53.01.5f.45.50.52.4f.53.49.4d.41", "127.0.0.1:11811");
//!--
static_cast<void>(domain_monitor_id);
static_cast<void>(disc_server_monitor_id);
static_cast<void>(disc_server_prefix_monitor_id);
}
{
//CONF-INIT-MONITOR-LISTENER-EXAMPLE
// Init a monitor in DDS domain 0 with a custom listener
CustomDomainListener domain_listener;
EntityId domain_monitor_id = StatisticsBackend::init_monitor(0, &domain_listener);

// Init a monitor in DDS domain 0 with a custom listener.
EntityId domain_monitor_id =
StatisticsBackend::init_monitor(0, &domain_listener);

// Init a monitor for a Fast DDS Discovery Server network which server is located in IPv4
// address 127.0.0.1 and port 11811, and that uses the default GUID prefix
// eprosima::fastdds::rtps::DEFAULT_ROS2_SERVER_GUIDPREFIX.
// The monitor uses a custom listener.
EntityId disc_server_monitor_id =
StatisticsBackend::init_monitor("127.0.0.1:11811", &domain_listener);

// Init a monitor for a Fast DDS Discovery Server network which serveris located in IPv4
// address 127.0.0.1 and port 11811, and that uses the GUID prefix
// "44.53.01.5f.45.50.52.4f.53.49.4d.41".
// The monitor uses a custom listener.
EntityId disc_server_prefix_monitor_id =
StatisticsBackend::init_monitor("44.53.01.5f.45.50.52.4f.53.49.4d.41", "127.0.0.1:11811",
&domain_listener);
//!--
static_cast<void>(domain_monitor_id);
static_cast<void>(disc_server_monitor_id);
static_cast<void>(disc_server_prefix_monitor_id);
}
{
//CONF-INIT-MONITOR-MASKS-EXAMPLE
Expand All @@ -64,11 +95,30 @@ void init_monitor_examples()
// Only get notificiations about network latency or subscription throughput
DataKindMask datakind_mask = DataKind::NETWORK_LATENCY | DataKind::SUBSCRIPTION_THROUGHPUT;

// Init a monitor in DDS domain 0 with a custom listener, a CallbackMask, and a DataKindMask
CustomDomainListener domain_listener;
EntityId domain_monitor_id = StatisticsBackend::init_monitor(0, &domain_listener, callback_mask, datakind_mask);

// Init a monitor in DDS domain 0 with a custom listener, a CallbackMask, and a DataKindMask
EntityId domain_monitor_id =
StatisticsBackend::init_monitor(0, &domain_listener, callback_mask, datakind_mask);

// Init a monitor for a Fast DDS Discovery Server network which server is located in IPv4
// address 127.0.0.1 and port 11811, and that uses the default GUID prefix
// eprosima::fastdds::rtps::DEFAULT_ROS2_SERVER_GUIDPREFIX.
// The monitor uses a custom listener, a CallbackMask, and a DataKindMask.
EntityId disc_server_monitor_id =
StatisticsBackend::init_monitor("127.0.0.1:11811", &domain_listener, callback_mask, datakind_mask);

// Init a monitor for a Fast DDS Discovery Server network which serveris located in IPv4
// address 127.0.0.1 and port 11811, and that uses the GUID prefix
// "44.53.01.5f.45.50.52.4f.53.49.4d.41".
// The monitor uses a custom listener, a CallbackMask, and a DataKindMask.
EntityId disc_server_prefix_monitor_id =
StatisticsBackend::init_monitor("44.53.01.5f.45.50.52.4f.53.49.4d.41", "127.0.0.1:11811",
&domain_listener, callback_mask, datakind_mask);
//!--
static_cast<void>(domain_monitor_id);
static_cast<void>(disc_server_monitor_id);
static_cast<void>(disc_server_prefix_monitor_id);
}
}

Expand Down
6 changes: 1 addition & 5 deletions docs/rst/statistics_backend/init_monitor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Initializing a monitor on a certain Domain ID makes *eProsima Fast DDS Statistic
start monitoring the statistics data and entity discoveries on that domain.
No statistics data will be gathered unless there is a monitor initialized in the required domain.

|StatisticsBackend-api| provides two overloads of |init_monitor-api| that can be used to start a monitorization on a
|StatisticsBackend-api| provides three overloads of |init_monitor-api| that can be used to start a monitorization on a
DDS domain or a *Fast DDS* Discovery Server network.

.. literalinclude:: /code/StatisticsBackendTests.cpp
Expand All @@ -18,10 +18,6 @@ DDS domain or a *Fast DDS* Discovery Server network.
:end-before: //!
:dedent: 8

.. warning::
Initializing a monitor for a discovery server configuration is currently not supported.
It will be implemented on a future release of *Fast DDS Statistics Backend*.

Furthermore, it is possible to initialize a monitor with a custom |DomainListener-api|.
Please refer to :ref:`listeners_domain_listener` for more information about the ``DomainListener`` and its
functionality.
Expand Down
45 changes: 41 additions & 4 deletions include/fastdds_statistics_backend/StatisticsBackend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,56 @@ class FASTDDS_STATISTICS_BACKEND_DllAPI StatisticsBackend
DataKindMask data_mask = DataKindMask::none());

/**
* @brief Starts monitoring the domain corresponding to a server.
* @brief Starts monitoring the network corresponding to a server.
*
* This function creates a new statistics DomainParticipant that starts monitoring
* the domain of the server with the given locator.
* the network of the server with the given locators.
* The server \c GuidPrefix_t is set to the default one: \c eprosima::fastdds::rtps::DEFAULT_ROS2_SERVER_GUIDPREFIX.
* If any other server is to be used, call the overload method that receives the \c GuidPrefix_t as parameter.
*
* The format to specify a locator is: <tt>kind:[IP]:port</tt>, where:
* * \b kind is one of { \c UDPv4, \c TCPv4, \c UDPv6, \c TCPv4 }
* * \b IP is the IP address
* * \b port is the IP port
* Note that \c SHM locators are not supported. For any server configured with shared memory locators,
* initialize the monitor using only the non shared memory locators.
*
* @param discovery_server_locators The locator list of the server whose network is to be monitored,
* formatted as a semicolon separated list of locators.
* @param domain_listener Listener with the callback to use to inform of events.
* @param callback_mask Mask of the callbacks. Only the events that have the mask bit set will be informed.
* @param data_mask Mask of the data types that will be monitored.
* @return The ID of the created statistics Domain.
*/
static EntityId init_monitor(
std::string discovery_server_locators,
DomainListener* domain_listener = nullptr,
CallbackMask callback_mask = CallbackMask::all(),
DataKindMask data_mask = DataKindMask::none());

/**
* @brief Starts monitoring the network corresponding to a server.
*
* @param discovery_server_locators The locator of the server whose domain is to be monitored,
* formatted as "IPV4address:port".
* This function creates a new statistics DomainParticipant that starts monitoring
* the network of the server with the given \c GuidPrefix_t and with the given locators.
*
* The format to specify a locator is: <tt>kind:[IP]:port</tt>, where:
* * \b kind is one of { \c UDPv4, \c TCPv4, \c UDPv6, \c TCPv4 }
* * \b IP is the IP address
* * \b port is the IP port
* Note that \c SHM locators are not supported. For any server configured with shared memory locators,
* initialize the monitor using only the non shared memory locators.
*
* @param discovery_server_guid_prefix Server \c GuidPrefix_t to be monitored.
* @param discovery_server_locators The locator list of the server whose network is to be monitored,
* formatted as a semicolon separated list of locators.
* @param domain_listener Listener with the callback to use to inform of events.
* @param callback_mask Mask of the callbacks. Only the events that have the mask bit set will be informed.
* @param data_mask Mask of the data types that will be monitored.
* @return The ID of the created statistics Domain.
*/
static EntityId init_monitor(
std::string discovery_server_guid_prefix,
std::string discovery_server_locators,
DomainListener* domain_listener = nullptr,
CallbackMask callback_mask = CallbackMask::all(),
Expand Down
Loading