ARC SDK
Endpoint.h
1 #ifndef __ARC_ENDPOINT_H__
2 #define __ARC_ENDPOINT_H__
3 
4 #include <string>
5 #include <set>
6 #include <algorithm>
7 #include <map>
8 
9 #include <arc/URL.h>
10 #include <arc/compute/EndpointQueryingStatus.h>
11 
12 namespace Arc {
13 
14 class ConfigEndpoint;
15 class ExecutionTarget;
16 class Endpoint;
17 class EndpointQueryingStatus;
18 class ComputingEndpointAttributes;
19 
24 typedef bool (*EndpointCompareFn)(const Endpoint&, const Endpoint&);
25 
30 class EndpointStatusMap : public std::map<Endpoint, EndpointQueryingStatus, EndpointCompareFn> {
31 public:
33  EndpointStatusMap(EndpointCompareFn fn) : std::map<Endpoint, EndpointQueryingStatus, EndpointCompareFn>(fn) {}
34  EndpointStatusMap(const EndpointStatusMap& m) : std::map<Endpoint, EndpointQueryingStatus, EndpointCompareFn>(m) {}
35  ~EndpointStatusMap() {}
36 };
37 
39 
55 class Endpoint {
56 public:
67  enum CapabilityEnum { REGISTRY, COMPUTINGINFO, JOBLIST, JOBSUBMIT, JOBCREATION, JOBMANAGEMENT, UNSPECIFIED};
68 
71  if (cap == Endpoint::REGISTRY) return "information.discovery.registry";
72  if (cap == Endpoint::COMPUTINGINFO) return "information.discovery.resource";
73  if (cap == Endpoint::JOBLIST) return "information.discovery.resource";
74  if (cap == Endpoint::JOBSUBMIT) return "executionmanagement.jobexecution";
75  if (cap == Endpoint::JOBCREATION) return "executionmanagement.jobcreation";
76  if (cap == Endpoint::JOBMANAGEMENT) return "executionmanagement.jobmanager";
77  return "";
78  }
79 
81 
87  Endpoint(const std::string& URLString = "",
88  const std::set<std::string>& Capability = std::set<std::string>(),
89  const std::string& InterfaceName = "")
91 
93 
98  Endpoint(const std::string& URLString,
99  const Endpoint::CapabilityEnum cap,
100  const std::string& InterfaceName = "")
101  : URLString(URLString), InterfaceName(InterfaceName), Capability() { Capability.insert(GetStringForCapability(cap)); }
102 
104 
109  Endpoint(const ExecutionTarget& e, const std::string& rsi = "");
110 
112 
117  Endpoint(const ComputingEndpointAttributes& cea, const std::string& rsi = "");
118 
120 
128  Endpoint(const ConfigEndpoint& endpoint) { *this = endpoint; }
129 
134  bool HasCapability(Endpoint::CapabilityEnum cap) const;
135 
140  bool HasCapability(const std::string& cap) const;
141 
145  std::string str() const;
146 
149  std::string getServiceName() const;
150 
152  bool operator<(const Endpoint& other) const;
153 
154  static bool ServiceIDCompare(const Endpoint& a, const Endpoint& b);
155 
157  Endpoint& operator=(const ConfigEndpoint& e);
158 
160  std::string URLString;
162  std::string InterfaceName;
164  std::string HealthState;
166  std::string HealthStateInfo;
168  std::string QualityLevel;
170  std::set<std::string> Capability;
180  std::string ServiceID;
181 
182  static std::pair<EndpointStatusMap::const_iterator, EndpointStatusMap::const_iterator> getServiceEndpoints(const Endpoint&, const EndpointStatusMap&);
183 };
184 
185 } // namespace Arc
186 
187 #endif // __ARC_ENDPOINT_H__