QualityControl  1.5.1
O2 Data Quality Control Framework
MySqlDatabase.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_MYSQLDATABASE_H
17 #define QC_REPOSITORY_MYSQLDATABASE_H
18 
19 #include <Common/Timer.h>
20 
22 
23 class TMySQLResult;
24 class TMySQLServer;
25 
27 {
28 
33 {
34  public:
36  MySqlDatabase();
38  ~MySqlDatabase() override;
39 
40  void connect(std::string host, std::string database, std::string username, std::string password) override;
41  void connect(const std::unordered_map<std::string, std::string>& config) override;
42  // MonitorObject
43  void storeMO(std::shared_ptr<const o2::quality_control::core::MonitorObject> mo, long from, long to) override;
44  std::shared_ptr<o2::quality_control::core::MonitorObject> retrieveMO(std::string taskName, std::string objectName, long timestamp = -1) override;
45  std::string retrieveMOJson(std::string taskName, std::string objectName, long timestamp = -1) override;
46  // QualityObject
47  void storeQO(std::shared_ptr<const o2::quality_control::core::QualityObject> q, long from, long to) override;
48  std::shared_ptr<o2::quality_control::core::QualityObject> retrieveQO(std::string qoPath, long timestamp = -1) override;
49  std::string retrieveQOJson(std::string qoPath, long timestamp = -1) override;
50  // General
51  std::string retrieveJson(std::string path, long timestamp, const std::map<std::string, std::string>& metadata) override;
52  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;
53 
54  void disconnect() override;
55  std::vector<std::string> getPublishedObjectNames(std::string taskName) override;
56  std::vector<std::string> getListOfTasksWithPublications();
57  void truncate(std::string taskName, std::string objectName) override;
58 
59  private:
64  TMySQLResult* query(std::string sql);
65 
70  bool execute(std::string sql);
71 
76  void addIndex(std::string table, std::string column);
77 
78  void prepareTaskDataContainer(std::string taskName) override;
79  void prepareTable(std::string table_name);
80 
81  void storeQueue();
82  void storeForMonitorObject(std::string taskName);
83  void storeForQualityObject(std::string checkName);
84 
85  TMySQLServer* mServer;
86 
87  // Queue
88  // name of tasks -> vector of mo
89  std::map<std::string, std::vector<std::shared_ptr<const o2::quality_control::core::QualityObject>>> mQualityObjectsQueue;
90  std::map<std::string, std::vector<std::shared_ptr<const o2::quality_control::core::MonitorObject>>> mMonitorObjectsQueue;
91  size_t queueSize;
92  AliceO2::Common::Timer lastStorage;
93 };
94 
95 } // namespace o2::quality_control::repository
96 
97 #endif // QC_REPOSITORY_MYSQLDATABASE_H
Definition: AggregatorRunner.h:59
Implementation of the DatabaseInterface for MySQL.
Definition: MySqlDatabase.h:32
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: MySqlDatabase.cxx:235
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: MySqlDatabase.cxx:466
MySqlDatabase()
Default constructor.
Definition: MySqlDatabase.cxx:38
~MySqlDatabase() override
Destructor.
Definition: MySqlDatabase.cxx:40
The interface to the MonitorObject&#39;s repository.
Definition: DatabaseInterface.h:35
void storeMO(std::shared_ptr< const o2::quality_control::core::MonitorObject > mo, long from, long to) override
Definition: MySqlDatabase.cxx:106
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: MySqlDatabase.cxx:355
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: MySqlDatabase.cxx:290
void truncate(std::string taskName, std::string objectName) override
Definition: MySqlDatabase.cxx:449
void storeQO(std::shared_ptr< const o2::quality_control::core::QualityObject > q, long from, long to) override
Definition: MySqlDatabase.cxx:95
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: MySqlDatabase.cxx:300
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: MySqlDatabase.cxx:461
void connect(std::string host, std::string database, std::string username, std::string password) override
Definition: MySqlDatabase.cxx:42