DDS  ver. 3.5.3.8.g5fe284b
SSHScheduler.h
Go to the documentation of this file.
1 // Copyright 2014 GSI, Inc. All rights reserved.
2 //
3 //
4 //
5 #ifndef __DDS__SSHScheduler__
6 #define __DDS__SSHScheduler__
7 
8 // DDS
9 #include "AgentChannel.h"
10 #include "ChannelInfo.h"
11 #include "TopoCore.h"
12 #include "TopoTask.h"
13 // STD
14 #include <vector>
15 
16 namespace dds
17 {
18  namespace commander_cmd
19  {
21  {
22  public:
23  struct SSchedule
24  {
26  : m_taskID(0)
27  {
28  }
29 
30  uint64_t m_taskID;
33  };
34 
35  typedef std::vector<SSchedule> ScheduleVector_t;
36  typedef std::map<size_t, std::vector<uint64_t>, std::greater<size_t>> CollectionMap_t;
37  typedef std::vector<dds::protocol_api::SWeakChannelInfo<CAgentChannel>> weakChannelInfoVector_t;
38 
39  private:
40  // Map tuple<agent ID, host name, worker id> to vector of channel indeces.
41  typedef std::map<std::tuple<uint64_t, std::string, std::string>, std::vector<size_t>> hostToChannelMap_t;
42  // Map pair<host name, task/collection name> to counter.
43  typedef std::map<std::pair<std::string, std::string>, size_t> hostCounterMap_t;
44 
45  public:
46  CSSHScheduler();
48 
49  void makeSchedule(const topology_api::CTopoCore& _topology, const weakChannelInfoVector_t& _channels);
50 
51  void makeSchedule(const topology_api::CTopoCore& _topology,
52  const weakChannelInfoVector_t& _channels,
53  const topology_api::CTopoCore::IdSet_t& _addedTasks,
54  const topology_api::CTopoCore::IdSet_t& _addedCollections);
55 
56  const ScheduleVector_t& getSchedule() const;
57 
58  static bool hostPatternMatches(const std::string& _hostPattern, const std::string& _host);
59 
60  std::string toString();
61 
62  private:
63  void makeScheduleImpl(const topology_api::CTopoCore& _topology,
64  const weakChannelInfoVector_t& _channels,
65  const topology_api::CTopoCore::IdSet_t* _addedTasks,
66  const topology_api::CTopoCore::IdSet_t* _addedCollections);
67 
68  void scheduleCollections(const topology_api::CTopoCore& _topology,
69  const weakChannelInfoVector_t& _channels,
70  hostToChannelMap_t& _hostToChannelMap,
71  std::set<uint64_t>& _scheduledTasks,
72  const CollectionMap_t& _collectionMap,
73  bool useRequirement,
74  hostCounterMap_t& _hostCounterMap);
75 
76  void scheduleTasks(const topology_api::CTopoCore& _topology,
77  const weakChannelInfoVector_t& _channels,
78  hostToChannelMap_t& _hostToChannelMap,
79  std::set<uint64_t>& _scheduledTasks,
80  const std::set<uint64_t>& _tasksInCollections,
81  bool useRequirement,
82  const topology_api::CTopoCore::IdSet_t* _addedTasks,
83  hostCounterMap_t& _hostCounterMap);
84 
85  bool checkRequirement(topology_api::CTopoRequirement::Ptr_t _requirement,
86  bool _useRequirement,
87  const std::string& _hostName,
88  const std::string& _wnName,
89  const std::string& _elementName,
90  hostCounterMap_t& _hostCounterMap) const;
91 
92  private:
93  ScheduleVector_t m_schedule;
94  };
95  } // namespace commander_cmd
96 } // namespace dds
97 
98 #endif /* defined(__DDS__SSHScheduler__) */
std::shared_ptr< CTopoRequirement > Ptr_t
Definition: TopoRequirement.h:31
SSchedule()
Definition: SSHScheduler.h:25
topology_api::STopoRuntimeTask m_taskInfo
Definition: SSHScheduler.h:31
uint64_t m_taskID
Definition: SSHScheduler.h:30
~CSSHScheduler()
Definition: SSHScheduler.cpp:25
dds::protocol_api::SWeakChannelInfo< CAgentChannel > m_weakChannelInfo
Definition: SSHScheduler.h:32
static bool hostPatternMatches(const std::string &_hostPattern, const std::string &_host)
Definition: SSHScheduler.cpp:358
Definition: TopoTask.h:101
CSSHScheduler()
Definition: SSHScheduler.cpp:21
std::vector< dds::protocol_api::SWeakChannelInfo< CAgentChannel > > weakChannelInfoVector_t
Definition: SSHScheduler.h:37
std::string toString()
Definition: SSHScheduler.cpp:366
Definition: AgentConnectionManager.h:13
Definition: TopoCore.h:25
void makeSchedule(const topology_api::CTopoCore &_topology, const weakChannelInfoVector_t &_channels)
Definition: SSHScheduler.cpp:29
std::map< size_t, std::vector< uint64_t >, std::greater< size_t > > CollectionMap_t
Definition: SSHScheduler.h:36
std::vector< SSchedule > ScheduleVector_t
Definition: SSHScheduler.h:35
Definition: ChannelInfo.h:38
Definition: SSHScheduler.h:20
const ScheduleVector_t & getSchedule() const
Definition: SSHScheduler.cpp:353
std::set< Id_t > IdSet_t
Note that ID is of type uint_64. ID is calculated using CRC64 algorithm.
Definition: TopoCore.h:30