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

« back to all changes in this revision

Viewing changes to src/hed/libs/client/EntityRetriever.cpp

  • Committer: Package Import Robot
  • Author(s): Mattias Ellert
  • Date: 2012-12-13 16:41:31 UTC
  • mfrom: (3.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20121213164131-wii0p2fcv7e3en93
Tags: 2.0.1-1
* 2.0.1 Release
* Drop patches accepted upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
119
119
 
120
120
  template<typename T>
121
121
  void EntityRetriever<T>::addEndpoint(const Endpoint& endpoint) {
 
122
    // Set the status of the endpoint to STARTED only if it was not registered already (overwrite = false)
 
123
    if (!setStatusOfEndpoint(endpoint, EndpointQueryingStatus(EndpointQueryingStatus::STARTED), false)) {
 
124
      // Not able to set the status (because the endpoint was already registered)
 
125
      logger.msg(DEBUG, "Ignoring endpoint (%s), it is already registered in retriever.", endpoint.str());
 
126
      return;
 
127
    }
 
128
 
122
129
    std::map<std::string, std::string>::const_iterator itPluginName = interfacePluginMap.end();
123
130
    if (!endpoint.InterfaceName.empty()) {
124
131
      itPluginName = interfacePluginMap.find(endpoint.InterfaceName);
213
220
  void EntityRetriever<T>::queryEndpoint(void *arg) {
214
221
    AutoPointer<ThreadArg> a((ThreadArg*)arg);
215
222
    ThreadedPointer<Common>& common = a->common;
216
 
    bool set = false;
217
 
    // Set the status of the endpoint to STARTED only if it was not set already by an other thread (overwrite = false)
218
 
    if(!common->lockSharedIfValid()) return;
219
 
    set = (*common)->setStatusOfEndpoint(a->endpoint, EndpointQueryingStatus(EndpointQueryingStatus::STARTED), false);
220
 
    common->unlockShared();
221
223
 
222
 
    if (!set) { // The thread was not able to set the status (because it was already set by another thread)
223
 
      logger.msg(DEBUG, "Will not query endpoint (%s) because another thread is already querying it", a->endpoint.str());
224
 
      return;
225
 
    }
226
224
    // If the thread was able to set the status, then this is the first (and only) thread querying this endpoint
227
225
    if (!a->pluginName.empty()) { // If the plugin was already selected
228
226
      EntityRetrieverPlugin<T>* plugin = common->load(a->pluginName);
261
259
        if (!plugin) {
262
260
          // Should not happen since all available plugins was already loaded in the constructor.
263
261
          // Problem loading the plugin, skip it
264
 
          logger.msg(DEBUG, "Problem loading plugin %s, skipping it..", *it);
 
262
          logger.msg(DEBUG, "Problem loading plugin %s, skipping it.", *it);
265
263
          continue;
266
264
        }
267
265
        if (plugin->isEndpointNotSupported(a->endpoint)) {
270
268
        }
271
269
        // Create a new endpoint with the same endpoint and a specified interface
272
270
        Endpoint endpoint = a->endpoint;
273
 
        ThreadArg* newArg;
 
271
        ThreadArg* newArg = NULL;
274
272
        // Set interface
275
273
        std::list<std::string>::const_iterator itSI = plugin->SupportedInterfaces().begin();
276
274
        for (; itSI != plugin->SupportedInterfaces().end(); ++itSI) {
289
287
          otherEndpoints.push_back(endpoint);
290
288
          newArg = new ThreadArg(*a, otherResult);
291
289
        }
 
290
        // Set the status of the endpoint to STARTED only if it was not registered already (overwrite = false)
 
291
        if(!common->lockSharedIfValid()) return;
 
292
        bool set = (*common)->setStatusOfEndpoint(endpoint, EndpointQueryingStatus(EndpointQueryingStatus::STARTED), false);
 
293
        common->unlockShared();
 
294
        if (!set) {
 
295
          // Not able to set the status (because the endpoint was already registered)
 
296
          logger.msg(DEBUG, "Ignoring endpoint (%s), it is already registered in retriever.", endpoint.str());
 
297
          return;
 
298
        }
 
299
 
292
300
        // Make new argument by copying old one with result report object replaced
293
301
        newArg->endpoint = endpoint;
294
302
        newArg->pluginName = *it;