QualityControl  1.5.1
O2 Data Quality Control Framework
CheckRunner.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 
16 
17 #ifndef QC_CHECKER_CHECKRUNNER_H
18 #define QC_CHECKER_CHECKRUNNER_H
19 
20 // std & boost
21 #include <chrono>
22 #include <memory>
23 #include <string>
24 #include <map>
25 #include <vector>
26 #include <unordered_set>
27 // O2
28 #include <Common/Timer.h>
29 #include <Framework/Task.h>
30 #include <Headers/DataHeader.h>
31 #include <Monitoring/MonitoringFactory.h>
32 #include <Configuration/ConfigurationInterface.h>
33 #include <Framework/DataProcessorSpec.h>
34 // QC
39 #include "QualityControl/Check.h"
41 
43 {
44 class ServiceDiscovery;
45 }
46 
47 namespace o2::framework
48 {
49 struct InputSpec;
50 struct OutputSpec;
51 class DataAllocator;
52 } // namespace o2::framework
53 
54 namespace o2::monitoring
55 {
56 class Monitoring;
57 }
58 
59 class TClass;
60 
62 {
63 
73 class CheckRunner : public framework::Task
74 {
75  public:
77 
88  CheckRunner(std::vector<Check> checks, std::string configurationSource);
89 
99  CheckRunner(o2::framework::InputSpec input, std::string configurationSource);
100 
102  ~CheckRunner() override;
103 
105  void init(framework::InitContext& ctx) override;
106 
108  void run(framework::ProcessingContext& ctx) override;
109 
110  framework::Inputs getInputs() { return mInputs; };
111  framework::Outputs getOutputs() { return mOutputs; };
112 
113  void setTaskStoreSet(std::unordered_set<std::string> storeSet) { mInputStoreSet = storeSet; }
114  std::string getDeviceName() { return mDeviceName; };
115 
117  static o2::header::DataDescription createCheckRunnerDataDescription(const std::string taskName);
118  static o2::framework::Inputs createInputSpec(const std::string checkName, const std::string configSource);
119 
120  static std::string createCheckRunnerIdString() { return "QC-CHECK-RUNNER"; };
121  static std::string createCheckRunnerName(std::vector<Check> checks);
122  static std::string createSinkCheckRunnerName(o2::framework::InputSpec input);
123 
124  private:
135  QualityObjectsType check();
136 
142  void store(QualityObjectsType& qualityObjects);
143 
149  void store(std::vector<std::shared_ptr<MonitorObject>>& monitorObjects);
150 
154  void send(QualityObjectsType& qualityObjects, framework::DataAllocator& allocator);
155 
161  static o2::framework::Outputs collectOutputs(const std::vector<Check>& checks);
162 
163  inline void initDatabase();
164  inline void initMonitoring();
165  inline void initServiceDiscovery();
166 
171  void updateServiceDiscovery(const QualityObjectsType& qualityObjects);
172 
178  static std::size_t hash(std::string input_string);
179 
189  void prepareCacheData(framework::InputRecord& inputRecord);
193  void sendPeriodicMonitoring();
194 
195  // General state
196  std::string mDeviceName;
197  std::vector<Check> mChecks;
199  std::shared_ptr<o2::quality_control::repository::DatabaseInterface> mDatabase;
200  std::unordered_set<std::string> mInputStoreSet;
201  std::vector<std::shared_ptr<MonitorObject>> mMonitorObjectStoreVector;
202  std::shared_ptr<o2::configuration::ConfigurationInterface> mConfigFile;
203  UpdatePolicyManager updatePolicyManager;
204 
205  // DPL
206  o2::framework::Inputs mInputs;
207  o2::framework::Outputs mOutputs;
208 
209  // Checks cache
210  std::map<std::string, std::shared_ptr<MonitorObject>> mMonitorObjects;
211 
212  // Service discovery
213  std::shared_ptr<ServiceDiscovery> mServiceDiscovery;
214  std::unordered_set<std::string> mListAllQOPaths; // store the names of all the QOs the Checks have generated so far
215 
216  // monitoring
217  std::shared_ptr<o2::monitoring::Monitoring> mCollector;
218  int mTotalNumberObjectsReceived;
219  int mTotalNumberCheckExecuted;
220  int mTotalNumberQOStored;
221  int mTotalNumberMOStored;
222  AliceO2::Common::Timer mTimer;
223 };
224 
225 } // namespace o2::quality_control::checker
226 
227 #endif // QC_CHECKER_CHECKRUNNER_H
Information service for QC.
Definition: ServiceDiscovery.h:32
Definition: Aggregator.h:32
Definition: AggregatorRunner.h:34
Definition: AggregatorRunner.h:27
Definition: UpdatePolicyManager.h:86
These methods can be used to build a complex processing topology. It spawns 3 separate dummy processi...
Definition: Activity.h:19
The class in charge of running the checks on a MonitorObject.
Definition: CheckRunner.h:73
Singleton class that any class in the QC can use to log.
Definition: QcInfoLogger.h:41