ARC SDK
JobInformationStorageSQLite.h
1 // -*- indent-tabs-mode: nil -*-
2 
3 #ifndef __ARC_JOBINFORMATIONSTORAGESQLITE_H__
4 #define __ARC_JOBINFORMATIONSTORAGESQLITE_H__
5 
6 #include <sqlite3.h>
7 
8 #include "JobInformationStorage.h"
9 
10 namespace Arc {
11 
13  public:
14  JobInformationStorageSQLite(const std::string& name, unsigned nTries = 10, unsigned tryInterval = 500000);
15  virtual ~JobInformationStorageSQLite() {}
16 
17  static JobInformationStorage* Instance(const std::string& name) { return new JobInformationStorageSQLite(name); }
18 
19  bool ReadAll(std::list<Job>& jobs, const std::list<std::string>& rejectEndpoints = std::list<std::string>());
20  bool Read(std::list<Job>& jobs, std::list<std::string>& jobIdentifiers,
21  const std::list<std::string>& endpoints = std::list<std::string>(),
22  const std::list<std::string>& rejectEndpoints = std::list<std::string>());
23  bool Write(const std::list<Job>& jobs) { std::list<const Job*> newJobs; std::set<std::string> prunedServices; return Write(jobs, prunedServices, newJobs); }
24  bool Write(const std::list<Job>& jobs, const std::set<std::string>& prunedServices, std::list<const Job*>& newJobs);
25  bool Clean();
26  bool Remove(const std::list<std::string>& jobids);
27 
28  private:
29  static void logErrorMessage(int err);
30 
31  static Logger logger;
32 
33  class JobDB {
34  public:
35  JobDB(const std::string& name, bool create = false);
36 
37  ~JobDB();
38 
39  sqlite3* handle() { return jobDB; }
40 
41  private:
42  void tearDown();
43 
44  void handleError(const char* errpfx, int err);
45 
46  sqlite3* jobDB;
47 
48  };
49 
50  class SQLiteException {
51  public:
52  SQLiteException(const std::string& msg, int ret, bool writeLogMessage = true) throw();
53  ~SQLiteException() throw() {}
54  const std::string& getMessage() const throw() { return message; }
55  int getReturnValue() const throw() { return returnvalue; }
56 
57  private:
58  std::string message;
59  int returnvalue;
60  };
61  };
62 
63 } // namespace Arc
64 
65 #endif // __ARC_JOBINFORMATIONSTORAGESQLITE_H__
Arc namespace contains all core ARC classes.
Definition: ArcConfig.h:11
bool Write(const std::list< Job > &jobs)
Write jobs.
Definition: JobInformationStorageSQLite.h:23
A logger class.
Definition: Logger.h:493
Definition: JobInformationStorageSQLite.h:12
bool Clean()
Clean storage.
Abstract class for storing job information.
Definition: JobInformationStorage.h:31
bool ReadAll(std::list< Job > &jobs, const std::list< std::string > &rejectEndpoints=std::list< std::string >())
Read all jobs from storage.
bool Read(std::list< Job > &jobs, std::list< std::string > &jobIdentifiers, const std::list< std::string > &endpoints=std::list< std::string >(), const std::list< std::string > &rejectEndpoints=std::list< std::string >())
Read specified jobs.
bool Remove(const std::list< std::string > &jobids)
Remove jobs.