From 85f868cacc6c6faa5c622ee512609d21a8b72968 Mon Sep 17 00:00:00 2001 From: Peguen Date: Wed, 22 Jan 2025 15:02:45 +0100 Subject: [PATCH 1/3] Filter eventcalls by hostname in ecal_service_client_v5_impl --- .../service/ecal_service_client_v5_impl.cpp | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/ecal/core/src/service/ecal_service_client_v5_impl.cpp b/ecal/core/src/service/ecal_service_client_v5_impl.cpp index a58cb2deb5..d902aa3783 100644 --- a/ecal/core/src/service/ecal_service_client_v5_impl.cpp +++ b/ecal/core/src/service/ecal_service_client_v5_impl.cpp @@ -216,23 +216,25 @@ namespace eCAL Logging::Log(Logging::log_level_debug1, "v5::CServiceClientImpl: Making a synchronous call with response collection to method: " + method_name_); - // Call the method using the new API - ServiceIDResponseVecT service_id_responses; - const bool success = m_service_client_impl->CallWithResponse(method_name_, request_, timeout_, service_id_responses); + std::pair success = { false, SServiceIDResponse() }; + auto instances = m_service_client_impl->GetClientInstances(); - // Convert the responses to the old format - service_response_vec_->clear(); - for (const auto& service_id_response : service_id_responses) + // Call the method using the new API for the correct host name + for (auto& instance : instances) { - // Filter responses based on host name if necessary - if (m_host_name.empty() || service_id_response.service_method_id.service_id.host_name == m_host_name) + if (instance.GetClientID().host_name == m_host_name) { - service_response_vec_->push_back(ConvertToServiceResponse(service_id_response)); + success = instance.CallWithResponse(method_name_, request_, timeout_); } } - Logging::Log(Logging::log_level_debug1, "v5::CServiceClientImpl: Call completed with success: " + std::to_string(success)); - return success; + // Convert the responses to the old format + service_response_vec_->clear(); + if (success.first) + service_response_vec_->push_back(ConvertToServiceResponse(success.second)); + + Logging::Log(Logging::log_level_debug1, "v5::CServiceClientImpl: Call completed with success: " + std::to_string(success.first)); + return success.first; } bool CServiceClientImpl::CallAsync(const std::string& method_name_, const std::string& request_, int /*timeout_*/) From d96e4950c923e69e97f36be34b8b6f91ee606e1f Mon Sep 17 00:00:00 2001 From: Peguen Date: Wed, 22 Jan 2025 16:06:55 +0100 Subject: [PATCH 2/3] Added hostname evaluation to all EventCalls in service_client_v5_impl. --- .../service/ecal_service_client_v5_impl.cpp | 42 ++++++++++++++----- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/ecal/core/src/service/ecal_service_client_v5_impl.cpp b/ecal/core/src/service/ecal_service_client_v5_impl.cpp index d902aa3783..65d3bb48a4 100644 --- a/ecal/core/src/service/ecal_service_client_v5_impl.cpp +++ b/ecal/core/src/service/ecal_service_client_v5_impl.cpp @@ -197,8 +197,18 @@ namespace eCAL } }; + auto instances = m_service_client_impl->GetClientInstances(); + bool success = false; + for (auto& instance : instances) + { + if (instance.GetClientID().host_name == m_host_name) + { + success = instance.CallWithCallback(method_name_, request_, timeout_, callback); + break; + } + } // Call the method using the new API - return m_service_client_impl->CallWithCallback(method_name_, request_, timeout_, callback); + return success; } bool CServiceClientImpl::Call(const std::string& method_name_, const std::string& request_, int timeout_, ServiceResponseVecT* service_response_vec_) @@ -216,25 +226,25 @@ namespace eCAL Logging::Log(Logging::log_level_debug1, "v5::CServiceClientImpl: Making a synchronous call with response collection to method: " + method_name_); - std::pair success = { false, SServiceIDResponse() }; + auto instances = m_service_client_impl->GetClientInstances(); - - // Call the method using the new API for the correct host name + std::pair response; for (auto& instance : instances) { if (instance.GetClientID().host_name == m_host_name) { - success = instance.CallWithResponse(method_name_, request_, timeout_); + response = instance.CallWithResponse(method_name_, request_, timeout_); + break; } } // Convert the responses to the old format service_response_vec_->clear(); - if (success.first) - service_response_vec_->push_back(ConvertToServiceResponse(success.second)); - - Logging::Log(Logging::log_level_debug1, "v5::CServiceClientImpl: Call completed with success: " + std::to_string(success.first)); - return success.first; + + service_response_vec_->push_back(ConvertToServiceResponse(response.second)); + + Logging::Log(Logging::log_level_debug1, "v5::CServiceClientImpl: Call completed with success: " + std::to_string(response.first)); + return response.first; } bool CServiceClientImpl::CallAsync(const std::string& method_name_, const std::string& request_, int /*timeout_*/) @@ -263,8 +273,18 @@ namespace eCAL } }; + auto instances = m_service_client_impl->GetClientInstances(); + bool success = false; + for (auto& instance : instances) + { + if (instance.GetClientID().host_name == m_host_name) + { + success = instance.CallWithCallbackAsync(method_name_, request_, callback); + break; + } + } + // Call the method asynchronously using the new API - const bool success = m_service_client_impl->CallWithCallbackAsync(method_name_, request_, callback); Logging::Log(Logging::log_level_debug1, "v5::CServiceClientImpl: Async call to method: " + method_name_ + " completed with success: " + std::to_string(success)); return success; } From ea7666abd1c84a550ad26995b30cc44843ec2207 Mon Sep 17 00:00:00 2001 From: Peguen Date: Wed, 22 Jan 2025 17:25:34 +0100 Subject: [PATCH 3/3] Updated to behaviour of v5.13 -> eCAL calls all methods on same host. --- .../service/ecal_service_client_v5_impl.cpp | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/ecal/core/src/service/ecal_service_client_v5_impl.cpp b/ecal/core/src/service/ecal_service_client_v5_impl.cpp index 65d3bb48a4..1cb545c8ea 100644 --- a/ecal/core/src/service/ecal_service_client_v5_impl.cpp +++ b/ecal/core/src/service/ecal_service_client_v5_impl.cpp @@ -201,10 +201,9 @@ namespace eCAL bool success = false; for (auto& instance : instances) { - if (instance.GetClientID().host_name == m_host_name) + if (instance.GetClientID().host_name == m_host_name || m_host_name.empty()) { - success = instance.CallWithCallback(method_name_, request_, timeout_, callback); - break; + success |= instance.CallWithCallback(method_name_, request_, timeout_, callback); } } // Call the method using the new API @@ -226,25 +225,25 @@ namespace eCAL Logging::Log(Logging::log_level_debug1, "v5::CServiceClientImpl: Making a synchronous call with response collection to method: " + method_name_); - auto instances = m_service_client_impl->GetClientInstances(); - std::pair response; + std::vector> responses; + bool success = false; for (auto& instance : instances) { - if (instance.GetClientID().host_name == m_host_name) + if (instance.GetClientID().host_name == m_host_name || m_host_name.empty()) { - response = instance.CallWithResponse(method_name_, request_, timeout_); - break; + responses.emplace_back(instance.CallWithResponse(method_name_, request_, timeout_)); + success |= responses.back().first; } } // Convert the responses to the old format service_response_vec_->clear(); + for (const auto& response : responses) + service_response_vec_->push_back(ConvertToServiceResponse(response.second)); - service_response_vec_->push_back(ConvertToServiceResponse(response.second)); - - Logging::Log(Logging::log_level_debug1, "v5::CServiceClientImpl: Call completed with success: " + std::to_string(response.first)); - return response.first; + Logging::Log(Logging::log_level_debug1, "v5::CServiceClientImpl: Call completed with success: " + std::to_string(success)); + return success; } bool CServiceClientImpl::CallAsync(const std::string& method_name_, const std::string& request_, int /*timeout_*/) @@ -277,10 +276,9 @@ namespace eCAL bool success = false; for (auto& instance : instances) { - if (instance.GetClientID().host_name == m_host_name) + if (instance.GetClientID().host_name == m_host_name || m_host_name.empty()) { - success = instance.CallWithCallbackAsync(method_name_, request_, callback); - break; + success |= instance.CallWithCallbackAsync(method_name_, request_, callback); } }