Skip to content

Commit ae469ac

Browse files
knopers8Barthelemy
authored andcommitted
Dummy database (#258)
It does nothing. It is to avoid writing large amounts of data to QCDB during benchmarks.
1 parent 0a8fbe9 commit ae469ac

6 files changed

Lines changed: 121 additions & 1 deletion

File tree

Framework/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ add_library(QualityControl
5656
src/PostProcessingRunner.cxx
5757
src/PostProcessingFactory.cxx
5858
src/PostProcessingConfig.cxx
59-
src/PostProcessingInterface.cxx)
59+
src/PostProcessingInterface.cxx
60+
src/DummyDatabase.cxx)
6061

6162
if(ENABLE_MYSQL)
6263
target_sources(QualityControl PRIVATE src/MySqlDatabase.cxx)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
11+
///
12+
/// \file DummyDatabase.h
13+
/// \author Piotr Konopka
14+
///
15+
16+
#ifndef QC_REPOSITORY_DUMMYDATABASE_H
17+
#define QC_REPOSITORY_DUMMYDATABASE_H
18+
19+
#include "QualityControl/DatabaseInterface.h"
20+
21+
namespace o2::quality_control::repository
22+
{
23+
24+
/// \brief Dummy database which does nothing. Use it to avoid writing to QC repository.
25+
class DummyDatabase : public DatabaseInterface
26+
{
27+
public:
28+
DummyDatabase() = default;
29+
virtual ~DummyDatabase() = default;
30+
31+
void connect(std::string host, std::string database, std::string username, std::string password) override;
32+
void connect(const std::unordered_map<std::string, std::string>& config) override;
33+
void store(std::shared_ptr<o2::quality_control::core::MonitorObject> mo) override;
34+
core::MonitorObject* retrieve(std::string path, std::string objectName, long timestamp = 0) override;
35+
std::string retrieveJson(std::string path, std::string objectName) override;
36+
void disconnect() override;
37+
void prepareTaskDataContainer(std::string taskName) override;
38+
std::vector<std::string> getPublishedObjectNames(std::string taskName) override;
39+
void truncate(std::string taskName, std::string objectName) override;
40+
41+
private:
42+
};
43+
44+
} // namespace o2::quality_control::repository
45+
46+
#endif // QC_REPOSITORY_DUMMYDATABASE_H

Framework/src/DatabaseFactory.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// O2
1919
#include <Common/Exceptions.h>
2020
// QC
21+
#include "QualityControl/DummyDatabase.h"
2122
#include "QualityControl/DatabaseFactory.h"
2223
#include "QualityControl/QcInfoLogger.h"
2324
#ifdef _WITH_MYSQL
@@ -45,6 +46,9 @@ std::unique_ptr<DatabaseInterface> DatabaseFactory::create(std::string name)
4546
// TODO check if CCDB installed
4647
QcInfoLogger::GetInstance() << "CCDB backend selected" << QcInfoLogger::endm;
4748
return std::make_unique<CcdbDatabase>();
49+
} else if (name == "Dummy") {
50+
QcInfoLogger::GetInstance() << "Dummy backend selected, MonitorObjects will not be stored nor retrieved" << QcInfoLogger::endm;
51+
return std::make_unique<DummyDatabase>();
4852
} else {
4953
BOOST_THROW_EXCEPTION(FatalException() << errinfo_details("No database named " + name));
5054
}

Framework/src/DummyDatabase.cxx

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
11+
///
12+
/// \file DummyDatabase.cxx
13+
/// \author Piotr Konopka
14+
///
15+
16+
#include "QualityControl/DummyDatabase.h"
17+
18+
namespace o2::quality_control::repository
19+
{
20+
21+
void DummyDatabase::connect(std::string, std::string, std::string, std::string)
22+
{
23+
}
24+
25+
void DummyDatabase::connect(const std::unordered_map<std::string, std::string>&)
26+
{
27+
}
28+
29+
void DummyDatabase::store(std::shared_ptr<o2::quality_control::core::MonitorObject>)
30+
{
31+
}
32+
33+
core::MonitorObject* DummyDatabase::retrieve(std::string, std::string, long)
34+
{
35+
return nullptr;
36+
}
37+
38+
std::string DummyDatabase::retrieveJson(std::string, std::string)
39+
{
40+
return std::string();
41+
}
42+
43+
void DummyDatabase::disconnect()
44+
{
45+
}
46+
47+
void DummyDatabase::prepareTaskDataContainer(std::string)
48+
{
49+
}
50+
51+
std::vector<std::string> DummyDatabase::getPublishedObjectNames(std::string)
52+
{
53+
return std::vector<std::string>();
54+
}
55+
56+
void DummyDatabase::truncate(std::string, std::string)
57+
{
58+
}
59+
60+
} // namespace o2::quality_control::repository

Framework/test/testDbFactory.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
//#include <cassert>
2929
//#include <iostream>
3030

31+
#include <QualityControl/DummyDatabase.h>
3132
#include <QualityControl/CcdbDatabase.h>
3233
#include <QualityControl/MonitorObject.h>
3334
#include <TH1F.h>
@@ -58,6 +59,10 @@ BOOST_AUTO_TEST_CASE(db_factory_test)
5859
std::unique_ptr<DatabaseInterface> database3 = DatabaseFactory::create("CCDB");
5960
BOOST_CHECK(database3);
6061
BOOST_CHECK(dynamic_cast<CcdbDatabase*>(database3.get()));
62+
63+
std::unique_ptr<DatabaseInterface> database4 = DatabaseFactory::create("Dummy");
64+
BOOST_CHECK(database4);
65+
BOOST_CHECK(dynamic_cast<DummyDatabase*>(database4.get()));
6166
}
6267

6368
BOOST_AUTO_TEST_CASE(db_ccdb_listing)

doc/DevelopersTips.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ When we don't see the monitoring data in grafana, here is what to do to pinpoint
4040
5. `select count(*) from cpuUsedPercentage` <-- use the correct metrics name
4141
6. Repeat the last command and see if the number increases. If it increases it denotes that the metrics is stored correctly in the database. If it is the case, the problem lies in your grafana.
4242

43+
### Avoid writing QC objects to a repository
44+
45+
In case of a need to avoid writing QC objects to a repository, one can choose the "Dummy" database implementation in the config file. This is might be useful when one expects very large amounts of data that would be stored, but not actually needed (e.g. benchmarks).
46+
4347
### QCG
4448

4549
#### Generalities

0 commit comments

Comments
 (0)