From b63b0726790d8fc3e3dacca1a277b34a55d77468 Mon Sep 17 00:00:00 2001 From: martinboulais <31805063+martinboulais@users.noreply.github.com> Date: Tue, 23 Apr 2024 07:04:29 +0200 Subject: [PATCH] [O2B-1010] Hide protobuf internals --- Framework/CMakeLists.txt | 2 +- .../include/QualityControl/Bookkeeping.h | 7 ++--- Framework/src/AggregatorRunner.cxx | 2 +- Framework/src/Bookkeeping.cxx | 30 ++++--------------- Framework/src/CheckRunner.cxx | 2 +- Framework/src/PostProcessingRunner.cxx | 2 +- Framework/src/TaskRunner.cxx | 4 +-- Framework/src/runBookkeepingBenchmark.cxx | 5 ++-- 8 files changed, 16 insertions(+), 38 deletions(-) diff --git a/Framework/CMakeLists.txt b/Framework/CMakeLists.txt index 15189abb34..47f114c8bb 100644 --- a/Framework/CMakeLists.txt +++ b/Framework/CMakeLists.txt @@ -25,7 +25,7 @@ target_link_libraries(O2QualityControlTypes ROOT::Hist AliceO2::Common O2::DataFormatsQualityControl - AliceO2::BookkeepingProtoApi + AliceO2::BookkeepingApi ) add_root_dictionary(O2QualityControlTypes diff --git a/Framework/include/QualityControl/Bookkeeping.h b/Framework/include/QualityControl/Bookkeeping.h index 40cbdda2ac..a3b4d41182 100644 --- a/Framework/include/QualityControl/Bookkeeping.h +++ b/Framework/include/QualityControl/Bookkeeping.h @@ -17,7 +17,7 @@ #define QC_CORE_BOOKKEEPING_H #include -#include "BookkeepingApi/BkpProtoClient.h" +#include "BookkeepingApi/BkpClient.h" namespace o2::quality_control::core { @@ -37,15 +37,14 @@ class Bookkeeping Bookkeeping(const Bookkeeping&) = delete; void init(const std::string& url); - void populateActivity(Activity& activity, size_t runNumber); - void registerProcess(int runNumber, const std::string& name, const std::string& detector, bookkeeping::DplProcessType type, const std::string& args); + void registerProcess(int runNumber, const std::string& name, const std::string& detector, bkp::DplProcessType type, const std::string& args); private: Bookkeeping() = default; bool mInitialized = false; std::string mUrl; - std::unique_ptr mClient; + std::unique_ptr mClient; }; } // namespace o2::quality_control::core diff --git a/Framework/src/AggregatorRunner.cxx b/Framework/src/AggregatorRunner.cxx index ad9292fed0..c4aa6de821 100644 --- a/Framework/src/AggregatorRunner.cxx +++ b/Framework/src/AggregatorRunner.cxx @@ -403,7 +403,7 @@ void AggregatorRunner::start(ServiceRegistryRef services) if (gSystem->Getenv("O2_QC_REGISTER_IN_BK")) { // until we are sure it works, we have to turn it on ILOG(Debug, Devel) << "Registering aggregator to BookKeeping" << ENDM; try { - Bookkeeping::getInstance().registerProcess(mActivity->mId, mDeviceName, AggregatorRunner::getDetectorName(mAggregators), bookkeeping::DPL_PROCESS_TYPE_QC_AGGREGATOR, ""); + Bookkeeping::getInstance().registerProcess(mActivity->mId, mDeviceName, AggregatorRunner::getDetectorName(mAggregators), bkp::DplProcessType::QC_AGGREGATOR, ""); } catch (std::runtime_error& error) { ILOG(Warning, Devel) << "Failed registration to the BookKeeping: " << error.what() << ENDM; } diff --git a/Framework/src/Bookkeeping.cxx b/Framework/src/Bookkeeping.cxx index 626f42de9a..65549b1a5a 100644 --- a/Framework/src/Bookkeeping.cxx +++ b/Framework/src/Bookkeeping.cxx @@ -17,11 +17,11 @@ #include "QualityControl/Bookkeeping.h" #include "QualityControl/QcInfoLogger.h" #include "QualityControl/Activity.h" -#include "BookkeepingApi/BkpProtoClientFactory.h" -#include "BookkeepingApi/BkpProtoClient.h" +#include "BookkeepingApi/BkpClientFactory.h" +#include "BookkeepingApi/BkpClient.h" #include -using namespace o2::bkp::api::proto; +using namespace o2::bkp::api; namespace o2::quality_control::core { @@ -43,7 +43,7 @@ void Bookkeeping::init(const std::string& url) } try { - mClient = BkpProtoClientFactory::create(url); + mClient = BkpClientFactory::create(url); } catch (std::runtime_error& error) { ILOG(Warning, Support) << "Error connecting to Bookkeeping: " << error.what() << ENDM; return; @@ -58,26 +58,6 @@ void Bookkeeping::init(const std::string& url) mInitialized = true; } -void Bookkeeping::populateActivity(Activity& activity, size_t runNumber) -{ - if (!mInitialized) { - return; - } - try { - auto bkRun = mClient->run()->Get(runNumber, { bookkeeping::RUN_RELATIONS_LHC_FILL }); - ILOG(Debug, Devel) << "Retrieved run info from Bookkeeping : " << bkRun->run().environmentid() << ", " << bkRun->run().runtype() << ENDM; - activity.mId = bkRun->run().runnumber(); - activity.mType = bkRun->run().runtype(); - activity.mPeriodName = bkRun->run().lhcperiod(); - activity.mValidity.setMin(bkRun->run().timeo2start()); - activity.mValidity.setMax(bkRun->run().timeo2end()); - activity.mBeamType = bkRun->lhcfill().beamtype(); - ILOG(Debug, Devel) << "activity created from run : " << activity << ENDM; - } catch (std::runtime_error& error) { - ILOG(Warning, Support) << "Error retrieving run info from Bookkeeping: " << error.what() << ENDM; - } -} - std::string getHostName() { char hostname[256]; @@ -88,7 +68,7 @@ std::string getHostName() } } -void Bookkeeping::registerProcess(int runNumber, const std::string& name, const std::string& detector, bookkeeping::DplProcessType type, const std::string& args) +void Bookkeeping::registerProcess(int runNumber, const std::string& name, const std::string& detector, bkp::DplProcessType type, const std::string& args) { if (!mInitialized) { return; diff --git a/Framework/src/CheckRunner.cxx b/Framework/src/CheckRunner.cxx index 00b8279404..62cad609c5 100644 --- a/Framework/src/CheckRunner.cxx +++ b/Framework/src/CheckRunner.cxx @@ -517,7 +517,7 @@ void CheckRunner::start(ServiceRegistryRef services) if (gSystem->Getenv("O2_QC_REGISTER_IN_BK")) { // until we are sure it works, we have to turn it on ILOG(Debug, Devel) << "Registering checkRunner to BookKeeping" << ENDM; try { - Bookkeeping::getInstance().registerProcess(mActivity->mId, mDeviceName, mDetectorName, bookkeeping::DPL_PROCESS_TYPE_QC_CHECKER, ""); + Bookkeeping::getInstance().registerProcess(mActivity->mId, mDeviceName, mDetectorName, bkp::DplProcessType::QC_CHECKER, ""); } catch (std::runtime_error& error) { ILOG(Warning, Devel) << "Failed registration to the BookKeeping: " << error.what() << ENDM; } diff --git a/Framework/src/PostProcessingRunner.cxx b/Framework/src/PostProcessingRunner.cxx index 1af940182a..9de1af3f07 100644 --- a/Framework/src/PostProcessingRunner.cxx +++ b/Framework/src/PostProcessingRunner.cxx @@ -183,7 +183,7 @@ void PostProcessingRunner::start(framework::ServiceRegistryRef dplServices) if (gSystem->Getenv("O2_QC_REGISTER_IN_BK")) { // until we are sure it works, we have to turn it on ILOG(Debug, Devel) << "Registering pp task to BookKeeping" << ENDM; try { - Bookkeeping::getInstance().registerProcess(mActivity.mId, mRunnerConfig.taskName, mRunnerConfig.detectorName, bookkeeping::DPL_PROCESS_TYPE_QC_POSTPROCESSING, ""); + Bookkeeping::getInstance().registerProcess(mActivity.mId, mRunnerConfig.taskName, mRunnerConfig.detectorName, bkp::DplProcessType::QC_POSTPROCESSING, ""); } catch (std::runtime_error& error) { ILOG(Warning, Devel) << "Failed registration to the BookKeeping: " << error.what() << ENDM; } diff --git a/Framework/src/TaskRunner.cxx b/Framework/src/TaskRunner.cxx index ed265f890a..8607ddd0ae 100644 --- a/Framework/src/TaskRunner.cxx +++ b/Framework/src/TaskRunner.cxx @@ -490,12 +490,12 @@ void TaskRunner::registerToBookkeeping() // register ourselves to the BK at the first cycle ILOG(Debug, Devel) << "Registering taskRunner to BookKeeping" << ENDM; try { - Bookkeeping::getInstance().registerProcess(mActivity.mId, mTaskConfig.taskName, mTaskConfig.detectorName, bookkeeping::DPL_PROCESS_TYPE_QC_TASK, ""); + Bookkeeping::getInstance().registerProcess(mActivity.mId, mTaskConfig.taskName, mTaskConfig.detectorName, bkp::DplProcessType::QC_TASK, ""); if (gSystem->Getenv("O2_QC_REGISTER_IN_BK_X_TIMES")) { ILOG(Debug, Devel) << "O2_QC_REGISTER_IN_BK_X_TIMES set to " << gSystem->Getenv("O2_QC_REGISTER_IN_BK_X_TIMES") << ENDM; int iterations = std::stoi(gSystem->Getenv("O2_QC_REGISTER_IN_BK_X_TIMES")); for (int i = 1; i < iterations; i++) { // start at 1 because we already did it once - Bookkeeping::getInstance().registerProcess(mActivity.mId, mTaskConfig.taskName, mTaskConfig.detectorName, bookkeeping::DPL_PROCESS_TYPE_QC_TASK, ""); + Bookkeeping::getInstance().registerProcess(mActivity.mId, mTaskConfig.taskName, mTaskConfig.detectorName, bkp::DplProcessType::QC_TASK, ""); } } } catch (std::runtime_error& error) { diff --git a/Framework/src/runBookkeepingBenchmark.cxx b/Framework/src/runBookkeepingBenchmark.cxx index 4faf2658a5..b0714b4b06 100644 --- a/Framework/src/runBookkeepingBenchmark.cxx +++ b/Framework/src/runBookkeepingBenchmark.cxx @@ -12,7 +12,7 @@ #include "QualityControl/Bookkeeping.h" #include #include -#include "BookkeepingApi/BkpProtoClientFactory.h" +#include "BookkeepingApi/BkpClientFactory.h" #include "QualityControl/Activity.h" #include #include "QualityControl/QcInfoLogger.h" @@ -20,7 +20,6 @@ using namespace std; namespace bpo = boost::program_options; using namespace o2::bkp::api; -using namespace o2::bkp::api::proto; using namespace o2::quality_control::core; /** @@ -74,7 +73,7 @@ int main(int argc, const char* argv[]) totalNumberOfExecutions++; triggerTimer.reset(minDelay * 1000); timer.reset(); - Bookkeeping::getInstance().populateActivity(activity, run); + Bookkeeping::getInstance().registerProcess(123, "asdf", "ITS", o2::bkp::DplProcessType::_NULL, ""); auto duration = timer.getTime(); if (printActivity) { cout << activity << endl;