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

[core] Change entity_id type from std::string to uint64_t #1872

Merged
merged 5 commits into from
Jan 7, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 13 additions & 30 deletions ecal/core/src/monitoring/ecal_monitoring_impl.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2024 Continental Corporation
* Copyright (C) 2016 - 2025 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -232,8 +232,8 @@ namespace eCAL
auto attr = sample_topic.attr;

// try to get topic info
const std::string topic_name_id = topic_name + topic_id;
Monitoring::STopicMon& TopicInfo = (*pTopicMap->map)[topic_name_id];
const std::string& topic_map_key = topic_id;
Monitoring::STopicMon& TopicInfo = (*pTopicMap->map)[topic_map_key];

// set static content
TopicInfo.hname = host_name;
Expand Down Expand Up @@ -292,9 +292,7 @@ namespace eCAL

bool CMonitoringImpl::UnregisterTopic(const Registration::Sample& sample_, enum ePubSub pubsub_type_)
{
const auto& sample_topic = sample_.topic;
const std::string& topic_name = sample_topic.tname;
const std::string& topic_id = sample_.identifier.entity_id;
const std::string& topic_map_key = sample_.identifier.entity_id;

// unregister from topic map
STopicMonMap* pTopicMap = GetMap(pubsub_type_);
Expand All @@ -304,8 +302,7 @@ namespace eCAL
const std::lock_guard<std::mutex> lock(pTopicMap->sync);

// remove topic info
const std::string topic_name_id = topic_name + topic_id;
pTopicMap->map->erase(topic_name_id);
pTopicMap->map->erase(topic_map_key);
}

return(true);
Expand Down Expand Up @@ -395,13 +392,13 @@ namespace eCAL
const uint32_t tcp_port_v1 = sample_service.tcp_port_v1;

// create map key
const std::string service_name_id = service_name + service_id + std::to_string(process_id);
const std::string& service_map_key = service_id;

// acquire access
const std::lock_guard<std::mutex> lock(m_server_map.sync);

// try to get service info
Monitoring::SServerMon& ServerInfo = (*m_server_map.map)[service_name_id];
Monitoring::SServerMon& ServerInfo = (*m_server_map.map)[service_map_key];

// set static content
ServerInfo.hname = host_name;
Expand Down Expand Up @@ -433,21 +430,14 @@ namespace eCAL

bool CMonitoringImpl::UnregisterServer(const Registration::Sample& sample_)
{
const auto& sample_service = sample_.service;
const auto& sample_identifier = sample_.identifier;

const std::string& service_name = sample_service.sname;
const std::string& service_id = sample_identifier.entity_id;
const int process_id = sample_identifier.process_id;

// create map key
const std::string service_name_id = service_name + service_id + std::to_string(process_id);
const std::string& service_map_key = sample_.identifier.entity_id;

// acquire access
const std::lock_guard<std::mutex> lock(m_server_map.sync);

// remove service info
m_server_map.map->erase(service_name_id);
m_server_map.map->erase(service_map_key);

return(true);
}
Expand All @@ -465,13 +455,13 @@ namespace eCAL
const std::string& unit_name = sample_client.uname;

// create map key
const std::string service_name_id = service_name + service_id + std::to_string(process_id);
const std::string& client_map_key = service_id;

// acquire access
const std::lock_guard<std::mutex> lock(m_clients_map.sync);

// try to get service info
Monitoring::SClientMon& ClientInfo = (*m_clients_map.map)[service_name_id];
Monitoring::SClientMon& ClientInfo = (*m_clients_map.map)[client_map_key];

// set static content
ClientInfo.hname = host_name;
Expand Down Expand Up @@ -501,21 +491,14 @@ namespace eCAL

bool CMonitoringImpl::UnregisterClient(const Registration::Sample& sample_)
{
const auto& sample_identifier = sample_.identifier;
const std::string& service_id = sample_identifier.entity_id;
const int32_t process_id = sample_identifier.process_id;

const auto& sample_client = sample_.client;
const std::string& service_name = sample_client.sname;

// create map key
const std::string service_name_id = service_name + service_id + std::to_string(process_id);
const std::string& client_map_key = sample_.identifier.entity_id;

// acquire access
const std::lock_guard<std::mutex> lock(m_clients_map.sync);

// remove service info
m_clients_map.map->erase(service_name_id);
m_clients_map.map->erase(client_map_key);

return(true);
}
Expand Down
Loading