Skip to content

Commit 6f47deb

Browse files
authored
[QC-471] Do not create a Dispatcher if there are no policies (#4758)
1 parent 5b5d860 commit 6f47deb

4 files changed

Lines changed: 8 additions & 1 deletion

File tree

Utilities/DataSampling/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ std::vector<DataProcessorSpec> defineDataProcessing(ConfigContext &ctx)
6161
```
6262
6363
Sampled data can be subscribed to by adding `InputSpecs` provided by `std::vector<InputSpec> DataSampling::InputSpecsForPolicy(const std::string& policiesSource, const std::string& policyName)` to a chosen data processor. Then, they can be accessed by the bindings specified in the configuration file. Dispatcher adds a `DataSamplingHeader` to the header stack, which contains statistics like total number of evaluated/accepted messages for a given Policy or the sampling time since epoch.
64+
If no sampling policies are specified, Dispatcher will not be spawned.
6465
6566
The [o2-datasampling-pod-and-root](https://github.com/AliceO2Group/AliceO2/blob/dev/Utilities/DataSampling/test/dataSamplingPodAndRoot.cxx) workflow can serve as a usage example.
6667

Utilities/DataSampling/include/DataSampling/Dispatcher.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class Dispatcher : public framework::Task
5252

5353
/// \brief Register a Data Sampling Policy
5454
void registerPolicy(std::unique_ptr<DataSamplingPolicy>&&);
55+
/// \brief Returns the number of registered policies.
56+
size_t numberOfPolicies();
5557

5658
const std::string& getName();
5759
/// \brief Assembles InputSpecs of all registered policies in a single vector, removing overlapping entries.

Utilities/DataSampling/src/DataSampling.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void DataSampling::DoGenerateInfrastructure(Dispatcher& dispatcher, WorkflowSpec
7575
}
7676
}
7777

78-
if (dispatcher.getInputSpecs().size() > 0) {
78+
if (dispatcher.numberOfPolicies() > 0) {
7979
DataProcessorSpec spec;
8080
spec.name = dispatcher.getName();
8181
spec.inputs = dispatcher.getInputSpecs();

Utilities/DataSampling/src/Dispatcher.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,5 +258,9 @@ framework::Options Dispatcher::getOptions()
258258

259259
return options;
260260
}
261+
size_t Dispatcher::numberOfPolicies()
262+
{
263+
return mPolicies.size();
264+
}
261265

262266
} // namespace o2::utilities

0 commit comments

Comments
 (0)