Skip to content

Commit

Permalink
Added new status attribute for entities
Browse files Browse the repository at this point in the history
Signed-off-by: Irene Bandera <[email protected]>
  • Loading branch information
irenebm committed Sep 4, 2023
1 parent 541dff3 commit e5c8bf4
Show file tree
Hide file tree
Showing 44 changed files with 502 additions and 58 deletions.
11 changes: 11 additions & 0 deletions docs/code/StatisticsBackendTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,17 @@ void get_type_example()
}
}

void get_status_example()
{
{
EntityId entity_id;
//CONF-GET-STATUS-EXAMPLE
EntityStatus status = StatisticsBackend::get_status(entity_id);
//!--
static_cast<void>(status);
}
}

void set_alias_example()
{
{
Expand Down
1 change: 1 addition & 0 deletions docs/code/datareader_info_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"name": "datareader_name",
"alias": "datareader_alias",
"alive": false,
"status": 0,
"guid": "01.0f.22.cd.59.64.04.00.05.00.00.00|00.00.01.04",
"qos":
{
Expand Down
1 change: 1 addition & 0 deletions docs/code/datawriter_info_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"name": "datawriter_name",
"alias": "datawriter_alias",
"alive": true,
"status": 0,
"guid": "01.0f.22.cd.59.64.04.00.02.00.00.00|00.00.01.03",
"qos":
{
Expand Down
3 changes: 2 additions & 1 deletion docs/code/domain_info_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"kind": "domain",
"name": "0",
"alias": "domain_alias",
"alive": true
"alive": true,
"status": 0
}
12 changes: 12 additions & 0 deletions docs/code/graph_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,23 @@
"name": "example_host",
"alias": "example_host_alias",
"alive": true,
"status": 0,
"users":
[
{
"entity_id": "2",
"name": "example_user",
"alias": "example_user_alias",
"alive": true,
"status": 0,
"processes":
[
{
"entity_id": "3",
"name": "example_process_1",
"alias": "example_process_1_alias",
"alive": true,
"status": 0,
"pid": "9564",
"participants":
[
Expand All @@ -31,6 +34,7 @@
"name": "example_process_2",
"alias": "example_process_2_alias",
"alive": true,
"status": 0,
"pid": "9565",
"participants":
[
Expand All @@ -49,6 +53,7 @@
"name": "127.0.0.1:7412",
"alias": "localhost_1",
"alive": true,
"status": 0,
"datareaders":
[
],
Expand All @@ -62,6 +67,7 @@
"name": "127.0.0.1:7414",
"alias": "localhost_2",
"alive": true,
"status": 0,
"datareaders":
[
"10"
Expand All @@ -78,13 +84,15 @@
"name": "0",
"alias": "domain_0_alias",
"alive": true,
"status": 0,
"participants":
[
{
"entity_id": "4",
"name": "participant_1",
"alias": "participant_1_alias",
"alive": true,
"status": 0,
"guid": "01.0f.22.cd.59.64.04.00.02.00.00.00|00.00.01.c1",
"process": "3",
"datareaders":
Expand All @@ -97,6 +105,7 @@
"name": "datawriter_1",
"alias": "datawriter_1_alias",
"alive": true,
"status": 0,
"guid": "01.0f.22.cd.59.64.04.00.02.00.00.00|00.00.01.03",
"topic": "5",
"locators":
Expand All @@ -111,6 +120,7 @@
"name": "participant_2",
"alias": "participant_2_alias",
"alive": false,
"status": 0,
"guid": "01.0f.22.cd.59.64.04.00.05.00.00.00|00.00.01.c1",
"process": "8",
"datareaders":
Expand All @@ -120,6 +130,7 @@
"name": "datareader_1",
"alias": "datareader_1_alias",
"alive": false,
"status": 0,
"guid": "01.0f.22.cd.59.64.04.00.05.00.00.00|00.00.01.04",
"topic": "5",
"locators":
Expand All @@ -140,6 +151,7 @@
"name": "example_topic",
"alias": "example_topic_alias",
"alive": true,
"status": 0,
"data_type": "example_data_type",
"datareaders":
[
Expand Down
3 changes: 2 additions & 1 deletion docs/code/host_info_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"kind": "host",
"name": "host_name",
"alias": "host_alias",
"alive": true
"alive": true,
"status": 0
}
1 change: 1 addition & 0 deletions docs/code/participant_info_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"name": "participant_name",
"alias": "participant_alias",
"alive": true,
"status": 0,
"guid": "01.0f.22.cd.59.64.04.00.05.00.00.00|00.00.01.c1",
"qos": {
"available_builtin_endpoints": 3135,
Expand Down
1 change: 1 addition & 0 deletions docs/code/process_info_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"name": "process_name",
"alias": "process_alias",
"alive": true,
"status": 0,
"pid": "9564"
}
1 change: 1 addition & 0 deletions docs/code/topic_info_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"name": "topic_name",
"alias": "topic_alias",
"alive": true,
"status": 0,
"data_type": "example_data_type"
}
3 changes: 2 additions & 1 deletion docs/code/user_info_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"kind": "user",
"name": "user_name",
"alias": "user_alias",
"alive": true
"alive": true,
"status": 0,
}
10 changes: 10 additions & 0 deletions docs/rst/api-reference/types/entitystatus.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

.. _api_types_entitystatus:

.. rst-class:: api-ref

EntityStatus
------------

.. doxygenenum:: eprosima::statistics_backend::EntityStatus
:project: fastdds_statistics_backend
1 change: 1 addition & 0 deletions docs/rst/api-reference/types/types_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Types
/rst/api-reference/types/domainid
/rst/api-reference/types/entityid
/rst/api-reference/types/entitykind
/rst/api-reference/types/entitystatus
/rst/api-reference/types/graph
/rst/api-reference/types/info
/rst/api-reference/types/statistickind
Expand Down
6 changes: 6 additions & 0 deletions docs/rst/exports/alias.include
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
.. |reset-api| replace:: :cpp:func:`reset()<eprosima::statistics_backend::StatisticsBackend::reset>`
.. |set_domain_listener-api| replace:: :cpp:func:`set_domain_listener()<eprosima::statistics_backend::StatisticsBackend::set_domain_listener>`
.. |get_type-api| replace:: :cpp:func:`get_type()<eprosima::statistics_backend::StatisticsBackend::get_type>`
.. |get_status-api| replace:: :cpp:func:`get_status()<eprosima::statistics_backend::StatisticsBackend::get_status>`
.. |set_alias-api| replace:: :cpp:func:`set_alias()<eprosima::statistics_backend::StatisticsBackend::set_alias>`
.. |clear_statistics_data-api| replace:: :cpp:func:`clear_statistics_data()<eprosima::statistics_backend::StatisticsBackend::clear_statistics_data>`
.. |clear_inactive_entities-api| replace:: :cpp:func:`clear_inactive_entities()<eprosima::statistics_backend::StatisticsBackend::clear_inactive_entities>`
Expand Down Expand Up @@ -82,6 +83,11 @@
.. |DATAREADER-api| replace:: :cpp:enumerator:`DATAREADER<eprosima::statistics_backend::EntityKind::DATAREADER>`
.. |LOCATOR-api| replace:: :cpp:enumerator:`LOCATOR<eprosima::statistics_backend::EntityKind::LOCATOR>`

.. |EntityStatus-api| replace:: :cpp:type:`EntityStatus<eprosima::statistics_backend::EntityStatus>`
.. |OK-api| replace:: :cpp:enumerator:`OK<eprosima::statistics_backend::EntityStatus::OK>`
.. |WARNING-api| replace:: :cpp:enumerator:`WARNING<eprosima::statistics_backend::EntityStatus::WARNING>`
.. |ERROR-api| replace:: :cpp:enumerator:`ERROR<eprosima::statistics_backend::EntityStatus::ERROR>`

.. |BadParameter-api| replace:: :cpp:type:`BadParameter<eprosima::statistics_backend::BadParameter>`
.. |Error-api| replace:: :cpp:type:`Error<eprosima::statistics_backend::Error>`
.. |PreconditionNotMet-api| replace:: :cpp:type:`PreconditionNotMet<eprosima::statistics_backend::PreconditionNotMet>`
12 changes: 12 additions & 0 deletions docs/rst/notes/forthcoming_version.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.. add orphan tag when new info added to this file
.. :orphan:
###################
Forthcoming Version
###################

Next release will include the following **API extensions**:

* `StatisticsBackend::get_status` returns the entity status of a given id.
* Added `status` attribute for entities.
3 changes: 3 additions & 0 deletions docs/rst/notes/notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
Release Notes
#############

.. TODO uncomment when there are forthcoming notes
.. include:: forthcoming_version.rst

Version 0.11.0
##############

Expand Down
1 change: 1 addition & 0 deletions docs/rst/spelling_wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ metatraffic
monitorization
monitorizations
namespace
Ok
ostream
OStream
preprocessed
Expand Down
16 changes: 16 additions & 0 deletions docs/rst/statistics_backend/get_status.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.. include:: ../exports/alias.include

.. _statistics_backend_get_status:

Get entity status
-----------------

It is also possible to retrieve the |EntityStatus-api| of an entity given its |EntityId-api|:

.. literalinclude:: /code/StatisticsBackendTests.cpp
:language: c++
:start-after: //CONF-GET-STATUS-EXAMPLE
:end-before: //!
:dedent: 8

|get_status-api| throws |BadParameter-api| if there is no entity with the given ID.
1 change: 1 addition & 0 deletions docs/rst/statistics_backend/statistics_backend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ contain a set of callbacks that the application implements.
/rst/statistics_backend/get_info
/rst/statistics_backend/get_entities
/rst/statistics_backend/get_data
/rst/statistics_backend/get_status
/rst/statistics_backend/get_type
/rst/statistics_backend/set_alias
/rst/statistics_backend/is_active
Expand Down
15 changes: 15 additions & 0 deletions docs/rst/types/entity_status.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.. include:: ../exports/alias.include

.. _types_entity_status:

EntityStatus
============

The *eProsima Fast DDS Statistics Backend* keeps track of the entities status.
The following list shows the possible status values along with their corresponding descriptions.

- |OK-api|: The entity is functioning optimally and there are no issues to report.
- |WARNING-api|: The entity is operating with some warnings or minor issues.
Although it's still functional, some attention may be required.
- |ERROR-api|: The entity has encountered critical errors and its normal operation is disrupted.
Immediate action is necessary to resolve the problem.
1 change: 1 addition & 0 deletions docs/rst/types/types_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ Types
/rst/types/statistic_kind
/rst/types/entity_kind
/rst/types/entity_id
/rst/types/entity_status
/rst/types/json_tags
/rst/types/database_dumps
10 changes: 10 additions & 0 deletions include/fastdds_statistics_backend/StatisticsBackend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,16 @@ class FASTDDS_STATISTICS_BACKEND_DllAPI StatisticsBackend
static EntityKind get_type(
EntityId entity_id);

/**
* @brief Returns the entity status of a given id.
*
* @param entity_id The ID of the entity whose status is requested.
* @throws eprosima::statistics_backend::BadParameter if there is no entity with the given ID.
* @return EntityStatus of \c entity_id.
*/
static EntityStatus get_status(
EntityId entity_id);

/**
* @brief Get the meta information of a given entity.
*
Expand Down
2 changes: 2 additions & 0 deletions include/fastdds_statistics_backend/types/JSONTags.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ constexpr const char* LOCATOR_ENTITY_TAG = "locator";
constexpr const char* ID_INFO_TAG = "id";
//! Key tag for the EntityKind of an entity
constexpr const char* KIND_INFO_TAG = "kind";
//! Key tag for the EntityStatus of an entity
constexpr const char* STATUS_INFO_TAG = "status";
//! Key tag for name of an entity
constexpr const char* NAME_INFO_TAG = "name";
//! Key tag for alias of an entity
Expand Down
15 changes: 15 additions & 0 deletions include/fastdds_statistics_backend/types/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,21 @@ enum class EntityKind
LOCATOR,
};

/**
* Indicates the Status of an Entity in Statistics Backend structure
*/
enum class EntityStatus
{
/// Ok entity status
OK,

/// Warning entity status
WARNING,

/// Error entity status
ERROR,
};

/**
* Indicates the Type of Data stored by the Backend
*
Expand Down
7 changes: 7 additions & 0 deletions src/cpp/StatisticsBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,12 @@ EntityKind StatisticsBackend::get_type(
return StatisticsBackendData::get_instance()->database_->get_entity_kind(entity_id);
}

EntityStatus StatisticsBackend::get_status(
EntityId entity_id)
{
return StatisticsBackendData::get_instance()->database_->get_entity_status(entity_id);
}

Info StatisticsBackend::get_info(
EntityId entity_id)
{
Expand All @@ -506,6 +512,7 @@ Info StatisticsBackend::get_info(
info[ALIAS_INFO_TAG] = entity->alias;
info[ALIVE_INFO_TAG] = entity->active;
info[METATRAFFIC_INFO_TAG] = entity->metatraffic;
info[STATUS_INFO_TAG] = entity->status;

switch (entity->kind)
{
Expand Down
Loading

0 comments on commit e5c8bf4

Please sign in to comment.