Skip to content

Commit 043f167

Browse files
authored
[QC-1275] Remove ServiceDiscovery (#2536)
* [QC-1275] Remove ServiceDiscovery # Conflicts: # Framework/src/ServiceDiscovery.cxx * Update PostProcessingRunner.h
1 parent 3e9e5f9 commit 043f167

19 files changed

+25
-447
lines changed

Framework/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ add_library(O2QualityControl
9999
src/Check.cxx
100100
src/Aggregator.cxx
101101
src/HashDataDescription.cxx
102-
src/ServiceDiscovery.cxx
103102
src/Triggers.cxx
104103
src/TriggerHelpers.cxx
105104
src/PostProcessingRunner.cxx

Framework/include/QualityControl/AggregatorRunner.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ class ConfigurationInterface;
5151

5252
namespace o2::quality_control
5353
{
54-
namespace core
55-
{
56-
class ServiceDiscovery;
57-
}
5854
namespace checker
5955
{
6056
class Aggregator;
@@ -150,7 +146,6 @@ class AggregatorRunner : public framework::Task
150146

151147
void initDatabase();
152148
void initMonitoring();
153-
void initServiceDiscovery();
154149
void initLibraries();
155150
void initAggregators();
156151

@@ -203,9 +198,6 @@ class AggregatorRunner : public framework::Task
203198
int mTotalNumberObjectsReceived;
204199
int mTotalNumberAggregatorExecuted;
205200
int mTotalNumberObjectsProduced;
206-
207-
// Service discovery
208-
std::shared_ptr<core::ServiceDiscovery> mServiceDiscovery;
209201
};
210202

211203
} // namespace o2::quality_control::checker

Framework/include/QualityControl/ObjectsManager.h

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@
2323
#include "QualityControl/MonitorObjectCollection.h"
2424
#include <Mergers/Mergeable.h>
2525
// stl
26-
#include <concepts>
2726
#include <string>
28-
#include <memory>
29-
#include <type_traits>
3027

3128
class TObject;
3229

@@ -49,8 +46,6 @@ enum class PublicationPolicy {
4946
Forever
5047
};
5148

52-
class ServiceDiscovery;
53-
5449
/// \brief Keeps the list of encapsulated objects to publish and does the actual publication.
5550
///
5651
/// Keeps a list of the objects to publish, encapsulates them and does the actual publication.
@@ -69,7 +64,7 @@ class ObjectsManager
6964
* @param parallelTaskID ID of a parallel Task, use 0 if there is only one.
7065
* @param noDiscovery If true disables the use of ServiceDiscovery
7166
*/
72-
ObjectsManager(std::string taskName, std::string taskClass, std::string detectorName, std::string consulUrl, int parallelTaskID = 0, bool noDiscovery = false);
67+
ObjectsManager(std::string taskName, std::string taskClass, std::string detectorName, int parallelTaskID = 0);
7368
virtual ~ObjectsManager();
7469

7570
static const std::string gDrawOptionsKey;
@@ -202,19 +197,6 @@ class ObjectsManager
202197
*/
203198
MonitorObject* getMonitorObject(size_t index);
204199

205-
/**
206-
* \brief Update the list of objects stored in the Service Discovery.
207-
* Update the list of objects stored in the Service Discovery.
208-
*/
209-
void updateServiceDiscovery();
210-
211-
/**
212-
* \brief Remove all objects from the ServiceDiscovery.
213-
* Remove all objects from the ServiceDiscovery even though they still might be published by the task.
214-
* This is typically used at End of Activity.
215-
*/
216-
void removeAllFromServiceDiscovery();
217-
218200
/**
219201
* \brief Sets the validity interval of all registered objects.
220202
*/
@@ -237,8 +219,6 @@ class ObjectsManager
237219
std::string mTaskName;
238220
std::string mTaskClass;
239221
std::string mDetectorName;
240-
std::unique_ptr<ServiceDiscovery> mServiceDiscovery;
241-
bool mUpdateServiceDiscovery;
242222
Activity mActivity;
243223
std::vector<std::string> mMovingWindowsList;
244224

Framework/include/QualityControl/PostProcessingRunner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
#include <memory>
2121
#include <functional>
22-
#include <Framework/ServiceRegistryRef.h>
2322
#include <boost/property_tree/ptree_fwd.hpp>
23+
#include <Framework/ServiceRegistryRef.h>
2424
#include "QualityControl/PostProcessingConfig.h"
2525
#include "QualityControl/PostProcessingInterface.h"
2626
#include "QualityControl/PostProcessingRunnerConfig.h"

Framework/include/QualityControl/ServiceDiscovery.h

Lines changed: 0 additions & 87 deletions
This file was deleted.

Framework/src/AggregatorRunner.cxx

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
// QC
3434
#include "QualityControl/DatabaseFactory.h"
3535
#include "QualityControl/QcInfoLogger.h"
36-
#include "QualityControl/ServiceDiscovery.h"
3736
#include "QualityControl/Aggregator.h"
3837
#include "QualityControl/runnerUtils.h"
3938
#include "QualityControl/InfrastructureSpecReader.h"
@@ -73,9 +72,6 @@ AggregatorRunner::AggregatorRunner(AggregatorRunnerConfig arc, const std::vector
7372
AggregatorRunner::~AggregatorRunner()
7473
{
7574
ILOG(Debug, Trace) << "AggregatorRunner destructor (" << this << ")" << ENDM;
76-
if (mServiceDiscovery != nullptr) {
77-
mServiceDiscovery->deregister();
78-
}
7975
}
8076

8177
void AggregatorRunner::prepareInputs()
@@ -127,7 +123,6 @@ void AggregatorRunner::init(framework::InitContext& iCtx)
127123
}
128124
initDatabase();
129125
initMonitoring();
130-
initServiceDiscovery();
131126
initAggregators();
132127
} catch (...) {
133128
ILOG(Fatal) << "Unexpected exception during initialization: "
@@ -253,18 +248,6 @@ void AggregatorRunner::initMonitoring()
253248
mTimer.reset(1000000); // 10 s.
254249
}
255250

256-
void AggregatorRunner::initServiceDiscovery()
257-
{
258-
auto consulUrl = mRunnerConfig.consulUrl;
259-
if (consulUrl.empty()) {
260-
mServiceDiscovery = nullptr;
261-
ILOG(Warning, Support) << "Service Discovery disabled" << ENDM;
262-
return;
263-
}
264-
mServiceDiscovery = std::make_shared<ServiceDiscovery>(consulUrl, mDeviceName, mDeviceName);
265-
ILOG(Info, Devel) << "ServiceDiscovery initialized";
266-
}
267-
268251
void AggregatorRunner::initAggregators()
269252
{
270253
ILOG(Info, Devel) << "Initialization of the aggregators" << ENDM;

Framework/src/CheckRunner.cxx

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,12 @@
2929
#include <utility>
3030
// QC
3131
#include "QualityControl/DatabaseFactory.h"
32-
#include "QualityControl/ServiceDiscovery.h"
3332
#include "QualityControl/runnerUtils.h"
3433
#include "QualityControl/InfrastructureSpecReader.h"
3534
#include "QualityControl/CheckRunnerFactory.h"
3635
#include "QualityControl/RootClassFactory.h"
3736
#include "QualityControl/ConfigParamGlo.h"
3837
#include "QualityControl/Bookkeeping.h"
39-
#include "QualityControl/WorkflowType.h"
4038

4139
#include <TSystem.h>
4240

@@ -164,9 +162,6 @@ CheckRunner::CheckRunner(CheckRunnerConfig checkRunnerConfig, InputSpec input)
164162
CheckRunner::~CheckRunner()
165163
{
166164
ILOG(Debug, Trace) << "CheckRunner destructor (" << this << ")" << ENDM;
167-
if (mServiceDiscovery != nullptr) {
168-
mServiceDiscovery->deregister();
169-
}
170165
}
171166

172167
void CheckRunner::init(framework::InitContext& iCtx)
@@ -176,7 +171,6 @@ void CheckRunner::init(framework::InitContext& iCtx)
176171
Bookkeeping::getInstance().init(mConfig.bookkeepingUrl);
177172
initDatabase();
178173
initMonitoring();
179-
initServiceDiscovery();
180174
initLibraries(); // we have to load libraries before we load ConfigurableParams, otherwise the corresponding ROOT dictionaries won't be found
181175

182176
if (!ConfigParamGlo::keyValues.empty()) {
@@ -413,7 +407,6 @@ void CheckRunner::updateServiceDiscovery(const QualityObjectsType& qualityObject
413407
objects += path + ",";
414408
}
415409
objects.pop_back(); // remove last comma
416-
mServiceDiscovery->_register(objects);
417410
}
418411

419412
void CheckRunner::initDatabase()
@@ -431,17 +424,6 @@ void CheckRunner::initMonitoring()
431424
mTimer.reset(10000000); // 10 s.
432425
}
433426

434-
void CheckRunner::initServiceDiscovery()
435-
{
436-
if (mConfig.consulUrl.empty()) {
437-
mServiceDiscovery = nullptr;
438-
ILOG(Warning, Support) << "Service Discovery disabled" << ENDM;
439-
return;
440-
}
441-
mServiceDiscovery = std::make_shared<ServiceDiscovery>(mConfig.consulUrl, mDeviceName, mDeviceName);
442-
ILOG(Info, Support) << "ServiceDiscovery initialized" << ENDM;
443-
}
444-
445427
void CheckRunner::initLibraries()
446428
{
447429
std::set<std::string> moduleNames;

Framework/src/ObjectsManager.cxx

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "QualityControl/ObjectsManager.h"
1818

1919
#include "QualityControl/QcInfoLogger.h"
20-
#include "QualityControl/ServiceDiscovery.h"
2120
#include "QualityControl/MonitorObjectCollection.h"
2221
#include <Common/Exceptions.h>
2322
#include <TObjArray.h>
@@ -36,23 +35,14 @@ namespace o2::quality_control::core
3635
const std::string ObjectsManager::gDrawOptionsKey = "drawOptions";
3736
const std::string ObjectsManager::gDisplayHintsKey = "displayHints";
3837

39-
ObjectsManager::ObjectsManager(std::string taskName, std::string taskClass, std::string detectorName, std::string consulUrl, int parallelTaskID, bool noDiscovery)
40-
: mTaskName(std::move(taskName)), mTaskClass(std::move(taskClass)), mDetectorName(std::move(detectorName)), mUpdateServiceDiscovery(false)
38+
ObjectsManager::ObjectsManager(std::string taskName, std::string taskClass, std::string detectorName, int parallelTaskID)
39+
: mTaskName(std::move(taskName)), mTaskClass(std::move(taskClass)), mDetectorName(std::move(detectorName))
4140
{
4241
mMonitorObjects = std::make_unique<MonitorObjectCollection>();
4342
mMonitorObjects->SetOwner(true);
4443
mMonitorObjects->SetName(mTaskName.c_str());
4544
mMonitorObjects->setDetector(mDetectorName);
4645
mMonitorObjects->setTaskName(mTaskName);
47-
48-
// register with the discovery service
49-
if (!noDiscovery && !consulUrl.empty()) {
50-
std::string uniqueTaskID = mTaskName + "_" + std::to_string(parallelTaskID);
51-
mServiceDiscovery = std::make_unique<ServiceDiscovery>(consulUrl, mTaskName, uniqueTaskID);
52-
} else {
53-
ILOG(Warning, Support) << "Service Discovery disabled" << ENDM;
54-
mServiceDiscovery = nullptr;
55-
}
5646
}
5747

5848
ObjectsManager::~ObjectsManager()
@@ -81,39 +71,9 @@ void ObjectsManager::startPublishingImpl(TObject* object, PublicationPolicy publ
8171
newObject->setActivity(mActivity);
8272
newObject->setCreateMovingWindow(std::find(mMovingWindowsList.begin(), mMovingWindowsList.end(), object->GetName()) != mMovingWindowsList.end());
8373
mMonitorObjects->Add(newObject);
84-
mUpdateServiceDiscovery = true;
8574
mPublicationPoliciesForMOs[newObject] = publicationPolicy;
8675
}
8776

88-
void ObjectsManager::updateServiceDiscovery()
89-
{
90-
if (!mUpdateServiceDiscovery || mServiceDiscovery == nullptr) {
91-
return;
92-
}
93-
// prepare the string of comma separated objects and publish it
94-
string objects;
95-
for (auto tobj : *mMonitorObjects) {
96-
auto* mo = dynamic_cast<MonitorObject*>(tobj);
97-
if (mo) {
98-
objects += mo->getPath() + ",";
99-
} else {
100-
ILOG(Error, Devel) << "ObjectsManager::updateServiceDiscovery : dynamic_cast returned nullptr." << ENDM;
101-
}
102-
}
103-
objects.pop_back();
104-
mServiceDiscovery->_register(objects);
105-
mUpdateServiceDiscovery = false;
106-
}
107-
108-
void ObjectsManager::removeAllFromServiceDiscovery()
109-
{
110-
if (mServiceDiscovery == nullptr) {
111-
return;
112-
}
113-
mServiceDiscovery->_register("");
114-
mUpdateServiceDiscovery = true;
115-
}
116-
11777
void ObjectsManager::stopPublishing(TObject* object)
11878
{
11979
if (!object) {
@@ -161,7 +121,6 @@ void ObjectsManager::stopPublishing(PublicationPolicy policy)
161121

162122
void ObjectsManager::stopPublishingAll()
163123
{
164-
removeAllFromServiceDiscovery();
165124
mMonitorObjects->Clear();
166125
mPublicationPoliciesForMOs.clear();
167126
}

Framework/src/PostProcessingRunner.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void PostProcessingRunner::init(const PostProcessingRunnerConfig& runnerConfig,
9494
mSourceDatabase = configureDatabase(mRunnerConfig.sourceDatabase, "Source");
9595
mDestinationDatabase = configureDatabase(mRunnerConfig.destinationDatabase, "Destination");
9696

97-
mObjectManager = std::make_shared<ObjectsManager>(mTaskConfig.taskName, mTaskConfig.className, mTaskConfig.detectorName, mRunnerConfig.consulUrl);
97+
mObjectManager = std::make_shared<ObjectsManager>(mTaskConfig.taskName, mTaskConfig.className, mTaskConfig.detectorName);
9898
mObjectManager->setActivity(mActivity);
9999
mServices.registerService<DatabaseInterface>(mSourceDatabase.get());
100100
if (mPublicationCallback == nullptr) {

0 commit comments

Comments
 (0)