DDS  ver. 2.0
ConnectionManager.h
Go to the documentation of this file.
1 // Copyright 2014 GSI, Inc. All rights reserved.
2 //
3 //
4 //
5 #ifndef __DDS__ConnectionManager__
6 #define __DDS__ConnectionManager__
7 // DDS
8 #include "AgentChannel.h"
10 #include "KeyValueManager.h"
11 #include "Options.h"
12 #include "SSHScheduler.h"
13 #include "Topology.h"
14 #include "UIChannelInfo.h"
15 // STD
16 #include <condition_variable>
17 #include <mutex>
18 
19 namespace dds
20 {
21  namespace commander_cmd
22  {
23  class CConnectionManager : public protocol_api::CConnectionManagerImpl<CAgentChannel, CConnectionManager>,
24  public std::enable_shared_from_this<CConnectionManager>
25  {
26  public:
27  CConnectionManager(const SOptions_t& _options);
28 
30 
31  public:
33  void _start();
34  void _stop();
35  void _createInfoFile(const std::vector<size_t>& _ports) const;
36  void _deleteInfoFile() const;
37 
38  private:
39  void on_cmdGET_AGENTS_INFO(
40  const protocol_api::SSenderInfo& _sender,
43  void on_cmdGET_LOG(const protocol_api::SSenderInfo& _sender,
46  void on_cmdBINARY_ATTACHMENT_RECEIVED(
47  const protocol_api::SSenderInfo& _sender,
50  void on_cmdSUBMIT(const protocol_api::SSenderInfo& _sender,
53  void on_cmdTRANSPORT_TEST(
54  const protocol_api::SSenderInfo& _sender,
57  void on_cmdSIMPLE_MSG(const protocol_api::SSenderInfo& _sender,
60  void on_cmdUPDATE_KEY(const protocol_api::SSenderInfo& _sender,
63  void on_cmdUSER_TASK_DONE(
64  const protocol_api::SSenderInfo& _sender,
67  void on_cmdGET_PROP_LIST(
68  const protocol_api::SSenderInfo& _sender,
71  void on_cmdGET_PROP_VALUES(
72  const protocol_api::SSenderInfo& _sender,
75  void on_cmdUPDATE_TOPOLOGY(
76  const protocol_api::SSenderInfo& _sender,
79  void on_cmdREPLY_ID(const protocol_api::SSenderInfo& _sender,
82  void on_cmdENABLE_STAT(
83  const protocol_api::SSenderInfo& _sender,
86  void on_cmdDISABLE_STAT(
87  const protocol_api::SSenderInfo& _sender,
90  void on_cmdGET_STAT(const protocol_api::SSenderInfo& _sender,
93  void on_cmdCUSTOM_CMD(const protocol_api::SSenderInfo& _sender,
96 
97  private:
98  void activateTasks(const CSSHScheduler& _scheduler);
99  void stopTasks(const weakChannelInfo_t::container_t& _agents,
101  bool _shutdownOnComplete);
102  void enableDisableStatForChannels(bool _enable);
103  void _createWnPkg(bool _needInlineBashScript) const;
104 
105  private:
106  CGetLogChannelInfo m_getLog;
107  CTestChannelInfo m_transportTest;
108  CUpdateTopologyChannelInfo m_updateTopology;
109  CSubmitAgentsChannelInfo m_SubmitAgents;
111 
112  // TODO: This is temporary storage only. Store this information as a part of scheduler.
113  typedef std::map<uint64_t, weakChannelInfo_t> TaskIDToAgentChannelMap_t;
114  TaskIDToAgentChannelMap_t m_taskIDToAgentChannelMap;
115  std::mutex m_mapMutex;
116 
117  CKeyValueManager m_keyValueManager;
118 
119  std::mutex m_stopTasksMutex;
120  std::condition_variable m_stopTasksCondition;
121 
122  // Statistic on/off flag
123  bool m_statEnabled;
124  };
125  }
126 }
127 #endif /* defined(__DDS__ConnectionManager__) */
void _start()
Definition: ConnectionManager.cpp:52
std::shared_ptr< CAgentChannel > connectionPtr_t
Definition: BaseChannelImpl.h:216
Definition: BaseEventHandlersImpl.h:48
void _stop()
Definition: ConnectionManager.cpp:73
std::shared_ptr< SEmptyCmd > ptr_t
Definition: CommandAttachmentImpl.h:66
void _createInfoFile(const std::vector< size_t > &_ports) const
Definition: ConnectionManager.cpp:215
Definition: UIChannelInfo.h:189
Definition: UIChannelInfo.h:228
Definition: ConnectionManager.h:23
std::weak_ptr< CAgentChannel > weakConnectionPtr_t
Definition: BaseChannelImpl.h:217
CConnectionManager(const SOptions_t &_options)
Definition: ConnectionManager.cpp:41
Definition: UIChannelInfo.h:278
Definition: dds-agent/src/AgentConnectionManager.h:18
void newClientCreated(CAgentChannel::connectionPtr_t _newClient)
Definition: ConnectionManager.cpp:77
Definition: Topology.h:42
Key-value manager for the DDS commander.
Definition: KeyValueManager.h:114
dds-commander&#39;s container of options
Definition: dds-commander/src/Options.h:24
Definition: SSHScheduler.h:20
void _deleteInfoFile() const
Definition: ConnectionManager.cpp:251
~CConnectionManager()
Definition: ConnectionManager.cpp:48
Base class for connection managers.
Definition: ConnectionManagerImpl.h:33
std::vector< SWeakChannelInfo > container_t
Definition: ChannelInfo.h:54
Definition: UIChannelInfo.h:319