From e5c8bf43a4a1f35ce6aa511075db382e402da4f1 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Fri, 18 Aug 2023 10:01:39 +0200 Subject: [PATCH] Added new status attribute for entities Signed-off-by: Irene Bandera --- docs/code/StatisticsBackendTests.cpp | 11 +++ docs/code/datareader_info_example.json | 1 + docs/code/datawriter_info_example.json | 1 + docs/code/domain_info_example.json | 3 +- docs/code/graph_example.json | 12 +++ docs/code/host_info_example.json | 3 +- docs/code/participant_info_example.json | 1 + docs/code/process_info_example.json | 1 + docs/code/topic_info_example.json | 1 + docs/code/user_info_example.json | 3 +- docs/rst/api-reference/types/entitystatus.rst | 10 +++ docs/rst/api-reference/types/types_index.rst | 1 + docs/rst/exports/alias.include | 6 ++ docs/rst/notes/forthcoming_version.rst | 12 +++ docs/rst/notes/notes.rst | 3 + docs/rst/spelling_wordlist.txt | 1 + docs/rst/statistics_backend/get_status.rst | 16 ++++ .../statistics_backend/statistics_backend.rst | 1 + docs/rst/types/entity_status.rst | 15 ++++ docs/rst/types/types_index.rst | 1 + .../StatisticsBackend.hpp | 10 +++ .../types/JSONTags.h | 2 + .../types/types.hpp | 15 ++++ src/cpp/StatisticsBackend.cpp | 7 ++ src/cpp/database/database.cpp | 15 ++++ src/cpp/database/database.hpp | 10 +++ src/cpp/database/database_queue.cpp | 5 +- src/cpp/database/database_queue.hpp | 3 + src/cpp/database/entities.cpp | 5 +- src/cpp/database/entities.hpp | 55 ++++++++----- .../Resources/alternative_complex_dump.json | 36 ++++++-- ...ernative_complex_dump_erased_domain_2.json | 29 +++++-- test/unittest/Resources/complex_dump.json | 39 +++++++-- .../complex_dump_erased_domain_1.json | 32 ++++++-- test/unittest/Resources/database_dump.json | 26 +++++- .../Resources/empty_entities_dump.json | 9 ++ ...empty_entities_dump_unlinked_entities.json | 9 ++ test/unittest/Resources/old_complex_dump.json | 39 +++++++-- test/unittest/Resources/simple_dump.json | 9 ++ ...mple_dump_no_process_participant_link.json | 9 ++ ...rocess_participant_link_erased_domain.json | 4 + .../unittest/StatisticsBackend/CMakeLists.txt | 1 + .../StatisticsBackendTests.cpp | 82 +++++++++++++++++++ versions.md | 6 ++ 44 files changed, 502 insertions(+), 58 deletions(-) create mode 100644 docs/rst/api-reference/types/entitystatus.rst create mode 100644 docs/rst/notes/forthcoming_version.rst create mode 100644 docs/rst/statistics_backend/get_status.rst create mode 100644 docs/rst/types/entity_status.rst diff --git a/docs/code/StatisticsBackendTests.cpp b/docs/code/StatisticsBackendTests.cpp index 0f2648657..1f1110d59 100644 --- a/docs/code/StatisticsBackendTests.cpp +++ b/docs/code/StatisticsBackendTests.cpp @@ -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(status); + } +} + void set_alias_example() { { diff --git a/docs/code/datareader_info_example.json b/docs/code/datareader_info_example.json index 24aaba9bf..4313f726a 100644 --- a/docs/code/datareader_info_example.json +++ b/docs/code/datareader_info_example.json @@ -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": { diff --git a/docs/code/datawriter_info_example.json b/docs/code/datawriter_info_example.json index 8e6f7abb6..fa4c862f4 100644 --- a/docs/code/datawriter_info_example.json +++ b/docs/code/datawriter_info_example.json @@ -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": { diff --git a/docs/code/domain_info_example.json b/docs/code/domain_info_example.json index 26f569bff..bf67525c9 100644 --- a/docs/code/domain_info_example.json +++ b/docs/code/domain_info_example.json @@ -3,5 +3,6 @@ "kind": "domain", "name": "0", "alias": "domain_alias", - "alive": true + "alive": true, + "status": 0 } diff --git a/docs/code/graph_example.json b/docs/code/graph_example.json index 932f0079b..f1ecb8438 100644 --- a/docs/code/graph_example.json +++ b/docs/code/graph_example.json @@ -6,6 +6,7 @@ "name": "example_host", "alias": "example_host_alias", "alive": true, + "status": 0, "users": [ { @@ -13,6 +14,7 @@ "name": "example_user", "alias": "example_user_alias", "alive": true, + "status": 0, "processes": [ { @@ -20,6 +22,7 @@ "name": "example_process_1", "alias": "example_process_1_alias", "alive": true, + "status": 0, "pid": "9564", "participants": [ @@ -31,6 +34,7 @@ "name": "example_process_2", "alias": "example_process_2_alias", "alive": true, + "status": 0, "pid": "9565", "participants": [ @@ -49,6 +53,7 @@ "name": "127.0.0.1:7412", "alias": "localhost_1", "alive": true, + "status": 0, "datareaders": [ ], @@ -62,6 +67,7 @@ "name": "127.0.0.1:7414", "alias": "localhost_2", "alive": true, + "status": 0, "datareaders": [ "10" @@ -78,6 +84,7 @@ "name": "0", "alias": "domain_0_alias", "alive": true, + "status": 0, "participants": [ { @@ -85,6 +92,7 @@ "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": @@ -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": @@ -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": @@ -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": @@ -140,6 +151,7 @@ "name": "example_topic", "alias": "example_topic_alias", "alive": true, + "status": 0, "data_type": "example_data_type", "datareaders": [ diff --git a/docs/code/host_info_example.json b/docs/code/host_info_example.json index f25b1b525..3691cb35a 100644 --- a/docs/code/host_info_example.json +++ b/docs/code/host_info_example.json @@ -3,5 +3,6 @@ "kind": "host", "name": "host_name", "alias": "host_alias", - "alive": true + "alive": true, + "status": 0 } diff --git a/docs/code/participant_info_example.json b/docs/code/participant_info_example.json index 69dcbef14..280c4e37f 100644 --- a/docs/code/participant_info_example.json +++ b/docs/code/participant_info_example.json @@ -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, diff --git a/docs/code/process_info_example.json b/docs/code/process_info_example.json index 62c403e84..07a88907e 100644 --- a/docs/code/process_info_example.json +++ b/docs/code/process_info_example.json @@ -4,5 +4,6 @@ "name": "process_name", "alias": "process_alias", "alive": true, + "status": 0, "pid": "9564" } diff --git a/docs/code/topic_info_example.json b/docs/code/topic_info_example.json index f94c965e7..b27fc5381 100644 --- a/docs/code/topic_info_example.json +++ b/docs/code/topic_info_example.json @@ -4,5 +4,6 @@ "name": "topic_name", "alias": "topic_alias", "alive": true, + "status": 0, "data_type": "example_data_type" } diff --git a/docs/code/user_info_example.json b/docs/code/user_info_example.json index ac32ff552..76393f8b1 100644 --- a/docs/code/user_info_example.json +++ b/docs/code/user_info_example.json @@ -3,5 +3,6 @@ "kind": "user", "name": "user_name", "alias": "user_alias", - "alive": true + "alive": true, + "status": 0, } diff --git a/docs/rst/api-reference/types/entitystatus.rst b/docs/rst/api-reference/types/entitystatus.rst new file mode 100644 index 000000000..057043a0a --- /dev/null +++ b/docs/rst/api-reference/types/entitystatus.rst @@ -0,0 +1,10 @@ + +.. _api_types_entitystatus: + +.. rst-class:: api-ref + +EntityStatus +------------ + +.. doxygenenum:: eprosima::statistics_backend::EntityStatus + :project: fastdds_statistics_backend diff --git a/docs/rst/api-reference/types/types_index.rst b/docs/rst/api-reference/types/types_index.rst index 117e68901..242efdc14 100644 --- a/docs/rst/api-reference/types/types_index.rst +++ b/docs/rst/api-reference/types/types_index.rst @@ -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 diff --git a/docs/rst/exports/alias.include b/docs/rst/exports/alias.include index c17f8fd7d..542a49045 100644 --- a/docs/rst/exports/alias.include +++ b/docs/rst/exports/alias.include @@ -15,6 +15,7 @@ .. |reset-api| replace:: :cpp:func:`reset()` .. |set_domain_listener-api| replace:: :cpp:func:`set_domain_listener()` .. |get_type-api| replace:: :cpp:func:`get_type()` +.. |get_status-api| replace:: :cpp:func:`get_status()` .. |set_alias-api| replace:: :cpp:func:`set_alias()` .. |clear_statistics_data-api| replace:: :cpp:func:`clear_statistics_data()` .. |clear_inactive_entities-api| replace:: :cpp:func:`clear_inactive_entities()` @@ -82,6 +83,11 @@ .. |DATAREADER-api| replace:: :cpp:enumerator:`DATAREADER` .. |LOCATOR-api| replace:: :cpp:enumerator:`LOCATOR` +.. |EntityStatus-api| replace:: :cpp:type:`EntityStatus` +.. |OK-api| replace:: :cpp:enumerator:`OK` +.. |WARNING-api| replace:: :cpp:enumerator:`WARNING` +.. |ERROR-api| replace:: :cpp:enumerator:`ERROR` + .. |BadParameter-api| replace:: :cpp:type:`BadParameter` .. |Error-api| replace:: :cpp:type:`Error` .. |PreconditionNotMet-api| replace:: :cpp:type:`PreconditionNotMet` diff --git a/docs/rst/notes/forthcoming_version.rst b/docs/rst/notes/forthcoming_version.rst new file mode 100644 index 000000000..b48ad0532 --- /dev/null +++ b/docs/rst/notes/forthcoming_version.rst @@ -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. diff --git a/docs/rst/notes/notes.rst b/docs/rst/notes/notes.rst index 16ac06f82..f10581d4b 100644 --- a/docs/rst/notes/notes.rst +++ b/docs/rst/notes/notes.rst @@ -4,6 +4,9 @@ Release Notes ############# +.. TODO uncomment when there are forthcoming notes +.. include:: forthcoming_version.rst + Version 0.11.0 ############## diff --git a/docs/rst/spelling_wordlist.txt b/docs/rst/spelling_wordlist.txt index 4e8dd92fb..c0f2064ce 100644 --- a/docs/rst/spelling_wordlist.txt +++ b/docs/rst/spelling_wordlist.txt @@ -18,6 +18,7 @@ metatraffic monitorization monitorizations namespace +Ok ostream OStream preprocessed diff --git a/docs/rst/statistics_backend/get_status.rst b/docs/rst/statistics_backend/get_status.rst new file mode 100644 index 000000000..c83dd4b0d --- /dev/null +++ b/docs/rst/statistics_backend/get_status.rst @@ -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. diff --git a/docs/rst/statistics_backend/statistics_backend.rst b/docs/rst/statistics_backend/statistics_backend.rst index 8269a24c4..0aa01e974 100644 --- a/docs/rst/statistics_backend/statistics_backend.rst +++ b/docs/rst/statistics_backend/statistics_backend.rst @@ -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 diff --git a/docs/rst/types/entity_status.rst b/docs/rst/types/entity_status.rst new file mode 100644 index 000000000..d3a8e0c6e --- /dev/null +++ b/docs/rst/types/entity_status.rst @@ -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. diff --git a/docs/rst/types/types_index.rst b/docs/rst/types/types_index.rst index caa05ffff..4ee16d0df 100644 --- a/docs/rst/types/types_index.rst +++ b/docs/rst/types/types_index.rst @@ -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 diff --git a/include/fastdds_statistics_backend/StatisticsBackend.hpp b/include/fastdds_statistics_backend/StatisticsBackend.hpp index f2b02aa44..1eafdae7b 100644 --- a/include/fastdds_statistics_backend/StatisticsBackend.hpp +++ b/include/fastdds_statistics_backend/StatisticsBackend.hpp @@ -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. * diff --git a/include/fastdds_statistics_backend/types/JSONTags.h b/include/fastdds_statistics_backend/types/JSONTags.h index 964c3e1eb..6367cb2fc 100644 --- a/include/fastdds_statistics_backend/types/JSONTags.h +++ b/include/fastdds_statistics_backend/types/JSONTags.h @@ -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 diff --git a/include/fastdds_statistics_backend/types/types.hpp b/include/fastdds_statistics_backend/types/types.hpp index d835ae32a..bdf207f5e 100644 --- a/include/fastdds_statistics_backend/types/types.hpp +++ b/include/fastdds_statistics_backend/types/types.hpp @@ -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 * diff --git a/src/cpp/StatisticsBackend.cpp b/src/cpp/StatisticsBackend.cpp index d0a041bb0..41244cc60 100644 --- a/src/cpp/StatisticsBackend.cpp +++ b/src/cpp/StatisticsBackend.cpp @@ -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) { @@ -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) { diff --git a/src/cpp/database/database.cpp b/src/cpp/database/database.cpp index 74433ce01..acbc20b07 100644 --- a/src/cpp/database/database.cpp +++ b/src/cpp/database/database.cpp @@ -2108,6 +2108,12 @@ EntityKind Database::get_entity_kind( return get_entity(entity_id)->kind; } +EntityStatus Database::get_entity_status( + EntityId entity_id) const +{ + return get_entity(entity_id)->status; +} + const std::vector> Database::get_entities( EntityKind entity_kind, const EntityId& entity_id) const @@ -2785,6 +2791,7 @@ DatabaseDump Database::dump_entity_( DatabaseDump entity_info = DatabaseDump::object(); entity_info[NAME_INFO_TAG] = entity->name; entity_info[ALIAS_INFO_TAG] = entity->alias; + entity_info[STATUS_INFO_TAG] = entity->status; // metatraffic and active attributes are stored but ignored when loading entity_info[METATRAFFIC_INFO_TAG] = entity->metatraffic; @@ -2809,6 +2816,7 @@ DatabaseDump Database::dump_entity_( DatabaseDump entity_info = DatabaseDump::object(); entity_info[NAME_INFO_TAG] = entity->name; entity_info[ALIAS_INFO_TAG] = entity->alias; + entity_info[STATUS_INFO_TAG] = entity->status; entity_info[HOST_ENTITY_TAG] = id_to_string(entity->host->id); @@ -2836,6 +2844,7 @@ DatabaseDump Database::dump_entity_( entity_info[NAME_INFO_TAG] = entity->name; entity_info[ALIAS_INFO_TAG] = entity->alias; entity_info[PID_INFO_TAG] = entity->pid; + entity_info[STATUS_INFO_TAG] = entity->status; entity_info[USER_ENTITY_TAG] = id_to_string(entity->user->id); @@ -2862,6 +2871,7 @@ DatabaseDump Database::dump_entity_( DatabaseDump entity_info = DatabaseDump::object(); entity_info[NAME_INFO_TAG] = entity->name; entity_info[ALIAS_INFO_TAG] = entity->alias; + entity_info[STATUS_INFO_TAG] = entity->status; // metatraffic and active attributes are stored but ignored when loading entity_info[METATRAFFIC_INFO_TAG] = entity->metatraffic; @@ -2897,6 +2907,7 @@ DatabaseDump Database::dump_entity_( entity_info[NAME_INFO_TAG] = entity->name; entity_info[ALIAS_INFO_TAG] = entity->alias; entity_info[DATA_TYPE_INFO_TAG] = entity->data_type; + entity_info[STATUS_INFO_TAG] = entity->status; entity_info[DOMAIN_ENTITY_TAG] = id_to_string(entity->domain->id); @@ -2935,6 +2946,7 @@ DatabaseDump Database::dump_entity_( entity_info[ALIAS_INFO_TAG] = entity->alias; entity_info[GUID_INFO_TAG] = entity->guid; entity_info[QOS_INFO_TAG] = entity->qos; + entity_info[STATUS_INFO_TAG] = entity->status; entity_info[DOMAIN_ENTITY_TAG] = id_to_string(entity->domain->id); @@ -3034,6 +3046,7 @@ DatabaseDump Database::dump_entity_( entity_info[ALIAS_INFO_TAG] = entity->alias; entity_info[GUID_INFO_TAG] = entity->guid; entity_info[QOS_INFO_TAG] = entity->qos; + entity_info[STATUS_INFO_TAG] = entity->status; entity_info[PARTICIPANT_ENTITY_TAG] = id_to_string(entity->participant->id); entity_info[TOPIC_ENTITY_TAG] = id_to_string(entity->topic->id); @@ -3104,6 +3117,7 @@ DatabaseDump Database::dump_entity_( entity_info[ALIAS_INFO_TAG] = entity->alias; entity_info[GUID_INFO_TAG] = entity->guid; entity_info[QOS_INFO_TAG] = entity->qos; + entity_info[STATUS_INFO_TAG] = entity->status; entity_info[PARTICIPANT_ENTITY_TAG] = id_to_string(entity->participant->id); entity_info[TOPIC_ENTITY_TAG] = id_to_string(entity->topic->id); @@ -3154,6 +3168,7 @@ DatabaseDump Database::dump_entity_( DatabaseDump entity_info = DatabaseDump::object(); entity_info[NAME_INFO_TAG] = entity->name; entity_info[ALIAS_INFO_TAG] = entity->alias; + entity_info[STATUS_INFO_TAG] = entity->status; // metatraffic and active attributes are stored but ignored when loading entity_info[METATRAFFIC_INFO_TAG] = entity->metatraffic; diff --git a/src/cpp/database/database.hpp b/src/cpp/database/database.hpp index 02b001dc4..55316ac8f 100644 --- a/src/cpp/database/database.hpp +++ b/src/cpp/database/database.hpp @@ -326,6 +326,16 @@ class Database EntityKind get_entity_kind( EntityId entity_id) const; + /** + * @brief Get EntityStatus given an EntityId. + * + * @param entity_id The EntityId of the entity. + * @throws eprosima::statistics_backend::BadParameter if there is no entity with the given ID. + * @return The EntityStatus of the given entity. + */ + EntityStatus get_entity_status( + EntityId entity_id) const; + /** * @brief Get a dump of the database. * diff --git a/src/cpp/database/database_queue.cpp b/src/cpp/database/database_queue.cpp index 7c22b7955..ab6d4dbf7 100644 --- a/src/cpp/database/database_queue.cpp +++ b/src/cpp/database/database_queue.cpp @@ -92,6 +92,8 @@ EntityId DatabaseEntityQueue::process_participant( name = info.address + ":" + get_participant_id(info.guid); } + EntityStatus status = info.entity_status; + // Create the participant and add it to the database GUID_t participant_guid = info.guid; auto participant = std::make_shared( @@ -99,7 +101,8 @@ EntityId DatabaseEntityQueue::process_participant( info.qos, to_string(participant_guid), std::shared_ptr(), - domain); + domain, + status); participant_id = database_->insert(participant); } diff --git a/src/cpp/database/database_queue.hpp b/src/cpp/database/database_queue.hpp index d8b074c6b..92352059a 100644 --- a/src/cpp/database/database_queue.hpp +++ b/src/cpp/database/database_queue.hpp @@ -369,6 +369,9 @@ struct EntityDiscoveryInfo std::string alias; bool is_virtual_metatraffic = false; + // Status + EntityStatus entity_status; + EntityDiscoveryInfo( EntityKind kind) : entity_kind(kind) diff --git a/src/cpp/database/entities.cpp b/src/cpp/database/entities.cpp index 4c448f0c0..1aa58036d 100644 --- a/src/cpp/database/entities.cpp +++ b/src/cpp/database/entities.cpp @@ -59,8 +59,9 @@ DDSEndpoint::DDSEndpoint( Qos endpoint_qos, /* {} */ std::string endpoint_guid, /* "|GUID UNKNOWN|" */ details::fragile_ptr endpoint_participant, /* nullptr */ - details::fragile_ptr endpoint_topic /* nullptr */) noexcept - : DDSEntity(entity_kind, endpoint_name, endpoint_qos, endpoint_guid) + details::fragile_ptr endpoint_topic, /* nullptr */ + EntityStatus status /* EntityStatus::OK */) noexcept + : DDSEntity(entity_kind, endpoint_name, endpoint_qos, endpoint_guid, status) , participant(endpoint_participant) , topic(endpoint_topic) { diff --git a/src/cpp/database/entities.hpp b/src/cpp/database/entities.hpp index 2c7ef7926..cbaf768a4 100644 --- a/src/cpp/database/entities.hpp +++ b/src/cpp/database/entities.hpp @@ -54,12 +54,14 @@ struct Entity EntityKind entity_kind = EntityKind::INVALID, std::string entity_name = "INVALID", bool entity_metatraffic = false, - bool entity_active = true) noexcept + bool entity_active = true, + EntityStatus entity_status = EntityStatus::OK) noexcept : kind(entity_kind) , name(entity_name) , alias(entity_name) , metatraffic(entity_metatraffic) , active(entity_active) + , status(entity_status) { } @@ -98,6 +100,9 @@ struct Entity //! Active means that there is statistical data being reported within the entity. bool active; + + //! The status of entity + EntityStatus status; }; /* @@ -106,8 +111,9 @@ struct Entity struct Host : Entity { Host( - std::string host_name) noexcept - : Entity(EntityKind::HOST, host_name, false, false) + std::string host_name, + EntityStatus status = EntityStatus::OK) noexcept + : Entity(EntityKind::HOST, host_name, false, false, status) { } @@ -130,8 +136,9 @@ struct User : Entity { User( std::string user_name, - details::fragile_ptr user_host) noexcept - : Entity(EntityKind::USER, user_name, false, false) + details::fragile_ptr user_host, + EntityStatus status = EntityStatus::OK) noexcept + : Entity(EntityKind::USER, user_name, false, false, status) , host(user_host) { } @@ -159,8 +166,9 @@ struct Process : Entity Process( std::string process_name, std::string process_id, - details::fragile_ptr process_user) noexcept - : Entity(EntityKind::PROCESS, process_name, false, false) + details::fragile_ptr process_user, + EntityStatus status = EntityStatus::OK) noexcept + : Entity(EntityKind::PROCESS, process_name, false, false, status) , pid(process_id) , user(process_user) { @@ -191,8 +199,9 @@ struct Process : Entity struct Domain : Entity { Domain( - std::string domain_name) noexcept - : Entity(EntityKind::DOMAIN, domain_name) + std::string domain_name, + EntityStatus status = EntityStatus::OK) noexcept + : Entity(EntityKind::DOMAIN, domain_name, false, true, status) { } @@ -223,8 +232,9 @@ struct DDSEntity : Entity EntityKind entity_kind = EntityKind::INVALID, std::string dds_entity_name = "INVALID", Qos dds_entity_qos = {}, - std::string dds_entity_guid = "|GUID UNKNOWN|") noexcept - : Entity(entity_kind, dds_entity_name) + std::string dds_entity_guid = "|GUID UNKNOWN|", + EntityStatus status = EntityStatus::OK) noexcept + : Entity(entity_kind, dds_entity_name, false, true, status) , qos(dds_entity_qos) , guid(dds_entity_guid) { @@ -248,7 +258,8 @@ struct DDSEndpoint : DDSEntity Qos endpoint_qos = {}, std::string endpoint_guid = "|GUID UNKNOWN|", details::fragile_ptr endpoint_participant = nullptr, - details::fragile_ptr endpoint_topic = nullptr) noexcept; + details::fragile_ptr endpoint_topic = nullptr, + EntityStatus status = EntityStatus::OK) noexcept; //! Reference to the DomainParticipant in which this Endpoint runs. details::fragile_ptr participant; @@ -276,8 +287,9 @@ struct DomainParticipant : DDSEntity Qos participant_qos, std::string participant_guid, details::fragile_ptr participant_process, - details::fragile_ptr participant_domain) noexcept - : DDSEntity(EntityKind::PARTICIPANT, participant_name, participant_qos, participant_guid) + details::fragile_ptr participant_domain, + EntityStatus status = EntityStatus::OK) noexcept + : DDSEntity(EntityKind::PARTICIPANT, participant_name, participant_qos, participant_guid, status) , process(participant_process) , domain(participant_domain) { @@ -325,8 +337,9 @@ struct Topic : Entity Topic( std::string topic_name, std::string topic_type, - details::fragile_ptr topic_domain) noexcept - : Entity(EntityKind::TOPIC, topic_name, is_metatraffic_topic(topic_name)) + details::fragile_ptr topic_domain, + EntityStatus status = EntityStatus::OK) noexcept + : Entity(EntityKind::TOPIC, topic_name, is_metatraffic_topic(topic_name), true, status) , data_type(topic_type) , domain(topic_domain) { @@ -369,9 +382,10 @@ struct DataReader : DDSEndpoint Qos datareader_qos, std::string datareader_guid, details::fragile_ptr datareader_participant, - details::fragile_ptr datareader_topic) noexcept + details::fragile_ptr datareader_topic, + EntityStatus status = EntityStatus::OK) noexcept : DDSEndpoint(EntityKind::DATAREADER, datareader_name, datareader_qos, datareader_guid, datareader_participant, - datareader_topic) + datareader_topic, status) { } @@ -395,9 +409,10 @@ struct DataWriter : DDSEndpoint Qos datawriter_qos, std::string datawriter_guid, details::fragile_ptr datawriter_participant, - details::fragile_ptr datawriter_topic) noexcept + details::fragile_ptr datawriter_topic, + EntityStatus status = EntityStatus::OK) noexcept : DDSEndpoint(EntityKind::DATAWRITER, datawriter_name, datawriter_qos, datawriter_guid, datawriter_participant, - datawriter_topic) + datawriter_topic, status) { } diff --git a/test/unittest/Resources/alternative_complex_dump.json b/test/unittest/Resources/alternative_complex_dump.json index 335ce510f..865007742 100644 --- a/test/unittest/Resources/alternative_complex_dump.json +++ b/test/unittest/Resources/alternative_complex_dump.json @@ -63,6 +63,7 @@ "alias":"datareader_1", "metatraffic":false, "alive":true, + "status": 0, "participant":"15", "qos":{ "qos":"empty" @@ -131,6 +132,7 @@ "alias":"datareader_2", "metatraffic":false, "alive":true, + "status": 0, "participant":"24", "qos":{ "qos":"empty" @@ -199,6 +201,7 @@ "alias":"datareader_0", "metatraffic":false, "alive":true, + "status": 0, "participant":"6", "qos":{ "qos":"empty" @@ -330,6 +333,7 @@ "alias":"datawriter_1", "metatraffic":false, "alive":true, + "status": 0, "participant":"15", "qos":{ "qos":"empty" @@ -459,6 +463,7 @@ "alias":"datawriter_2", "metatraffic":false, "alive":true, + "status": 0, "participant":"24", "qos":{ "qos":"empty" @@ -588,6 +593,7 @@ "alias":"datawriter_0", "metatraffic":false, "alive":true, + "status": 0, "participant":"6", "qos":{ "qos":"empty" @@ -602,6 +608,7 @@ "alias":"domain_1", "metatraffic":false, "alive":true, + "status": 0, "participants":[ "15" ], @@ -614,6 +621,7 @@ "alias":"domain_2", "metatraffic":false, "alive":true, + "status": 0, "participants":[ "24" ], @@ -626,6 +634,7 @@ "alias":"domain_0", "metatraffic":false, "alive":true, + "status": 0, "participants":[ "6" ], @@ -640,6 +649,7 @@ "alias":"host_0", "metatraffic":false, "alive":true, + "status": 0, "users":[ "2" ] @@ -649,6 +659,7 @@ "alias":"host_1", "metatraffic":false, "alive":true, + "status": 0, "users":[ "11" ] @@ -665,7 +676,8 @@ "name":"locator_0", "alias":"locator_0", "metatraffic":false, - "alive":true + "alive":true, + "status": 0 }, "18":{ "datareaders":[ @@ -677,7 +689,8 @@ "name":"locator_2", "alias":"locator_2", "metatraffic":false, - "alive":true + "alive":true, + "status": 0 }, "9":{ "datareaders":[ @@ -689,7 +702,8 @@ "name":"locator_1", "alias":"locator_1", "metatraffic":false, - "alive":true + "alive":true, + "status": 0 } }, "participants":{ @@ -878,6 +892,7 @@ "alias":"participant_1", "metatraffic":false, "alive":true, + "status": 0, "process":"12", "qos":{ "qos":"empty" @@ -1068,6 +1083,7 @@ "alias":"participant_2", "metatraffic":false, "alive":true, + "status": 0, "process":"3", "qos":{ "qos":"empty" @@ -1258,6 +1274,7 @@ "alias":"participant_0", "metatraffic":false, "alive":true, + "status": 0, "process":"3", "qos":{ "qos":"empty" @@ -1270,6 +1287,7 @@ "alias":"process_1", "metatraffic":false, "alive":true, + "status": 0, "participants":[ "15" ], @@ -1281,6 +1299,7 @@ "alias":"process_0", "metatraffic":false, "alive":true, + "status": 0, "participants":[ "6", "24" @@ -1302,7 +1321,8 @@ "name":"topic_1", "alias":"topic_1", "metatraffic":false, - "alive":true + "alive":true, + "status": 0 }, "23":{ "data_type":"data_type", @@ -1316,7 +1336,8 @@ "name":"topic_2", "alias":"topic_2", "metatraffic":false, - "alive":true + "alive":true, + "status": 0 }, "5":{ "data_type":"data_type", @@ -1330,7 +1351,8 @@ "name":"topic_0", "alias":"topic_0", "metatraffic":false, - "alive":true + "alive":true, + "status": 0 } }, "users":{ @@ -1340,6 +1362,7 @@ "alias":"user_1", "metatraffic":false, "alive":true, + "status": 0, "processes":[ "12" ] @@ -1350,6 +1373,7 @@ "alias":"user_0", "metatraffic":false, "alive":true, + "status": 0, "processes":[ "3" ] diff --git a/test/unittest/Resources/alternative_complex_dump_erased_domain_2.json b/test/unittest/Resources/alternative_complex_dump_erased_domain_2.json index 74bde6596..c3726993a 100644 --- a/test/unittest/Resources/alternative_complex_dump_erased_domain_2.json +++ b/test/unittest/Resources/alternative_complex_dump_erased_domain_2.json @@ -63,6 +63,7 @@ "alias":"datareader_1", "metatraffic":false, "alive":true, + "status": 0, "participant":"15", "qos":{ "qos":"empty" @@ -131,6 +132,7 @@ "alias":"datareader_0", "metatraffic":false, "alive":true, + "status": 0, "participant":"6", "qos":{ "qos":"empty" @@ -262,6 +264,7 @@ "alias":"datawriter_1", "metatraffic":false, "alive":true, + "status": 0, "participant":"15", "qos":{ "qos":"empty" @@ -391,6 +394,7 @@ "alias":"datawriter_0", "metatraffic":false, "alive":true, + "status": 0, "participant":"6", "qos":{ "qos":"empty" @@ -405,6 +409,7 @@ "alias":"domain_1", "metatraffic":false, "alive":true, + "status": 0, "participants":[ "15" ], @@ -417,6 +422,7 @@ "alias":"domain_0", "metatraffic":false, "alive":true, + "status": 0, "participants":[ "6" ], @@ -431,6 +437,7 @@ "alias":"host_0", "metatraffic":false, "alive":true, + "status": 0, "users":[ "2" ] @@ -440,6 +447,7 @@ "alias":"host_1", "metatraffic":false, "alive":true, + "status": 0, "users":[ "11" ] @@ -456,7 +464,8 @@ "name":"locator_0", "alias":"locator_0", "metatraffic":false, - "alive":true + "alive":true, + "status": 0 }, "18":{ "datareaders":[ @@ -466,7 +475,8 @@ "name":"locator_2", "alias":"locator_2", "metatraffic":false, - "alive":true + "alive":true, + "status": 0 }, "9":{ "datareaders":[ @@ -478,7 +488,8 @@ "name":"locator_1", "alias":"locator_1", "metatraffic":false, - "alive":true + "alive":true, + "status": 0 } }, "participants":{ @@ -667,6 +678,7 @@ "alias":"participant_1", "metatraffic":false, "alive":true, + "status": 0, "process":"12", "qos":{ "qos":"empty" @@ -857,6 +869,7 @@ "alias":"participant_0", "metatraffic":false, "alive":true, + "status": 0, "process":"3", "qos":{ "qos":"empty" @@ -869,6 +882,7 @@ "alias":"process_1", "metatraffic":false, "alive":true, + "status": 0, "participants":[ "15" ], @@ -880,6 +894,7 @@ "alias":"process_0", "metatraffic":false, "alive":true, + "status": 0, "participants":[ "6" ], @@ -900,7 +915,8 @@ "name":"topic_1", "alias":"topic_1", "metatraffic":false, - "alive":true + "alive":true, + "status": 0 }, "5":{ "data_type":"data_type", @@ -914,7 +930,8 @@ "name":"topic_0", "alias":"topic_0", "metatraffic":false, - "alive":true + "alive":true, + "status": 0 } }, "users":{ @@ -924,6 +941,7 @@ "alias":"user_1", "metatraffic":false, "alive":true, + "status": 0, "processes":[ "12" ] @@ -934,6 +952,7 @@ "alias":"user_0", "metatraffic":false, "alive":true, + "status": 0, "processes":[ "3" ] diff --git a/test/unittest/Resources/complex_dump.json b/test/unittest/Resources/complex_dump.json index ff73a74d6..21ef487d0 100644 --- a/test/unittest/Resources/complex_dump.json +++ b/test/unittest/Resources/complex_dump.json @@ -62,6 +62,7 @@ "alias": "datareader_1", "metatraffic": false, "alive": true, + "status": 0, "participant": "15", "qos": { "qos": "empty" @@ -130,6 +131,7 @@ "alias": "datareader_2", "metatraffic": false, "alive": true, + "status": 0, "participant": "24", "qos": { "qos": "empty" @@ -198,6 +200,7 @@ "alias": "datareader_0", "metatraffic": false, "alive": true, + "status": 0, "participant": "6", "qos": { "qos": "empty" @@ -328,6 +331,7 @@ "alias": "datawriter_1", "metatraffic": false, "alive": true, + "status": 0, "participant": "15", "qos": { "qos": "empty" @@ -456,6 +460,7 @@ "alias": "datawriter_2", "metatraffic": false, "alive": true, + "status": 0, "participant": "24", "qos": { "qos": "empty" @@ -584,6 +589,7 @@ "alias": "datawriter_0", "metatraffic": false, "alive": true, + "status": 0, "participant": "6", "qos": { "qos": "empty" @@ -598,6 +604,7 @@ "alias": "domain_1", "metatraffic": false, "alive": true, + "status": 0, "participants": [ "15" ], @@ -610,6 +617,7 @@ "alias": "domain_2", "metatraffic": false, "alive": true, + "status": 0, "participants": [ "24" ], @@ -622,6 +630,7 @@ "alias": "domain_0", "metatraffic": false, "alive": true, + "status": 0, "participants": [ "6" ], @@ -636,6 +645,7 @@ "alias": "host_0", "metatraffic": false, "alive": true, + "status": 0, "users": [ "2" ] @@ -645,6 +655,7 @@ "alias": "host_1", "metatraffic": false, "alive": true, + "status": 0, "users": [ "11" ] @@ -654,6 +665,7 @@ "alias": "host_2", "metatraffic": false, "alive": true, + "status": 0, "users": [ "20" ] @@ -670,7 +682,8 @@ "name": "locator_0", "alias": "locator_0", "metatraffic": false, - "alive": true + "alive": true, + "status": 0 }, "18": { "datareaders": [ @@ -682,7 +695,8 @@ "name": "locator_2", "alias": "locator_2", "metatraffic": false, - "alive": true + "alive": true, + "status": 0 }, "9": { "datareaders": [ @@ -694,7 +708,8 @@ "name": "locator_1", "alias": "locator_1", "metatraffic": false, - "alive": true + "alive": true, + "status": 0 } }, "participants": { @@ -883,6 +898,7 @@ "alias": "participant_1", "metatraffic": false, "alive": true, + "status": 0, "process": "12", "qos": { "qos": "empty" @@ -1073,6 +1089,7 @@ "alias": "participant_2", "metatraffic": false, "alive": true, + "status": 0, "process": "21", "qos": { "qos": "empty" @@ -1263,6 +1280,7 @@ "alias": "participant_0", "metatraffic": false, "alive": true, + "status": 0, "process": "3", "qos": { "qos": "empty" @@ -1275,6 +1293,7 @@ "alias": "process_1", "metatraffic": false, "alive": true, + "status": 0, "participants": [ "15" ], @@ -1286,6 +1305,7 @@ "alias": "process_2", "metatraffic": false, "alive": true, + "status": 0, "participants": [ "24" ], @@ -1297,6 +1317,7 @@ "alias": "process_0", "metatraffic": false, "alive": true, + "status": 0, "participants": [ "6" ], @@ -1317,7 +1338,8 @@ "name": "topic_1", "alias": "topic_1", "metatraffic": false, - "alive": true + "alive": true, + "status": 0 }, "23": { "data_type": "data_type", @@ -1331,7 +1353,8 @@ "name": "topic_2", "alias": "topic_2", "metatraffic": false, - "alive": true + "alive": true, + "status": 0 }, "5": { "data_type": "data_type", @@ -1345,7 +1368,8 @@ "name": "topic_0", "alias": "topic_0", "metatraffic": false, - "alive": true + "alive": true, + "status": 0 } }, "users": { @@ -1355,6 +1379,7 @@ "alias": "user_1", "metatraffic": false, "alive": true, + "status": 0, "processes": [ "12" ] @@ -1365,6 +1390,7 @@ "alias": "user_0", "metatraffic": false, "alive": true, + "status": 0, "processes": [ "3" ] @@ -1375,6 +1401,7 @@ "alias": "user_2", "metatraffic": false, "alive": true, + "status": 0, "processes": [ "21" ] diff --git a/test/unittest/Resources/complex_dump_erased_domain_1.json b/test/unittest/Resources/complex_dump_erased_domain_1.json index e18fa0684..39c8ab23e 100644 --- a/test/unittest/Resources/complex_dump_erased_domain_1.json +++ b/test/unittest/Resources/complex_dump_erased_domain_1.json @@ -62,6 +62,7 @@ "alias": "datareader_2", "metatraffic": false, "alive": true, + "status": 0, "participant": "24", "qos": { "qos": "empty" @@ -130,6 +131,7 @@ "alias": "datareader_0", "metatraffic": false, "alive": true, + "status": 0, "participant": "6", "qos": { "qos": "empty" @@ -260,6 +262,7 @@ "alias": "datawriter_2", "metatraffic": false, "alive": true, + "status": 0, "participant": "24", "qos": { "qos": "empty" @@ -388,6 +391,7 @@ "alias": "datawriter_0", "metatraffic": false, "alive": true, + "status": 0, "participant": "6", "qos": { "qos": "empty" @@ -402,6 +406,7 @@ "alias": "domain_2", "metatraffic": false, "alive": true, + "status": 0, "participants": [ "24" ], @@ -414,6 +419,7 @@ "alias": "domain_0", "metatraffic": false, "alive": true, + "status": 0, "participants": [ "6" ], @@ -428,6 +434,7 @@ "alias": "host_0", "metatraffic": false, "alive": true, + "status": 0, "users": [ "2" ] @@ -437,6 +444,7 @@ "alias": "host_1", "metatraffic": false, "alive": false, + "status": 0, "users": [ "11" ] @@ -446,6 +454,7 @@ "alias": "host_2", "metatraffic": false, "alive": true, + "status": 0, "users": [ "20" ] @@ -462,7 +471,8 @@ "name": "locator_0", "alias": "locator_0", "metatraffic": false, - "alive": true + "alive": true, + "status": 0 }, "18": { "datareaders": [ @@ -474,7 +484,8 @@ "name": "locator_2", "alias": "locator_2", "metatraffic": false, - "alive": true + "alive": true, + "status": 0 }, "9": { "datareaders": [], @@ -482,7 +493,8 @@ "name": "locator_1", "alias": "locator_1", "metatraffic": false, - "alive": true + "alive": true, + "status": 0 } }, "participants": { @@ -671,6 +683,7 @@ "alias": "participant_2", "metatraffic": false, "alive": true, + "status": 0, "process": "21", "qos": { "qos": "empty" @@ -861,6 +874,7 @@ "alias": "participant_0", "metatraffic": false, "alive": true, + "status": 0, "process": "3", "qos": { "qos": "empty" @@ -873,6 +887,7 @@ "alias": "process_1", "metatraffic": false, "alive": false, + "status": 0, "participants": [], "pid": "36000", "user": "11" @@ -882,6 +897,7 @@ "alias": "process_2", "metatraffic": false, "alive": true, + "status": 0, "participants": [ "24" ], @@ -893,6 +909,7 @@ "alias": "process_0", "metatraffic": false, "alive": true, + "status": 0, "participants": [ "6" ], @@ -913,7 +930,8 @@ "name": "topic_2", "alias": "topic_2", "metatraffic": false, - "alive": true + "alive": true, + "status": 0 }, "5": { "data_type": "data_type", @@ -927,7 +945,8 @@ "name": "topic_0", "alias": "topic_0", "metatraffic": false, - "alive": true + "alive": true, + "status": 0 } }, "users": { @@ -937,6 +956,7 @@ "alias": "user_1", "metatraffic": false, "alive": false, + "status": 0, "processes": [ "12" ] @@ -947,6 +967,7 @@ "alias": "user_0", "metatraffic": false, "alive": true, + "status": 0, "processes": [ "3" ] @@ -957,6 +978,7 @@ "alias": "user_2", "metatraffic": false, "alive": true, + "status": 0, "processes": [ "21" ] diff --git a/test/unittest/Resources/database_dump.json b/test/unittest/Resources/database_dump.json index 988503d2b..8c2846248 100644 --- a/test/unittest/Resources/database_dump.json +++ b/test/unittest/Resources/database_dump.json @@ -147,6 +147,7 @@ "alias":"datareader_1", "metatraffic":false, "alive":true, + "status": 0, "participant":"15", "qos":{ "qos":"empty" @@ -179,6 +180,7 @@ "alias":"datareader_2", "metatraffic":false, "alive":true, + "status": 0, "participant":"24", "qos":{ "qos":"empty" @@ -531,6 +533,7 @@ "alias":"datawriter_1", "metatraffic":false, "alive":true, + "status": 0, "participant":"15", "qos":{ "qos":"empty" @@ -579,6 +582,7 @@ "alias":"datawriter_2", "metatraffic":false, "alive":true, + "status": 0, "participant":"24", "qos":{ "qos":"empty" @@ -598,7 +602,8 @@ "name":"locator_1", "alias":"locator_1", "metatraffic":false, - "alive":true + "alive":true, + "status": 0 }, "18":{ "datareaders":[ @@ -610,7 +615,8 @@ "name":"locator_2", "alias":"locator_2", "metatraffic":false, - "alive":true + "alive":true, + "status": 0 } }, "participants":{ @@ -1175,6 +1181,7 @@ "alias":"participant_1", "metatraffic":false, "alive":true, + "status": 0, "process":"12", "qos":{ "qos":"empty" @@ -1245,6 +1252,7 @@ "alias":"participant_2", "metatraffic":false, "alive":true, + "status": 0, "process":"21", "qos":{ "qos":"empty" @@ -1264,7 +1272,8 @@ "name":"topic_1", "alias":"topic_1", "metatraffic":false, - "alive":true + "alive":true, + "status": 0 }, "23":{ "data_type":"data_type", @@ -1278,7 +1287,8 @@ "name":"topic_2", "alias":"topic_2", "metatraffic":false, - "alive":true + "alive":true, + "status": 0 } }, "domains":{ @@ -1287,6 +1297,7 @@ "alias":"domain_1", "metatraffic":false, "alive":true, + "status": 0, "participants":[ "15" ], @@ -1299,6 +1310,7 @@ "alias":"domain_2", "metatraffic":false, "alive":true, + "status": 0, "participants":[ "24" ], @@ -1313,6 +1325,7 @@ "alias":"host_1", "metatraffic":false, "alive":true, + "status": 0, "users":[ "11" ] @@ -1322,6 +1335,7 @@ "alias":"host_2", "metatraffic":false, "alive":true, + "status": 0, "users":[ "2000" ] @@ -1334,6 +1348,7 @@ "alias":"user_1", "metatraffic":false, "alive":true, + "status": 0, "processes":[ "12" ] @@ -1344,6 +1359,7 @@ "alias":"user_2", "metatraffic":false, "alive":true, + "status": 0, "processes":[ "21" ] @@ -1355,6 +1371,7 @@ "alias":"process_1", "metatraffic":false, "alive":true, + "status": 0, "participants":[ "15" ], @@ -1366,6 +1383,7 @@ "alias":"process_2", "metatraffic":false, "alive":true, + "status": 0, "participants":[ "24" ], diff --git a/test/unittest/Resources/empty_entities_dump.json b/test/unittest/Resources/empty_entities_dump.json index 941a3043d..2855fb3d5 100644 --- a/test/unittest/Resources/empty_entities_dump.json +++ b/test/unittest/Resources/empty_entities_dump.json @@ -7,6 +7,7 @@ "alias": "host_0", "metatraffic": false, "alive": true, + "status": 0, "users": [ "2" ] @@ -18,6 +19,7 @@ "alias": "user_0", "metatraffic": false, "alive": true, + "status": 0, "host": "1", "processes": [ "3" @@ -30,6 +32,7 @@ "alias": "process_0", "metatraffic": false, "alive": true, + "status": 0, "pid": "36000", "user": "2", "participants": [ @@ -43,6 +46,7 @@ "alias": "domain_0", "metatraffic": false, "alive": true, + "status": 0, "participants": [ "6" ], @@ -57,6 +61,7 @@ "alias": "topic_0", "metatraffic": false, "alive": true, + "status": 0, "data_type": "data_type", "domain": "4", "datawriters": [ @@ -73,6 +78,7 @@ "alias": "participant_0", "metatraffic": false, "alive": true, + "status": 0, "guid": "01.0f.00.00.00.00.00.00.00.00.00.00|0.0.1.0", "qos": { "qos": "empty" @@ -115,6 +121,7 @@ "alias": "datawriter_0", "metatraffic": false, "alive": true, + "status": 0, "guid": "01.0f.00.00.00.00.00.00.00.00.00.00|0.0.0.0", "qos": { "qos": "empty" @@ -158,6 +165,7 @@ "alias": "datareader_0", "metatraffic": false, "alive": true, + "status": 0, "guid": "01.0f.00.00.00.00.00.00.00.00.00.00|0.0.0.0", "qos": { "qos": "empty" @@ -189,6 +197,7 @@ "alias": "locator_0", "metatraffic": false, "alive": true, + "status": 0, "datawriters": [ "7" ], diff --git a/test/unittest/Resources/empty_entities_dump_unlinked_entities.json b/test/unittest/Resources/empty_entities_dump_unlinked_entities.json index 7f578b155..f7c1e579c 100644 --- a/test/unittest/Resources/empty_entities_dump_unlinked_entities.json +++ b/test/unittest/Resources/empty_entities_dump_unlinked_entities.json @@ -7,6 +7,7 @@ "alias": "host_0", "metatraffic": false, "alive": false, + "status": 0, "users": [ "2" ] @@ -18,6 +19,7 @@ "alias": "user_0", "metatraffic": false, "alive": false, + "status": 0, "host": "1", "processes": [ "3" @@ -30,6 +32,7 @@ "alias": "process_0", "metatraffic": false, "alive": false, + "status": 0, "pid": "36000", "user": "2", "participants": [] @@ -41,6 +44,7 @@ "alias": "domain_0", "metatraffic": false, "alive": true, + "status": 0, "participants": [ "6" ], @@ -55,6 +59,7 @@ "alias": "topic_0", "metatraffic": false, "alive": true, + "status": 0, "data_type": "data_type", "domain": "4", "datawriters": [ @@ -71,6 +76,7 @@ "alias": "participant_0", "metatraffic": false, "alive": true, + "status": 0, "guid": "01.0f.00.00.00.00.00.00.00.00.00.00|0.0.1.0", "qos": { "qos": "empty" @@ -113,6 +119,7 @@ "alias": "datawriter_0", "metatraffic": false, "alive": true, + "status": 0, "guid": "01.0f.00.00.00.00.00.00.00.00.00.00|0.0.0.0", "qos": { "qos": "empty" @@ -156,6 +163,7 @@ "alias": "datareader_0", "metatraffic": false, "alive": true, + "status": 0, "guid": "01.0f.00.00.00.00.00.00.00.00.00.00|0.0.0.0", "qos": { "qos": "empty" @@ -187,6 +195,7 @@ "alias": "locator_0", "metatraffic": false, "alive": true, + "status": 0, "datawriters": [ "7" ], diff --git a/test/unittest/Resources/old_complex_dump.json b/test/unittest/Resources/old_complex_dump.json index 475977182..a75f8937d 100644 --- a/test/unittest/Resources/old_complex_dump.json +++ b/test/unittest/Resources/old_complex_dump.json @@ -62,6 +62,7 @@ "alias": "datareader_1", "metatraffic": false, "alive": true, + "status": 0, "participant": "15", "qos": { "qos": "empty" @@ -130,6 +131,7 @@ "alias": "datareader_2", "metatraffic": false, "alive": true, + "status": 0, "participant": "24", "qos": { "qos": "empty" @@ -198,6 +200,7 @@ "alias": "datareader_0", "metatraffic": false, "alive": true, + "status": 0, "participant": "6", "qos": { "qos": "empty" @@ -336,6 +339,7 @@ "alias": "datawriter_1", "metatraffic": false, "alive": true, + "status": 0, "participant": "15", "qos": { "qos": "empty" @@ -472,6 +476,7 @@ "alias": "datawriter_2", "metatraffic": false, "alive": true, + "status": 0, "participant": "24", "qos": { "qos": "empty" @@ -608,6 +613,7 @@ "alias": "datawriter_0", "metatraffic": false, "alive": true, + "status": 0, "participant": "6", "qos": { "qos": "empty" @@ -622,6 +628,7 @@ "alias": "domain_1", "metatraffic": false, "alive": true, + "status": 0, "participants": [ "15" ], @@ -634,6 +641,7 @@ "alias": "domain_2", "metatraffic": false, "alive": true, + "status": 0, "participants": [ "24" ], @@ -646,6 +654,7 @@ "alias": "domain_0", "metatraffic": false, "alive": true, + "status": 0, "participants": [ "6" ], @@ -660,6 +669,7 @@ "alias": "host_0", "metatraffic": false, "alive": true, + "status": 0, "users": [ "2" ] @@ -669,6 +679,7 @@ "alias": "host_1", "metatraffic": false, "alive": true, + "status": 0, "users": [ "11" ] @@ -678,6 +689,7 @@ "alias": "host_2", "metatraffic": false, "alive": true, + "status": 0, "users": [ "20" ] @@ -694,7 +706,8 @@ "name": "locator_0", "alias": "locator_0", "metatraffic": false, - "alive": true + "alive": true, + "status": 0 }, "18": { "datareaders": [ @@ -706,7 +719,8 @@ "name": "locator_2", "alias": "locator_2", "metatraffic": false, - "alive": true + "alive": true, + "status": 0 }, "9": { "datareaders": [ @@ -718,7 +732,8 @@ "name": "locator_1", "alias": "locator_1", "metatraffic": false, - "alive": true + "alive": true, + "status": 0 } }, "participants": { @@ -907,6 +922,7 @@ "alias": "participant_1", "metatraffic": false, "alive": true, + "status": 0, "process": "12", "qos": { "qos": "empty" @@ -1097,6 +1113,7 @@ "alias": "participant_2", "metatraffic": false, "alive": true, + "status": 0, "process": "21", "qos": { "qos": "empty" @@ -1287,6 +1304,7 @@ "alias": "participant_0", "metatraffic": false, "alive": true, + "status": 0, "process": "3", "qos": { "qos": "empty" @@ -1299,6 +1317,7 @@ "alias": "process_1", "metatraffic": false, "alive": true, + "status": 0, "participants": [ "15" ], @@ -1310,6 +1329,7 @@ "alias": "process_2", "metatraffic": false, "alive": true, + "status": 0, "participants": [ "24" ], @@ -1321,6 +1341,7 @@ "alias": "process_0", "metatraffic": false, "alive": true, + "status": 0, "participants": [ "6" ], @@ -1341,7 +1362,8 @@ "name": "topic_1", "alias": "topic_1", "metatraffic": false, - "alive": true + "alive": true, + "status": 0 }, "23": { "data_type": "data_type", @@ -1355,7 +1377,8 @@ "name": "topic_2", "alias": "topic_2", "metatraffic": false, - "alive": true + "alive": true, + "status": 0 }, "5": { "data_type": "data_type", @@ -1369,7 +1392,8 @@ "name": "topic_0", "alias": "topic_0", "metatraffic": false, - "alive": true + "alive": true, + "status": 0 } }, "users": { @@ -1379,6 +1403,7 @@ "alias": "user_1", "metatraffic": false, "alive": true, + "status": 0, "processes": [ "12" ] @@ -1389,6 +1414,7 @@ "alias": "user_0", "metatraffic": false, "alive": true, + "status": 0, "processes": [ "3" ] @@ -1399,6 +1425,7 @@ "alias": "user_2", "metatraffic": false, "alive": true, + "status": 0, "processes": [ "21" ] diff --git a/test/unittest/Resources/simple_dump.json b/test/unittest/Resources/simple_dump.json index 31ce7b0f7..3564fa010 100644 --- a/test/unittest/Resources/simple_dump.json +++ b/test/unittest/Resources/simple_dump.json @@ -7,6 +7,7 @@ "alias": "host_0", "metatraffic": false, "alive": true, + "status": 0, "users": [ "2" ] @@ -18,6 +19,7 @@ "alias": "user_0", "metatraffic": false, "alive": true, + "status": 0, "host": "1", "processes": [ "3" @@ -30,6 +32,7 @@ "alias": "process_0", "metatraffic": false, "alive": true, + "status": 0, "pid": "36000", "user": "2", "participants": [ @@ -43,6 +46,7 @@ "alias": "domain_0", "metatraffic": false, "alive": true, + "status": 0, "participants": [ "6" ], @@ -59,6 +63,7 @@ "alive": true, "data_type": "data_type", "domain": "4", + "status": 0, "datawriters": [ "7" ], @@ -77,6 +82,7 @@ "qos": { "qos": "empty" }, + "status": 0, "process": "3", "domain": "4", "datawriters": [ @@ -197,6 +203,7 @@ "qos": { "qos": "empty" }, + "status": 0, "participant": "6", "topic": "5", "locators": [ @@ -279,6 +286,7 @@ "qos": { "qos": "empty" }, + "status": 0, "participant": "6", "topic": "5", "locators": [ @@ -321,6 +329,7 @@ "alias": "locator_0", "metatraffic": false, "alive": true, + "status": 0, "datawriters": [ "7" ], diff --git a/test/unittest/Resources/simple_dump_no_process_participant_link.json b/test/unittest/Resources/simple_dump_no_process_participant_link.json index 38ccdf177..072755843 100644 --- a/test/unittest/Resources/simple_dump_no_process_participant_link.json +++ b/test/unittest/Resources/simple_dump_no_process_participant_link.json @@ -7,6 +7,7 @@ "alias": "host_0", "metatraffic": false, "alive": false, + "status": 0, "users": [ "2" ] @@ -18,6 +19,7 @@ "alias": "user_0", "metatraffic": false, "alive": false, + "status": 0, "host": "1", "processes": [ "3" @@ -30,6 +32,7 @@ "alias": "process_0", "metatraffic": false, "alive": false, + "status": 0, "pid": "36000", "user": "2", "participants": [] @@ -44,6 +47,7 @@ ], "metatraffic": false, "alive": true, + "status": 0, "topics": [ "5" ] @@ -55,6 +59,7 @@ "alias": "topic_0", "metatraffic": false, "alive": true, + "status": 0, "data_type": "data_type", "domain": "4", "datawriters": [ @@ -71,6 +76,7 @@ "alias": "participant_0", "metatraffic": false, "alive": true, + "status": 0, "guid": "01.0f.00.00.00.00.00.00.00.00.00.00|0.0.1.0", "qos": { "qos": "empty" @@ -191,6 +197,7 @@ "alias": "datawriter_0", "metatraffic": false, "alive": true, + "status": 0, "guid": "01.0f.00.00.00.00.00.00.00.00.00.00|0.0.0.0", "qos": { "qos": "empty" @@ -273,6 +280,7 @@ "alias": "datareader_0", "metatraffic": false, "alive": true, + "status": 0, "guid": "01.0f.00.00.00.00.00.00.00.00.00.00|0.0.0.0", "qos": { "qos": "empty" @@ -319,6 +327,7 @@ "alias": "locator_0", "metatraffic": false, "alive": true, + "status": 0, "datawriters": [ "7" ], diff --git a/test/unittest/Resources/simple_dump_no_process_participant_link_erased_domain.json b/test/unittest/Resources/simple_dump_no_process_participant_link_erased_domain.json index 1b28c862c..82e7af9fa 100644 --- a/test/unittest/Resources/simple_dump_no_process_participant_link_erased_domain.json +++ b/test/unittest/Resources/simple_dump_no_process_participant_link_erased_domain.json @@ -11,6 +11,7 @@ "alias": "host_0", "metatraffic":false, "alive":false, + "status": 0, "users": ["2"] } }, @@ -23,6 +24,7 @@ "alias": "user_0", "metatraffic":false, "alive":false, + "status": 0, "host": "1", "processes": ["3"] } @@ -36,6 +38,7 @@ "alias": "process_0", "metatraffic":false, "alive":false, + "status": 0, "pid": "36000", "user": "2", "participants": [] @@ -70,6 +73,7 @@ "alias": "locator_0", "metatraffic":false, "alive":true, + "status": 0, "datawriters": [], "datareaders": [] } diff --git a/test/unittest/StatisticsBackend/CMakeLists.txt b/test/unittest/StatisticsBackend/CMakeLists.txt index 93683b0b8..be0eb2353 100644 --- a/test/unittest/StatisticsBackend/CMakeLists.txt +++ b/test/unittest/StatisticsBackend/CMakeLists.txt @@ -63,6 +63,7 @@ get_win32_path_dependencies(statistics_backend_tests TEST_FRIENDLY_PATH) set(BACKEND_TEST_LIST get_info get_entities + get_status get_type get_data_supported_entity_kinds set_alias diff --git a/test/unittest/StatisticsBackend/StatisticsBackendTests.cpp b/test/unittest/StatisticsBackend/StatisticsBackendTests.cpp index f46cc2054..9709df3cc 100644 --- a/test/unittest/StatisticsBackend/StatisticsBackendTests.cpp +++ b/test/unittest/StatisticsBackend/StatisticsBackendTests.cpp @@ -108,6 +108,8 @@ TEST_F(statistics_backend_tests, get_info) info.erase(ALIVE_INFO_TAG); EXPECT_EQ(entity->metatraffic, info[METATRAFFIC_INFO_TAG]); info.erase(METATRAFFIC_INFO_TAG); + EXPECT_EQ(entity->status, info[STATUS_INFO_TAG]); + info.erase(STATUS_INFO_TAG); // Check specific info switch (entity->kind) @@ -220,6 +222,86 @@ TEST_P(statistics_backend_tests, get_entities) } } +// Check the get_status StatisticsBackend method +TEST_F(statistics_backend_tests, get_status) +{ + StatisticsBackendTest::set_database(db); + + for (auto pair : db->hosts()) + { + auto entity = pair.second; + ASSERT_EQ(StatisticsBackendTest::get_status(entity->id), entity->status); + } + + for (auto pair : db->users()) + { + auto entity = pair.second; + ASSERT_EQ(StatisticsBackendTest::get_status(entity->id), entity->status); + } + + for (auto pair : db->processes()) + { + auto entity = pair.second; + ASSERT_EQ(StatisticsBackendTest::get_status(entity->id), entity->status); + } + + for (auto pair : db->domains()) + { + auto entity = pair.second; + ASSERT_EQ(StatisticsBackendTest::get_status(entity->id), entity->status); + } + + for (auto domainPair : db->participants()) + { + auto domainEntities = domainPair.second; + for (auto pair : domainEntities) + { + auto entity = pair.second; + ASSERT_EQ(StatisticsBackendTest::get_status(entity->id), entity->status); + } + } + + for (auto domainPair : db->topics()) + { + auto domainEntities = domainPair.second; + for (auto pair : domainEntities) + { + auto entity = pair.second; + ASSERT_EQ(StatisticsBackendTest::get_status(entity->id), entity->status); + } + } + + for (auto domainPair : db->get_dds_endpoints()) + { + auto domainEntities = domainPair.second; + for (auto pair : domainEntities) + { + auto entity = pair.second; + ASSERT_EQ(StatisticsBackendTest::get_status(entity->id), entity->status); + } + } + + for (auto domainPair : db->get_dds_endpoints()) + { + auto domainEntities = domainPair.second; + for (auto pair : domainEntities) + { + auto entity = pair.second; + ASSERT_EQ(StatisticsBackendTest::get_status(entity->id), entity->status); + } + } + + for (auto pair : db->locators()) + { + auto entity = pair.second; + ASSERT_EQ(StatisticsBackendTest::get_status(entity->id), entity->status); + } + + ASSERT_THROW(StatisticsBackendTest::get_status(EntityId::all()), BadParameter); + ASSERT_THROW(StatisticsBackendTest::get_status(EntityId::invalid()), BadParameter); + ASSERT_THROW(StatisticsBackendTest::get_status(EntityId(1234)), BadParameter); +} + // Check the get_type StatisticsBackend method TEST_F(statistics_backend_tests, get_type) { diff --git a/versions.md b/versions.md index e09d1e8a8..e099fd5f9 100644 --- a/versions.md +++ b/versions.md @@ -1,3 +1,9 @@ +Forthcoming +----------- + +* `StatisticsBackend::get_status` returns the entity status of a given id. +* Added status attribute for entities. + Version 0.11.0 --------------