DP3
ClusterDesc.h
Go to the documentation of this file.
1 // ClusterDesc.h: Description of a cluster and the nodes in it
2 //
3 // Copyright (C) 2020 ASTRON (Netherlands Institute for Radio Astronomy)
4 // SPDX-License-Identifier: GPL-3.0-or-later
5 
9 
10 #ifndef LOFAR_LMWCOMMON_CLUSTERDESC_H
11 #define LOFAR_LMWCOMMON_CLUSTERDESC_H
12 
13 #include "NodeDesc.h"
14 
15 #include <string>
16 #include <vector>
17 #include <iosfwd>
18 
19 namespace dp3 {
20 namespace common {
21 class ParameterSet;
22 }
23 } // namespace dp3
24 
25 namespace dp3 {
26 namespace common {
27 
30 
40 
41 class ClusterDesc {
42  public:
45 
47  explicit ClusterDesc(const std::string& parsetName);
48 
50  void setName(const std::string& name) { itsName = name; }
51 
55  void addNode(const NodeDesc& node, bool canExist = false);
56 
58  void write(std::ostream& os) const;
59 
61  const std::string& getName() const { return itsName; }
62 
64  const NodeDesc& getNode(const std::string& nodeName) const;
65 
67  const std::vector<NodeDesc>& getNodes() const { return itsNodes; }
68 
70  const std::map<std::string, std::vector<int>>& getMap() const {
71  return itsFS2Nodes;
72  }
73 
74  private:
76  void init(const std::string& parsetName);
77 
79  void getHomCluster(const ParameterSet& parset);
80 
82  void addNodes(const ParameterSet& parset, NodeDesc::NodeType type);
83 
85  void getHetCluster(const ParameterSet& parset);
86 
89  void getSubClusters(const std::vector<std::string>& parsetNames,
90  const std::string& defaultDir);
91 
93  void add2Map(int nodeIndex);
94 
95  std::string itsName;
96  std::vector<NodeDesc> itsNodes;
97  std::map<std::string, int> itsNodeMap;
98  std::map<std::string, std::vector<int>> itsFS2Nodes;
99 };
100 
101 } // namespace common
102 } // namespace dp3
103 
104 #endif
Description of a node in a cluster.
Description of a cluster and the nodes in it.
Definition: ClusterDesc.h:41
const std::string & getName() const
Get the cluster name.
Definition: ClusterDesc.h:61
const std::vector< NodeDesc > & getNodes() const
Get all nodes.
Definition: ClusterDesc.h:67
const std::map< std::string, std::vector< int > > & getMap() const
Get the map of file system to node index.
Definition: ClusterDesc.h:70
const NodeDesc & getNode(const std::string &nodeName) const
Get a specific node. An exception is thrown if not found.
void setName(const std::string &name)
Set cluster name.
Definition: ClusterDesc.h:50
ClusterDesc(const std::string &parsetName)
Construct from the given parameterset.
void addNode(const NodeDesc &node, bool canExist=false)
void write(std::ostream &os) const
Write it in parset format.
ClusterDesc()
Construct an empty object.
Definition: ClusterDesc.h:44
Description of a node in a cluster.
Definition: NodeDesc.h:31
NodeType
Define the node types.
Definition: NodeDesc.h:34
Implements a map of Key-Value pairs.
Definition: ParameterSet.h:31
This file has generic helper routines for testing steps.
Definition: AntennaConfig.h:53