~ubuntu-branches/ubuntu/trusty/nordugrid-arc/trusty-proposed

« back to all changes in this revision

Viewing changes to src/hed/libs/compute/Endpoint.h

  • Committer: Package Import Robot
  • Author(s): Mattias Ellert
  • Date: 2013-05-08 13:48:03 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20130508134803-mrhc5w4d5y7ubyj4
Tags: 3.0.1-1
3.0.1 Release

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
class EndpointQueryingStatus;
18
18
class ComputingEndpointAttributes;
19
19
  
 
20
/// Key comparison object definition for Endpoint objects
20
21
/**
 
22
 * \since Added in 3.0.0.
21
23
 * \ingroup compute
22
24
 * \headerfile Endpoint.h arc/compute/Endpoint.h 
23
25
 */
24
26
typedef bool (*EndpointCompareFn)(const Endpoint&, const Endpoint&);
25
27
 
 
28
/// Status map for Endpoint objects.
26
29
/**
 
30
 * Wrapper class inheriting from std::map providing no extra functionality than
 
31
 * that of std::map. It is needed due to limitations in the language wrapping
 
32
 * software (SWIG) that can't handle more than 2 template arguments.
 
33
 * 
 
34
 * \since Added in 3.0.0.
27
35
 * \ingroup compute
28
36
 * \headerfile Endpoint.h arc/compute/Endpoint.h 
29
37
 */
30
38
class EndpointStatusMap : public std::map<Endpoint, EndpointQueryingStatus, EndpointCompareFn> {
31
39
public:
 
40
  /// Creates a std::map with the key comparison object set to Endpoint::ServiceIDCompare
32
41
  EndpointStatusMap();
 
42
  /// Creates a std::map using \c fn as key comparison object
33
43
  EndpointStatusMap(EndpointCompareFn fn) : std::map<Endpoint, EndpointQueryingStatus, EndpointCompareFn>(fn) {}
 
44
  /// Copy constructor
34
45
  EndpointStatusMap(const EndpointStatusMap& m) : std::map<Endpoint, EndpointQueryingStatus, EndpointCompareFn>(m) {}
35
46
  ~EndpointStatusMap() {}
36
47
};
37
48
 
38
49
/// Represents an endpoint of a service with a given interface type and capabilities
39
50
/**
40
 
 * The type of the interface is described by a string called InterfaceName (from
41
 
 * the %GLUE2 specification). An Endpoint object must have a URL, and it is
42
 
 * quite useless without capabilities (the system has to know if an Endpoint is
43
 
 * a service registry or a computing element), but the InterfaceName is
44
 
 * optional.
 
51
 * This class similar in structure to the %Endpoint entity in the %GLUE2
 
52
 * specification. The type of the interface is described by a string called
 
53
 * InterfaceName (from the %GLUE2 specification). An Endpoint object must have a
 
54
 * URL, and it is quite useless without capabilities (the system has to know if
 
55
 * an Endpoint is a service registry or a computing element), but the
 
56
 * InterfaceName is optional.
45
57
 * 
46
58
 * The Endpoint object also contains information about the health state and
47
59
 * quality level of the endpoint, and optionally the requested submission
49
61
 * computing element related to this endpoint.
50
62
 * 
51
63
 * \see CapabilityEnum where the capabilities are listed.
 
64
 * \since Added in 2.0.0.
52
65
 * \ingroup compute
53
66
 * \headerfile Endpoint.h arc/compute/Endpoint.h 
54
67
 */
55
68
class Endpoint {
56
69
public:
57
 
  /** The capabilities:
58
 
  - REGISTRY: service registry capable of returning endpoints
59
 
  - COMPUTINGINFO: local information system of a computing element
60
 
                   capable of returning information about the resource
61
 
  - JOBLIST: local information system of a computing element
62
 
             capable of returning the list of jobs on the resource
63
 
  - JOBSUBMIT: interface of a computing element where jobs can be submitted
64
 
  - JOBCREATION: interface of a computing element where jobs can be created
65
 
  - UNSPECIFIED: unspecified capability
66
 
  */
67
 
  enum CapabilityEnum { REGISTRY, COMPUTINGINFO, JOBLIST, JOBSUBMIT, JOBCREATION, JOBMANAGEMENT, UNSPECIFIED};
 
70
  /// Values for classifying capabilities of services
 
71
  enum CapabilityEnum {
 
72
    /// Service registry capable of returning endpoints
 
73
    REGISTRY,
 
74
    /// Local information system of a computing element capable of returning information about the resource    
 
75
    COMPUTINGINFO,
 
76
    /// Local information system of a computing element capable of returning the list of jobs on the resource
 
77
    JOBLIST,
 
78
    /// Interface of a computing element where jobs can be submitted
 
79
    JOBSUBMIT,
 
80
    /// Interface of a computing element where jobs can be created
 
81
    /**
 
82
     * \since Added in 3.0.0.
 
83
     **/
 
84
    JOBCREATION,
 
85
    /// Interface of a computing element where jobs can be managed
 
86
    JOBMANAGEMENT,
 
87
    /// Unspecified capability
 
88
    UNSPECIFIED
 
89
  };
68
90
  
69
 
