FairMQ  1.4.14
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 {
28 namespace mq {
29 namespace sdk {
30 
35 enum class DDSRMSPlugin
36 {
37  localhost,
38  ssh
39 };
40 auto operator<<(std::ostream& os, DDSRMSPlugin plugin) -> std::ostream&;
41 auto operator>>(std::istream& is, DDSRMSPlugin& plugin) -> std::istream&;
42 
43 class DDSTopology;
44 class DDSAgent;
45 
47 {
48  public:
49  using Id = std::uint64_t;
50 };
51 
57 {
58  public:
59  using Id = std::string;
60  using Quantity = std::uint32_t;
61  using Path = boost::filesystem::path;
62 
63  explicit DDSSession(DDSEnvironment env = DDSEnvironment());
64  explicit DDSSession(Id existing, DDSEnvironment env = DDSEnvironment());
65 
69  explicit DDSSession(std::shared_ptr<dds::tools_api::CSession> nativeSession, DDSEnv env = {});
70 
71  auto GetEnv() const -> DDSEnvironment;
72  auto GetId() const -> Id;
73  auto GetRMSPlugin() const -> DDSRMSPlugin;
74  auto SetRMSPlugin(DDSRMSPlugin) -> void;
75  auto GetRMSConfig() const -> Path;
76  auto SetRMSConfig(Path) const -> void;
77  auto IsStoppedOnDestruction() const -> bool;
78  auto StopOnDestruction(bool stop = true) -> void;
79  auto IsRunning() const -> bool;
80  auto SubmitAgents(Quantity agents) -> void;
81  struct AgentCount {
82  Quantity idle = 0;
83  Quantity active = 0;
84  Quantity executing = 0;
85  };
86  auto RequestAgentCount() -> AgentCount;
87  auto RequestAgentInfo() -> std::vector<DDSAgent>;
88  auto RequestTaskInfo() -> std::vector<DDSTask>;
89  struct CommanderInfo {
90  int pid = -1;
91  std::string activeTopologyName;
92  };
93  auto RequestCommanderInfo() -> CommanderInfo;
94  auto WaitForIdleAgents(Quantity) -> void;
95  auto WaitForOnlyIdleAgents() -> void;
96  auto WaitForExecutingAgents(Quantity) -> void;
97  auto ActivateTopology(const Path& topoFile) -> void;
98  auto ActivateTopology(DDSTopology) -> void;
99  auto Stop() -> void;
100 
101  void StartDDSService();
102  void SubscribeToCommands(std::function<void(const std::string& msg, const std::string& condition, uint64_t senderId)>);
103  void UnsubscribeFromCommands();
104  void SendCommand(const std::string&, const std::string& = "");
105  void SendCommand(const std::string&, DDSChannel::Id);
106  auto GetTaskId(DDSChannel::Id) const -> DDSTask::Id;
107 
108  friend auto operator<<(std::ostream& os, const DDSSession& session) -> std::ostream&;
109 
110  private:
111  struct Impl;
112  std::shared_ptr<Impl> fImpl;
113 };
114 
115 auto getMostRecentRunningDDSSession(DDSEnv env = {}) -> DDSSession;
116 
117 } // namespace sdk
118 } // namespace mq
119 } // namespace fair
120 
121 #endif /* FAIR_MQ_SDK_DDSSESSION_H */
Represents a DDS session.
Definition: DDSSession.h:56
Definition: DDSSession.cxx:58
Definition: DDSSession.h:46
Definition: DDSSession.h:81
Tools for interfacing containers to the transport via polymorphic allocators.
Definition: DeviceRunner.h:23
Definition: DDSSession.h:89
Sets up the DDS environment (object helper)
Definition: DDSEnvironment.h:24
Represents a DDS topology.
Definition: DDSTopology.h:29

privacy