Skip to content

Commit

Permalink
Fix counters and change endpoint names in problems view (#245)
Browse files Browse the repository at this point in the history
* Fix Problems view warning counters

Signed-off-by: Carlosespicur <[email protected]>

* Fix endpoint names in problems view

Signed-off-by: Carlosespicur <[email protected]>

* Update problems description

Signed-off-by: Raul Sanchez-Mateos <[email protected]>

* Print name of the incompatible entity instead of guid

Signed-off-by: Raul Sanchez-Mateos <[email protected]>

* Uncrustify

Signed-off-by: Raul Sanchez-Mateos <[email protected]>

---------

Signed-off-by: Carlosespicur <[email protected]>
Signed-off-by: Raul Sanchez-Mateos <[email protected]>
Co-authored-by: Raul Sanchez-Mateos <[email protected]>
  • Loading branch information
Carlosespicur and rsanchez15 authored Jan 30, 2025
1 parent 2951202 commit 0fed95d
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 19 deletions.
8 changes: 8 additions & 0 deletions include/fastdds_monitor/backend/SyncBackendConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ class SyncBackendConnection
EntityKind get_type(
backend::EntityId id);

//! Get entity by GUID in string format
backend::EntityId get_entity_by_guid(
const std::string& guid);

//! Get a summary of important data collected from the backend related with the entity with id \c id
EntityInfo get_summary(
backend::EntityId id);
Expand Down Expand Up @@ -211,6 +215,10 @@ class SyncBackendConnection
std::string get_deserialized_guid(
const backend::GUID_s& data);

//! Convert a given entity guid in string format to GUID_s
backend::GUID_s get_serialize_guid(
const std::string& guid_str);

//! Get info from an entity from the Backend
std::vector<EntityId> get_entities(
EntityKind entity_type,
Expand Down
9 changes: 7 additions & 2 deletions include/fastdds_monitor/model/tree/StatusTreeItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ class StatusTreeItem : public QObject
//! Return the number of leaf nodes of the subtree rooted at this node
int leafCount() const;

//! Return the number of leaf nodes of the subtree rooted at this node with a specific status level
int filteredLeafCount(
backend::StatusLevel status_level) const;

int row() const;

//! Return true if the node is a leaf node (no children).
Expand Down Expand Up @@ -169,8 +173,9 @@ class StatusTreeItem : public QObject
//! Remove item from tree and delete it
void remove();

//! Increases the issues counter of a top level entity item
int recalculate_entity_counter();
//! Increases the issues (warnings or errors) counter of a top level entity item
int recalculate_entity_counter(
backend::StatusLevel status_level);

private:

Expand Down
50 changes: 36 additions & 14 deletions src/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ bool Engine::update_entity_status(
backend::StatusLevel new_status = backend::StatusLevel::OK_STATUS;
std::string description = backend::entity_status_description(kind);
std::string entity_guid = backend_connection_.get_guid(id);

std::string entity_kind = utils::to_string(backend::entity_kind_to_QString(backend_connection_.get_type(id)));
switch (kind)
{
case backend::StatusKind::DEADLINE_MISSED:
Expand All @@ -1032,7 +1032,8 @@ bool Engine::update_entity_status(
{
backend::StatusLevel entity_status = backend_connection_.get_status(id);
auto entity_item = entity_status_model_->getTopLevelItem(
id, backend_connection_.get_name(id), entity_status, description, entity_guid);
id, entity_kind + ": " + backend_connection_.get_name(
id), entity_status, description, entity_guid);
new_status = sample.status;
std::string handle_string;
auto deadline_missed_item = new models::StatusTreeItem(id, kind, std::string("Deadline missed"),
Expand All @@ -1050,7 +1051,7 @@ bool Engine::update_entity_status(
entity_status_model_->addItem(deadline_missed_item, total_count_item);
entity_status_model_->addItem(deadline_missed_item, last_instance_handle_item);
entity_status_model_->addItem(entity_item, deadline_missed_item);
counter = entity_item->recalculate_entity_counter();
counter = entity_item->recalculate_entity_counter(sample.status);
}
}
break;
Expand All @@ -1064,14 +1065,15 @@ bool Engine::update_entity_status(
{
backend::StatusLevel entity_status = backend_connection_.get_status(id);
auto entity_item = entity_status_model_->getTopLevelItem(
id, backend_connection_.get_name(id), entity_status, description, entity_guid);
id, entity_kind + ": " + backend_connection_.get_name(
id), entity_status, description, entity_guid);
new_status = sample.status;
auto inconsistent_topic_item =
new models::StatusTreeItem(id, kind, std::string("Inconsistent topics:"),
sample.status, std::to_string(
sample.inconsistent_topic_status.total_count()), description);
entity_status_model_->addItem(entity_item, inconsistent_topic_item);
counter = entity_item->recalculate_entity_counter();
counter = entity_item->recalculate_entity_counter(sample.status);
}
}
break;
Expand All @@ -1085,7 +1087,8 @@ bool Engine::update_entity_status(
{
backend::StatusLevel entity_status = backend_connection_.get_status(id);
auto entity_item = entity_status_model_->getTopLevelItem(
id, backend_connection_.get_name(id), entity_status, description, entity_guid);
id, entity_kind + ": " + backend_connection_.get_name(
id), entity_status, description, entity_guid);
new_status = sample.status;
auto liveliness_changed_item =
new models::StatusTreeItem(id, kind, std::string("Liveliness changed"),
Expand All @@ -1110,7 +1113,7 @@ bool Engine::update_entity_status(
entity_status_model_->addItem(liveliness_changed_item, not_alive_count_item);
entity_status_model_->addItem(liveliness_changed_item, last_publication_handle_item);
entity_status_model_->addItem(entity_item, liveliness_changed_item);
counter = entity_item->recalculate_entity_counter();
counter = entity_item->recalculate_entity_counter(sample.status);
}
}
break;
Expand All @@ -1124,14 +1127,15 @@ bool Engine::update_entity_status(
{
backend::StatusLevel entity_status = backend_connection_.get_status(id);
auto entity_item = entity_status_model_->getTopLevelItem(
id, backend_connection_.get_name(id), entity_status, description, entity_guid);
id, entity_kind + ": " + backend_connection_.get_name(
id), entity_status, description, entity_guid);
new_status = sample.status;
auto liveliness_lost_item = new models::StatusTreeItem(id, kind, std::string(
"Liveliness lost:"),
sample.status, std::to_string(
sample.liveliness_lost_status.total_count()), description);
entity_status_model_->addItem(entity_item, liveliness_lost_item);
counter = entity_item->recalculate_entity_counter();
counter = entity_item->recalculate_entity_counter(sample.status);
}
}
break;
Expand All @@ -1145,13 +1149,14 @@ bool Engine::update_entity_status(
{
backend::StatusLevel entity_status = backend_connection_.get_status(id);
auto entity_item = entity_status_model_->getTopLevelItem(
id, backend_connection_.get_name(id), entity_status, description, entity_guid);
id, entity_kind + ": " + backend_connection_.get_name(
id), entity_status, description, entity_guid);
new_status = sample.status;
auto samples_lost_item = new models::StatusTreeItem(id, kind, std::string("Samples lost:"),
sample.status, std::to_string(
sample.sample_lost_status.total_count()), description);
entity_status_model_->addItem(entity_item, samples_lost_item);
counter = entity_item->recalculate_entity_counter();
counter = entity_item->recalculate_entity_counter(sample.status);
}
}
break;
Expand All @@ -1166,7 +1171,8 @@ bool Engine::update_entity_status(
std::string fastdds_version = "v3.1.0";
backend::StatusLevel entity_status = backend_connection_.get_status(id);
auto entity_item = entity_status_model_->getTopLevelItem(
id, backend_connection_.get_name(id), entity_status, description, entity_guid);
id, entity_kind + ": " + backend_connection_.get_name(
id), entity_status, description, entity_guid);
new_status = sample.status;

auto incompatible_qos_item = new models::StatusTreeItem(id, kind, std::string(
Expand All @@ -1193,8 +1199,24 @@ bool Engine::update_entity_status(
backend::policy_documentation_description(policy_id) +
std::string("\">here</a></html>"),
"", true);
std::string remote_entity;
backend::EntityId remote_entity_id = backend_connection_.get_entity_by_guid(
remote_entity_guid);
if (remote_entity_id.is_valid())
{
EntityInfo entity_info = backend_connection_.get_info(remote_entity_id);
std::string remote_entity_kind = utils::to_string(
backend::entity_kind_to_QString(backend_connection_.get_type(remote_entity_id)));
std::stringstream ss;
ss << std::string(entity_info["alias"]) << " (" << remote_entity_kind << ")";
remote_entity = ss.str();
}
else
{
remote_entity = remote_entity_guid;
}
auto remote_entity_item = new models::StatusTreeItem(id, kind,
std::string("Remote entity: " + remote_entity_guid),
std::string("Remote entity: " + remote_entity),
sample.status, std::string(""), std::string(
""), remote_entity_guid, false);
entity_status_model_->addItem(incompatible_qos_item, policy_item);
Expand All @@ -1204,7 +1226,7 @@ bool Engine::update_entity_status(
}

entity_status_model_->addItem(entity_item, incompatible_qos_item);
counter = entity_item->recalculate_entity_counter();
counter = entity_item->recalculate_entity_counter(sample.status);
}
}
break;
Expand Down
30 changes: 30 additions & 0 deletions src/backend/SyncBackendConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,22 @@ EntityKind SyncBackendConnection::get_type(
}
}

backend::EntityId SyncBackendConnection::get_entity_by_guid(
const std::string& guid)
{
try
{
return StatisticsBackend::get_entity_by_guid(guid);
}
catch (const Exception& e)
{
qWarning() << "Fail getting entity by guid " << e.what();
static_cast<void>(e); // In release qWarning does not compile and so e is not used

return EntityId::invalid();
}
}

std::vector<EntityId> SyncBackendConnection::get_entities(
EntityKind entity_type,
EntityId entity_id)
Expand Down Expand Up @@ -940,6 +956,20 @@ std::string SyncBackendConnection::get_deserialized_guid(
return StatisticsBackend::deserialize_guid(data);
}

backend::GUID_s SyncBackendConnection::get_serialize_guid(
const std::string& guid_str)
{
try
{
return StatisticsBackend::serialize_guid(guid_str);
}
catch (const std::exception& e)
{
qWarning() << "Error generating GUID from string " << e.what();
}
return backend::GUID_s();
}

bool SyncBackendConnection::build_source_target_entities_vectors(
DataKind data_kind,
EntityId source_entity_id,
Expand Down
22 changes: 19 additions & 3 deletions src/model/tree/StatusTreeItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,20 @@ int StatusTreeItem::leafCount() const
return count + int(child_items_.isEmpty());
}

int StatusTreeItem::filteredLeafCount(
backend::StatusLevel status_level) const
{
int count = 0;
for (int i = 0; i < child_items_.count(); i++)
{
if (child_items_.value(i)->status_level() == status_level)
{
count += child_items_.value(i)->filteredLeafCount(status_level);
}
}
return count + int(child_items_.isEmpty() && status_level == status_level_);
}

const QVariant& StatusTreeItem::entity_id() const
{
return id_variant_;
Expand Down Expand Up @@ -385,14 +399,16 @@ void StatusTreeItem::remove()
}
}

int StatusTreeItem::recalculate_entity_counter()
int StatusTreeItem::recalculate_entity_counter(
backend::StatusLevel status_level)
{
int count = 0;
// check if top level item / entity item
if (id_ != backend::ID_ALL && kind_ == backend::StatusKind::INVALID)
{
count = leafCount();
value_ = std::to_string(count);
count = filteredLeafCount(status_level);
// update total number of issues (warnings + errors) related to this item
value_ = std::to_string(leafCount());
value_variant_ = QVariant(QString::fromStdString(value_));
return count;
}
Expand Down

0 comments on commit 0fed95d

Please sign in to comment.