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

« back to all changes in this revision

Viewing changes to src/clients/compute/arcsync.cpp

  • Committer: Package Import Robot
  • Author(s): Mattias Ellert
  • Date: 2013-11-29 13:39:10 UTC
  • mfrom: (3.1.16 sid)
  • Revision ID: package-import@ubuntu.com-20131129133910-sy6ayoavphc5hozs
Tags: 4.0.0-1
4.0.0 Release (Closes: #715131) (LP: #1049798)

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include <arc/compute/Job.h>
22
22
#include <arc/compute/JobInformationStorage.h>
23
23
 
 
24
#include "utils.h"
 
25
 
24
26
class JobSynchronizer : public Arc::EntityConsumer<Arc::Endpoint> {
25
27
public:
26
28
  JobSynchronizer(
59
61
  bool writeJobs(bool truncate) {
60
62
    bool jobsWritten = false;
61
63
    bool jobsReported = false;
62
 
    Arc::JobInformationStorageXML jobList(uc.JobListFile());
 
64
    Arc::JobInformationStorage *jobstore = createJobInformationStorage(uc);
 
65
    if (jobstore == NULL) {
 
66
      std::cerr << Arc::IString("Warning: Unable to open job list file (%s), unknown format", uc.JobListFile()) << std::endl;
 
67
      return false;
 
68
    }
63
69
    // Write extracted job info to joblist
64
70
    if (truncate) {
65
 
      jobList.Clean();
66
 
      if ( (jobsWritten = jobList.Write(jobs)) ) {
 
71
      jobstore->Clean();
 
72
      if ( (jobsWritten = jobstore->Write(jobs)) ) {
67
73
        for (std::list<Arc::Job>::const_iterator it = jobs.begin();
68
74
             it != jobs.end(); ++it) {
69
75
          if (!jobsReported) {
85
91
      std::set<std::string> prunedServices;
86
92
      jlr.getServicesWithStatus(Arc::EndpointQueryingStatus::SUCCESSFUL,
87
93
                                prunedServices);
88
 
      if ( (jobsWritten = jobList.Write(jobs, prunedServices, newJobs)) ) {
 
94
      if ( (jobsWritten = jobstore->Write(jobs, prunedServices, newJobs)) ) {
89
95
        for (std::list<const Arc::Job*>::const_iterator it = newJobs.begin();
90
96
             it != newJobs.end(); ++it) {
91
97
          if (!jobsReported) {
102
108
        std::cout << Arc::IString("Total number of new jobs found: ") << newJobs.size() << std::endl;
103
109
      }
104
110
    }
105
 
 
 
111
    delete jobstore;
106
112
    if (!jobsWritten) {
107
 
      std::cout << Arc::IString("ERROR: Failed to lock job list file %s", uc.JobListFile()) << std::endl;
108
 
      std::cout << Arc::IString("Please try again later, or manually clean up lock file") << std::endl;
 
113
      std::cout << Arc::IString("ERROR: Failed to write job information to file (%s)", uc.JobListFile()) << std::endl;
109
114
      return false;
110
115
    }
111
116
 
119
124
  Arc::EntityContainer<Arc::Job> jobs;
120
125
};
121
126
 
122
 
#include "utils.h"
123
 
 
124
127
int RUNMAIN(arcsync)(int argc, char **argv) {
125
128
 
126
129
  setlocale(LC_ALL, "");
163
166
    return 1;
164
167
  }
165
168
 
 
169
  if (opt.timeout > 0)
 
170
    usercfg.Timeout(opt.timeout);
 
171
 
166
172
  if (!checkproxy(usercfg)) {
167
173
    return 1;
168
174
  }