FairMQ  1.4.33
C++ Message Queuing Library and Framework
DDSSession.h
1 /********************************************************************************
2  * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 
9 #ifndef FAIR_MQ_SDK_DDSSESSION_H
10 #define FAIR_MQ_SDK_DDSSESSION_H
11 
12 #include <fairmq/sdk/DDSEnvironment.h>
13 #include <fairmq/sdk/DDSInfo.h>
14 #include <fairmq/sdk/DDSTask.h>
15 
16 #include <boost/filesystem.hpp>
17 
18 #include <cstdint>
19 #include <istream>
20 #include <memory>
21 #include <ostream>
22 #include <stdexcept>
23 #include <string>
24 #include <functional>
25 #include <vector>
26 
27 namespace fair::mq::sdk
28 {
29 
34 enum class DDSRMSPlugin
35 {
36  localhost,
37  ssh
38 };
39 auto operator<<(std::ostream& os, DDSRMSPlugin plugin) -> std::ostream&;
40 auto operator>>(std::istream& is, DDSRMSPlugin& plugin) -> std::istream&;
41 
42 class DDSTopology;
43 class DDSAgent;
44 
45 class DDSChannel
46 {
47  public:
48  using Id = std::uint64_t;
49 };
50 
55 class DDSSession
56 {
57  public:
58  using Id = std::string;
59  using Quantity = std::uint32_t;
60  using Path = boost::filesystem::path;
61 
62  explicit DDSSession(DDSEnvironment env = DDSEnvironment());
63  explicit DDSSession(Id existing, DDSEnvironment env = DDSEnvironment());
64 
68  explicit DDSSession(std::shared_ptr<dds::tools_api::CSession> nativeSession, DDSEnv env = {});
69 
70  auto GetEnv() const -> DDSEnvironment;
71  auto GetId() const -> Id;
72  auto GetRMSPlugin() const -> DDSRMSPlugin;
73  auto SetRMSPlugin(DDSRMSPlugin) -> void;
74  auto GetRMSConfig() const -> Path;
75  auto SetRMSConfig(Path) const -> void;
76  auto IsStoppedOnDestruction() const -> bool;
77  auto StopOnDestruction(bool stop = true) -> void;
78  auto IsRunning() const -> bool;
79  auto SubmitAgents(Quantity agents) -> void;
80  struct AgentCount {
81  Quantity idle = 0;
82  Quantity active = 0;
83  Quantity executing = 0;
84  };
85  auto RequestAgentCount() -> AgentCount;
86  auto RequestAgentInfo() -> std::vector<DDSAgent>;
87  auto RequestTaskInfo() -> std::vector<DDSTask>;
88  struct CommanderInfo {
89  int pid = -1;
90  std::string activeTopologyName;
91  };
92  auto RequestCommanderInfo() -> CommanderInfo;
93  auto WaitForIdleAgents(Quantity) -> void;
94  auto WaitForOnlyIdleAgents() -> void;
95  auto WaitForExecutingAgents(Quantity) -> void;
96  auto ActivateTopology(const Path& topoFile) -> void;
97  auto ActivateTopology(DDSTopology) -> void;
98  auto Stop() -> void;
99 
100  void StartDDSService();
101  void SubscribeToCommands(std::function<void(const std::string& msg, const std::string& condition, uint64_t senderId)>);
102  void UnsubscribeFromCommands();
103  void SendCommand(const std::string&, const std::string& = "");
104  void SendCommand(const std::string&, DDSChannel::Id);
105  auto GetTaskId(DDSChannel::Id) const -> DDSTask::Id;
106 
107  friend auto operator<<(std::ostream& os, const DDSSession& session) -> std::ostream&;
108 
109  private:
110  struct Impl;
111  std::shared_ptr<Impl> fImpl;
112 };
113 
114 auto getMostRecentRunningDDSSession(DDSEnv env = {}) -> DDSSession;
115 
116 } // namespace fair::mq::sdk
117 
118 #endif /* FAIR_MQ_SDK_DDSSESSION_H */
fair::mq::sdk::DDSEnvironment
Sets up the DDS environment (object helper)
Definition: DDSEnvironment.h:30
fair::mq::sdk::DDSSession
Represents a DDS session.
Definition: DDSSession.h:62
fair::mq::sdk::DDSSession::Impl
Definition: DDSSession.cxx:65
fair::mq::sdk::DDSSession::CommanderInfo
Definition: DDSSession.h:94
fair::mq::sdk::DDSTopology
Represents a DDS topology.
Definition: DDSTopology.h:35

privacy