  /** Get the string representation of the given #CapabilityEnum. */
 
91
  /// Get string representation of #CapabilityEnum.
 
92
  /**
 
93
   * \return The %GLUE2 capability string associated with the passed
 
94
   * #CapabilityEnum value is returned.
 
95
   **/
70
96
  static std::string GetStringForCapability(Endpoint::CapabilityEnum cap) {
71
97
    if (cap == Endpoint::REGISTRY) return "information.discovery.registry";
72
98
    if (cap == Endpoint::COMPUTINGINFO) return "information.discovery.resource";
105
131
   * \param e ExecutionTarget object to create new Endpoint from.
106
132
   * \param rsi string specifying the requested submission interface if any.
107
133
   *        Default value is the empty string.
 
134
   * \since Added in 3.0.0.
108
135
   **/
109
136
  Endpoint(const ExecutionTarget& e, const std::string& rsi = "");
110
137
 
111
 
  /// Create new Endpoint from ExecutionTarget object
 
138
  /// Create new Endpoint from ComputingEndpointAttributes object
112
139
  /**
113
140
   * \param cea ComputingEndpointAttributes object to create new Endpoint from.
114
141
   * \param rsi string specifying the requested submission interface if any.
115
142
   *        Default value is the empty string.
 
143
   * \since Added in 3.0.0.
116
144
   **/
117
145
  Endpoint(const ComputingEndpointAttributes& cea, const std::string& rsi = "");
118
146
  
119
147
  /// Create a new Endpoint from a ConfigEndpoint
120
148
  /**
121
 
    The URL, InterfaceName and the RequestedSubmissionInterfaceName will be copied
122
 
    from the ConfigEndpoint, and if the type of the ConfigEndpoint is REGISTRY or
123
 
    COMPUTINGINFO, the given capability will be added to the new Endpoint object.
124
 
    \param[in] endpoint is the ConfigEndpoint object which will be converted to an Endpoint
125
 
 
126
 
    This will call #operator=.
127
 
  */
 
149
   * The ConfigEndpoint::URLString, ConfigEndpoint::InterfaceName and the
 
150
   * ConfigEndpoint::RequestedSubmissionInterfaceName attributes will be copied
 
151
   * from the ConfigEndpoint, and if the type of the ConfigEndpoint is #REGISTRY
 
152
   * or #COMPUTINGINFO, the given capability will be added to the new Endpoint
 
153
   * object.
 
154
   * 
 
155
   * \param[in] endpoint is the ConfigEndpoint object which will be converted to
 
156
   *  an Endpoint
 
157
   **/
128
158
  Endpoint(const ConfigEndpoint& endpoint) { *this = endpoint; }
129
159
  
130
 
  /** Checks if the Endpoint has the given capability specified by a CapabilityEnum
131
 
    \param[in] cap is the specified CapabilityEnum
132
 
    \return true if the Endpoint has the given capability
 
160
  /// Check for capability
 
161
  /**
 
162
   * Checks if the Endpoint has the given capability specified by a
 
163
   * #CapabilityEnum value.
 
164
   * 
 
165
   * \param[in] cap is the specified #CapabilityEnum
 
166
   * \return true if the Endpoint has the given capability
133
167
  */
134
168
  bool HasCapability(Endpoint::CapabilityEnum cap) const;
135
169
  
136
 
  /** Checks if the Endpoint has the given capability specified by a string
137
 
    \param[in] cap is a string specifying a capability
138
 
    \return true if the Endpoint has the given capability
 
170
  /// Check for capability
 
171
  /**
 
172
   * Checks if the Endpoint has the given capability specified by a string.
 
173
   * 
 
174
   * \param[in] cap is a string specifying a capability.
 
175
   * \return true if the Endpoint has the given capability.
139
176
  */
140
177
  bool HasCapability(const std::string& cap) const;
141
178
 
142
 
  /** Returns a string representation of the Endpoint containing the URL,
143
 
    the main capability and the InterfaceName
144
 
  */
 
179
  /// Get string representation of this object
 
180
  /**
 
181
   * \return String formatted as:
 
182
   * \verbatim
 
183
   <URLString> (<InterfaceName>[, capabilities: <Capabilities space separated>])
 
184
   \endverbatim
 
185
   * where if #InterfaceName is empty, "<empty InterfaceName>" is used.
 
186
   **/
145
187
  std::string str() const;
146
188
 
147
 
  /** A string identifying the service exposing this endpoint.  It currently
148
 
    extracts the host name from the URL, but this may be refined later. */
 
189
  /// Get name of service from #URLString attribute
 
190
  /**
 
191
   * \return If #URLString contains "://", a URL object will be created from it
 
192
   * and if the host part of it is non empty it is returned, otherwise
 
193
   * #URLString is returned.
 
194
   * \since Added in 3.0.0.
 
195
   **/
149
196
  std::string getServiceName() const;
150
197
  
151
 
  /** Needed for std::map to be able to sort the keys */
 
198
  /// Key comparison method
 
199
  /**
 
200
   * Compare passed Endpoint object with this by value returned by #str().
 
201
   * 
 
202
   * \param[in] other Endpoint object to compare with.
 
203
   * \return The result of lexicographically less between this object (lhs) and
 
204
   * other (rhs) compared using value returned by #str() method, is returned.
 
205
   **/
152
206
  bool operator<(const Endpoint& other) const;
153
207
  
 
208
  /// Key comparison function for comparing Endpoint objects.
 
209
  /**
 
210
   * Compare endpoints by #ServiceID, #URLString and #InterfaceName in that
 
211
   * order. The attributes are compared lexicographically.
 
212
   * 
 
213
   * \return If the ServiceID attributes are unequal lexicographically less
 
214
   * between the ServiceID attributes of a and b is returned. If they equal then
 
215
   * same procedure is done with the URLString attribute, if they equal
 
216
   * lexicographically less between the InterfaceName attributes of a and b is
 
217
   * returned.
 
218
   * 
 
219
   * \since Added in 3.0.0.
 
220
   **/
154
221
  static bool ServiceIDCompare(const Endpoint& a, const Endpoint& b);
155
222
 
156
 
  /** Copy a ConfigEndpoint into the Endpoint */
 
223
  /// Set from a ConfigEndpoint object
 
224
  /**
 
225
   * \return \c *this is returned.
 
226
   **/
157
227
  Endpoint& operator=(const ConfigEndpoint& e);
158
228
  
159
 
  /** The string representation of the URL of the Endpoint */
 
229
  /// The string representation of the URL of the Endpoint
160
230
  std::string URLString;
161
 
  /** The type of the interface (GLUE2 InterfaceName) */
 
231
  /// The type of the interface (%GLUE2 InterfaceName)
162
232
  std::string InterfaceName;  
163
 
  /** GLUE2 HealthState */
 
233
  /// %GLUE2 HealthState
164
234
  std::string HealthState;
165
 
  /** GLUE2 HealthStateInfo */
 
235
  /// %GLUE2 HealthStateInfo
166
236
  std::string HealthStateInfo;
167
 
  /** GLUE2 QualityLevel */
 
237
  /// %GLUE2 QualityLevel
168
238
  std::string QualityLevel;
169
 
  /** Set of GLUE2 Capability strings */
 
239
  /// Set of %GLUE2 Capability strings
170
240
  std::set<std::string> Capability;
171
 
  /** A GLUE2 InterfaceName requesting an InterfaceName used for job submission.
172
 
  
173
 
    If a user specifies an InterfaceName for submitting jobs, that information
174
 
    will be stored here and will be used when collecting information about the
175
 
    computing element. Only those job submission interfaces will be considered
176
 
    which has this requested InterfaceName.
177
 
  */
 
241
  /// A %GLUE2 InterfaceName requesting an InterfaceName used for job submission.
 
242
  /**
 
243
   * If a user specifies an InterfaceName for submitting jobs, that information
 
244
   * will be stored here and will be used when collecting information about the
 
245
   * computing element. Only those job submission interfaces will be considered
 
246
   * which has this requested InterfaceName.
 
247
   **/
178
248
  std::string RequestedSubmissionInterfaceName;
179
 
  /** The ID of the service this Endpoint belongs to */
 
249
  /// ID of service this Endpoint belongs to
 
250
  /**
 
251
   * \since Added in 3.0.0.
 
252
   **/
180
253
  std::string ServiceID;
181
254
 
 
255
  /// Get bounds in EndpointStatusMap corresponding to Endpoint
 
256
  /**
 
257
   * \param[in] endpoint An Endpoint object for which the bounds of equivalent
 
258
   *  Endpoint objects in the EndpointStatusMap should be found.
 
259
   * \param[in] statusMap See description above.
 
260
   * \return The lower and upper bound of the equivalent to the passed Endpoint
 
261
   *  object is returned as a pair (lower, upper).
 
262
   **/
182
263
  static std::pair<EndpointStatusMap::const_iterator, EndpointStatusMap::const_iterator> getServiceEndpoints(const Endpoint&, const EndpointStatusMap&);
183
264
};
184
265