~ubuntu-branches/debian/sid/nordugrid-arc/sid

« back to all changes in this revision

Viewing changes to src/hed/acc/EMIES/SubmitterPluginEMIES.cpp

  • Committer: Package Import Robot
  • Author(s): Mattias Ellert
  • Date: 2012-12-13 16:41:31 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20121213164131-0fumka0jar8mxm07
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:
29
29
    return pos != std::string::npos && lower(endpoint.substr(0, pos)) != "http" && lower(endpoint.substr(0, pos)) != "https";
30
30
  }
31
31
  
32
 
  EMIESClient* SubmitterPluginEMIES::acquireClient(const URL& url) {
33
 
    std::map<URL, EMIESClient*>::const_iterator url_it = clients.find(url);
34
 
    if ( url_it != clients.end() ) {
35
 
      return url_it->second;
36
 
    } else {
37
 
      MCCConfig cfg;
38
 
      usercfg.ApplyToConfig(cfg);
39
 
      EMIESClient* ac = new EMIESClient(url, cfg, usercfg.Timeout());
40
 
      return clients[url] = ac;
41
 
    }
42
 
  }
43
 
 
44
 
  bool SubmitterPluginEMIES::releaseClient(const URL& url) {
45
 
    return true;
46
 
  }
47
 
 
48
 
  bool SubmitterPluginEMIES::deleteAllClients() {
49
 
    std::map<URL, EMIESClient*>::iterator it;
50
 
    for (it = clients.begin(); it != clients.end(); it++) {
51
 
        if ((*it).second != NULL) delete (*it).second;
52
 
    }
53
 
    return true;
54
 
  }
55
 
 
56
32
  bool SubmitterPluginEMIES::Submit(const std::list<JobDescription>& jobdescs, const ExecutionTarget& et, EntityConsumer<Job>& jc, std::list<const JobDescription*>& notSubmitted) {
57
33
    // TODO: this is multi step process. So having retries would be nice.
58
34
 
59
35
    URL url(et.ComputingEndpoint->URLString);
60
36
 
61
 
    EMIESClient* ac = acquireClient(url);
 
37
    AutoPointer<EMIESClient> ac(clients.acquire(url));
62
38
 
63
39
    bool ok = true;
64
40
    for (std::list<JobDescription>::const_iterator it = jobdescs.begin(); it != jobdescs.end(); ++it) {
177
153
      jc.addEntity(j);
178
154
    }
179
155
 
180
 
    releaseClient(url);
 
156
    clients.release(ac.Release());
181
157
    return ok;
182
158
  }
183
159
} // namespace Arc