~ubuntu-branches/ubuntu/utopic/nordugrid-arc/utopic

« back to all changes in this revision

Viewing changes to src/hed/libs/compute/JobInformationStorageBDB.cpp

  • Committer: Package Import Robot
  • Author(s): Mattias Ellert
  • Date: 2014-05-01 20:51:02 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20140501205102-icy9t3348uxobyx7
Tags: 4.1.0-1
* 4.1.0 Release
* Call dh_autoreconf to support ppc64le (Closes: #744639)

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
  }
43
43
  
44
44
  static void serialiseJob(const Job& j, Dbt& data) {
45
 
    const std::string version = "3.0.0";
46
 
    const unsigned nItems = 14;
 
45
    const std::string version = "3.0.1";
 
46
    const std::string empty_string;
47
47
    const std::string dataItems[] =
48
48
      {version, j.IDFromEndpoint, j.Name,
49
49
       j.JobStatusInterfaceName, j.JobStatusURL.fullstr(),
50
50
       j.JobManagementInterfaceName, j.JobManagementURL.fullstr(),
51
51
       j.ServiceInformationInterfaceName, j.ServiceInformationURL.fullstr(),
52
52
       j.SessionDir.fullstr(), j.StageInDir.fullstr(), j.StageOutDir.fullstr(),
53
 
       j.JobDescriptionDocument, tostring(j.LocalSubmissionTime.GetTime())};
 
53
       j.JobDescriptionDocument, tostring(j.LocalSubmissionTime.GetTime()),
 
54
       j.DelegationID.size()>0?*j.DelegationID.begin():empty_string};
 
55
    const unsigned nItems = sizeof(dataItems)/sizeof(dataItems[0]);
54
56
      
55
57
    data.set_data(NULL); data.set_size(0);
56
58
    uint32_t l = 0;
71
73
    
72
74
    std::string version;
73
75
    d = parse_string(version, d, size);
74
 
    if (version == "3.0.0") {
 
76
    if ((version == "3.0.0") || (version == "3.0.1")) {
75
77
      /* Order of items in record. Version 3.0.0
76
78
          {version, j.IDFromEndpoint, j.Name,
77
79
           j.JobStatusInterfaceName, j.JobStatusURL.fullstr(),
79
81
           j.ServiceInformationInterfaceName, j.ServiceInformationURL.fullstr(),
80
82
           j.SessionDir.fullstr(), j.StageInDir.fullstr(), j.StageOutDir.fullstr(),
81
83
           j.JobDescriptionDocument, tostring(j.LocalSubmissionTime.GetTime())};
 
84
         Version 3.0.1
 
85
           ..., j.DelegationID}
82
86
       */
83
87
      std::string s;
84
88
      d = parse_string(j.IDFromEndpoint, d, size);
94
98
      d = parse_string(s, d, size); j.StageOutDir = URL(s);
95
99
      d = parse_string(j.JobDescriptionDocument, d, size);
96
100
      d = parse_string(s, d, size); j.LocalSubmissionTime.SetTime(stringtoi(s));
 
101
      j.DelegationID.clear();
 
102
      if (version == "3.0.1") {
 
103
        d = parse_string(s, d, size);
 
104
        if(!s.empty()) j.DelegationID.push_back(s);
 
105
      }
97
106
    }
98
107
  }
99
108
  
106
115
    
107
116
    std::string version;
108
117
    d = parse_string(version, d, size);
109
 
    if (version == "3.0.0") {
 
118
    if ((version == "3.0.0") || (version == "3.0.1")) {
110
119
      for (unsigned i = 0; i < n-1; ++i) {
111
120
        d = parse_string(attr, d, size);
112
121
      }
161
170
    dbEnv = new DbEnv(DB_CXX_NO_EXCEPTIONS);
162
171
    dbEnv->set_errcall(&handleError);
163
172
 
164
 
    if ((ret = dbEnv->open(NULL, DB_CREATE | DB_INIT_CDB | DB_INIT_MPOOL, 0)) != 0) {
 
173
    if ((ret = dbEnv->open(Glib::get_tmp_dir().c_str(), DB_CREATE | DB_INIT_CDB | DB_INIT_MPOOL, 0)) != 0) {
165
174
      tearDown();
166
175
      throw BDBException(IString("Unable to create data base environment (%s)", name).str(), ret);
167
176
    }
184
193
      throw BDBException(IString("Unable to set duplicate flags for secondary key DB (%s)", name).str(), ret);
185
194
    }
186
195
 
187
 
    if ((ret = jobDB->open(NULL, name.c_str(), "job_records", type, flags, 0)) != 0) {
 
196
    std::string absPathToDB = URL(name).Path();
 
197
    if ((ret = jobDB->open(NULL, absPathToDB.c_str(), "job_records", type, flags, 0)) != 0) {
188
198
      tearDown();
189
199
      throw BDBException(IString("Unable to create job database (%s)", name).str(), ret);
190
200
    }
191
 
    if ((ret = nameSecondaryKeyDB->open(NULL, name.c_str(), "name_keys", type, flags, 0)) != 0) {
 
201
    if ((ret = nameSecondaryKeyDB->open(NULL, absPathToDB.c_str(), "name_keys", type, flags, 0)) != 0) {
192
202
      tearDown();
193
203
      throw BDBException(IString("Unable to create DB for secondary name keys (%s)", name).str(), ret);
194
204
    }
195
 
    if ((ret = endpointSecondaryKeyDB->open(NULL, name.c_str(), "endpoint_keys", type, flags, 0)) != 0) {
 
205
    if ((ret = endpointSecondaryKeyDB->open(NULL, absPathToDB.c_str(), "endpoint_keys", type, flags, 0)) != 0) {
196
206
      tearDown();
197
207
      throw BDBException(IString("Unable to create DB for secondary endpoint keys (%s)", name).str(), ret);
198
208
    }
199
 
    if ((ret = serviceInfoSecondaryKeyDB->open(NULL, name.c_str(), "serviceinfo_keys", type, flags, 0)) != 0) {
 
209
    if ((ret = serviceInfoSecondaryKeyDB->open(NULL, absPathToDB.c_str(), "serviceinfo_keys", type, flags, 0)) != 0) {
200
210
      tearDown();
201
211
      throw BDBException(IString("Unable to create DB for secondary service info keys (%s)", name).str(), ret);
202
212
    }
241
251
    delete dbEnv; dbEnv = NULL;
242
252
 
243
253
    dbEnv = new DbEnv(DB_CXX_NO_EXCEPTIONS);
244
 
    dbEnv->remove(NULL, 0);
 
254
    dbEnv->remove(Glib::get_tmp_dir().c_str(), 0);
245
255
    delete dbEnv; dbEnv = NULL;
246
256
  }
247
257
 
249
259
    tearDown();
250
260
  }
251
261
 
 
262
#if ((DB_VERSION_MAJOR > 4)||(DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3))
252
263
  void JobInformationStorageBDB::JobDB::handleError(const DbEnv *dbenv, const char *errpfx, const char *msg) {
 
264
#else
 
265
  void JobInformationStorageBDB::JobDB::handleError(const char *errpfx, char *msg) {
 
266
#endif
253
267
    if (errpfx) {
254
268
      JobInformationStorageBDB::logger.msg(DEBUG, "Error from BDB: %s: %s", errpfx, msg);
255
269
    }