From cfcdd666bf4dfb7dce9781e106d6dd81628f819b Mon Sep 17 00:00:00 2001 From: Dennis Klein Date: Fri, 19 Jul 2019 16:34:44 +0200 Subject: [PATCH] SDK: Implement DDS helpers --- fairmq/sdk/DDSEnvironment.cxx | 1 + fairmq/sdk/DDSSession.cxx | 34 +++++++++++++++++++++++++++++++++- fairmq/sdk/DDSSession.h | 2 ++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/fairmq/sdk/DDSEnvironment.cxx b/fairmq/sdk/DDSEnvironment.cxx index 2d4684e8..3f28047b 100644 --- a/fairmq/sdk/DDSEnvironment.cxx +++ b/fairmq/sdk/DDSEnvironment.cxx @@ -33,6 +33,7 @@ auto LoadDDSEnv(const boost::filesystem::path& config_home, const boost::filesys std::istringstream cmd; cmd.str("DDS_CFG=`dds-user-defaults --ignore-default-sid -p`\n" "if [ -z \"$DDS_CFG\" ]; then\n" + " mkdir -p \"$HOME/.DDS\"\n" " dds-user-defaults --ignore-default-sid -d -c \"$HOME/.DDS/DDS.cfg\"\n" "fi"); std::system(cmd.str().c_str()); diff --git a/fairmq/sdk/DDSSession.cxx b/fairmq/sdk/DDSSession.cxx index a2cb25bd..6110602e 100644 --- a/fairmq/sdk/DDSSession.cxx +++ b/fairmq/sdk/DDSSession.cxx @@ -69,7 +69,6 @@ struct DDSSession::Impl ~Impl() { - fSession.stop(); fSession.shutdown(); } @@ -136,6 +135,39 @@ auto DDSSession::SubmitAgents(Quantity agents, DDSRMSPlugin plugin, const Path& blocker.Wait(); } +auto DDSSession::RequestAgentInfo() -> void +{ + dds::tools_api::SAgentInfoRequestData agentInfoInfo; + tools::Semaphore blocker; + auto agentInfoRequest = dds::tools_api::SAgentInfoRequest::makeRequest(agentInfoInfo); + agentInfoRequest->setResponseCallback( + [&](const dds::tools_api::SAgentInfoResponseData& _response) { + LOG(debug) << "agent: " << _response.m_index << "/" << _response.m_activeAgentsCount; + LOG(debug) << "info: " << _response.m_agentInfo; + }); + agentInfoRequest->setMessageCallback( + [](const dds::tools_api::SMessageResponseData& _message) { LOG(debug) << _message; }); + agentInfoRequest->setDoneCallback([&]() { blocker.Signal(); }); + fImpl->fSession.sendRequest(agentInfoRequest); + blocker.Wait(); +} + +auto DDSSession::ActivateTopology(Path topologyFile) -> void +{ + dds::tools_api::STopologyRequestData topologyInfo; + topologyInfo.m_updateType = dds::tools_api::STopologyRequestData::EUpdateType::ACTIVATE; + topologyInfo.m_topologyFile = topologyFile.string(); + LOG(warn) << topologyFile.string() << " :::: " << topologyFile; + + tools::Semaphore blocker; + auto topologyRequest = dds::tools_api::STopologyRequest::makeRequest(topologyInfo); + topologyRequest->setMessageCallback( + [](const dds::tools_api::SMessageResponseData& _message) { LOG(debug) << _message; }); + topologyRequest->setDoneCallback([&]() { blocker.Signal(); }); + fImpl->fSession.sendRequest(topologyRequest); + blocker.Wait(); +} + auto operator<<(std::ostream& os, DDSSession session) -> std::ostream& { return os << "$DDS_SESSION_ID: " << session.GetId(); diff --git a/fairmq/sdk/DDSSession.h b/fairmq/sdk/DDSSession.h index c73c21b0..f82f6053 100644 --- a/fairmq/sdk/DDSSession.h +++ b/fairmq/sdk/DDSSession.h @@ -58,6 +58,8 @@ class DDSSession auto SubmitAgents(Quantity agents, DDSRMSPlugin plugin) -> void; auto SubmitAgents(Quantity agents, DDSRMSPlugin plugin, const Path& config) -> void; auto SubmitAgents(Quantity agents, const Path& config) -> void; + auto RequestAgentInfo() -> void; + auto ActivateTopology(Path topologyFile) -> void; friend auto operator<<(std::ostream& os, DDSSession session) -> std::ostream&; private: