QualityControl  1.5.1
O2 Data Quality Control Framework
CcdbDatabase.h
Go to the documentation of this file.
1 // Copyright CERN and copyright holders of ALICE O2. This software is
2 // distributed under the terms of the GNU General Public License v3 (GPL
3 // Version 3), copied verbatim in the file "COPYING".
4 //
5 // See http://alice-o2.web.cern.ch/license for full licensing information.
6 //
7 // In applying this license CERN does not waive the privileges and immunities
8 // granted to it by virtue of its status as an Intergovernmental Organization
9 // or submit itself to any jurisdiction.
10 
15 
16 #ifndef QC_REPOSITORY_CCDBDATABASE_H
17 #define QC_REPOSITORY_CCDBDATABASE_H
18 
19 #include <CCDB/CcdbApi.h>
20 
22 
24 {
25 
26 /*
27  * Notes (also concerning the underlying CcdbApi)
28  * - having 1 file per object per version server-side might lead to a tremendous number of files.
29  * --> they are aware of it
30  * - how to add a new filter ? such as expert/shifter flag
31  * --> new metadata
32  * - what are those time intervals ? what does it mean for us ?
33  * --> epoch milliseconds as long values
34  * - how to know the real time at which the object was stored ?
35  * --> new api should allow for it. To be confirmed.
36  * - we rather have a task_name/X/Y/Z/object_name/.../time where X/Y/Z are actually part of object_name but happen to
37  * have slashes, to build a hierarchy of objects
38  * --> we can.
39  * - we need to have a way to query for all objects in a certain path, e.g. in "task_name/X/Y" or in "task_name"
40  * --> the new api should allow it. To be tested.
41  * - when retrieving an object, despite what the usage menu says, the time can't be omitted.
42  * --> doc has been udpated.
43  * - initial tests show that it seems pretty slow.
44  * --> ok on their server with the new metadata database (postgresql)
45  * - Current path to objects : .../task/object with object possibly a slash separated subpath (up to 6 levels). Also
46  * consider having a task name such as "TPC/Task1" such as to build a tree of tasks with subsystems prefix.
47  *
48  */
49 
51 {
52  public:
53  CcdbDatabase() = default;
54  virtual ~CcdbDatabase();
55 
56  void connect(std::string host, std::string database, std::string username, std::string password) override;
57  void connect(const std::unordered_map<std::string, std::string>& config) override;
58 
59  // storage
60  void storeMO(std::shared_ptr<const o2::quality_control::core::MonitorObject> q, long from = -1, long to = -1) override;
61  void storeQO(std::shared_ptr<const o2::quality_control::core::QualityObject> q, long from = -1, long to = -1) override;
62 
63  // retrieval - MO - deprecated
64  std::shared_ptr<o2::quality_control::core::MonitorObject> retrieveMO(std::string taskName, std::string objectName, long timestamp = -1) override;
65  std::string retrieveMOJson(std::string taskName, std::string objectName, long timestamp = -1) override;
66 
67  // retrieval - QO - deprecated
68  std::shared_ptr<o2::quality_control::core::QualityObject> retrieveQO(std::string qoPath, long timestamp = -1) override;
69  std::string retrieveQOJson(std::string qoPath, long timestamp = -1) override;
70 
71  // retrieval - general
72  std::string retrieveJson(std::string path, long timestamp, const std::map<std::string, std::string>& metadata) override;
73  TObject* retrieveTObject(std::string path, const std::map<std::string, std::string>& metadata, long timestamp = -1, std::map<std::string, std::string>* headers = nullptr) override;
74 
75  void disconnect() override;
76  void prepareTaskDataContainer(std::string taskName) override;
77  std::vector<std::string> getPublishedObjectNames(std::string taskName) override;
78  void truncate(std::string taskName, std::string objectName) override;
79  void storeStreamerInfosToFile(std::string filename);
80  static long getCurrentTimestamp();
81  static long getFutureTimestamp(int secondsInFuture);
87  std::vector<std::string> getListing(std::string subpath = "");
88 
89  private:
96  static void loadDeprecatedStreamerInfos();
97  void init();
98 
105  std::string getListingAsString(std::string subpath = "", std::string accept = "text/plain");
106  o2::ccdb::CcdbApi ccdbApi;
107  std::string mUrl = "";
108 };
109 
110 } // namespace o2::quality_control::repository
111 
112 #endif // QC_REPOSITORY_CCDBDATABASE_H
std::string retrieveJson(std::string path, long timestamp, const std::map< std::string, std::string > &metadata) override
Look up an object and return it in JSON format. Look up an object and return it in JSON format if fou...
Definition: CcdbDatabase.cxx:260
std::shared_ptr< o2::quality_control::core::MonitorObject > retrieveMO(std::string taskName, std::string objectName, long timestamp=-1) override
Look up a monitor object and return it. Look up a monitor object and return it if found or nullptr if...
Definition: CcdbDatabase.cxx:195
Definition: AggregatorRunner.h:59
std::shared_ptr< o2::quality_control::core::QualityObject > retrieveQO(std::string qoPath, long timestamp=-1) override
Look up a quality object and return it. Look up a quality object and return it if found or nullptr if...
Definition: CcdbDatabase.cxx:232
std::vector< std::string > getListing(std::string subpath="")
Definition: CcdbDatabase.cxx:342
The interface to the MonitorObject&#39;s repository.
Definition: DatabaseInterface.h:35
void prepareTaskDataContainer(std::string taskName) override
Prepare the container, such as a table in a relational database, that will contain the MonitorObject&#39;...
Definition: CcdbDatabase.cxx:316
void storeMO(std::shared_ptr< const o2::quality_control::core::MonitorObject > q, long from=-1, long to=-1) override
Definition: CcdbDatabase.cxx:110
void connect(std::string host, std::string database, std::string username, std::string password) override
Definition: CcdbDatabase.cxx:91
std::string retrieveQOJson(std::string qoPath, long timestamp=-1) override
Look up a quality object and return it in JSON format. Look up a quality object and return it in JSON...
Definition: CcdbDatabase.cxx:247
TObject * retrieveTObject(std::string path, const std::map< std::string, std::string > &metadata, long timestamp=-1, std::map< std::string, std::string > *headers=nullptr) override
Look up an object and return it. Look up an object and return it if found or nullptr if not...
Definition: CcdbDatabase.cxx:179
void truncate(std::string taskName, std::string objectName) override
Definition: CcdbDatabase.cxx:402
void storeQO(std::shared_ptr< const o2::quality_control::core::QualityObject > q, long from=-1, long to=-1) override
Definition: CcdbDatabase.cxx:151
std::string retrieveMOJson(std::string taskName, std::string objectName, long timestamp=-1) override
Look up a monitor object and return it in JSON format. Look up a monitor object and return it in JSON...
Definition: CcdbDatabase.cxx:253