Project
Loading...
Searching...
No Matches
DataSamplingPolicy.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#ifndef ALICEO2_DATASAMPLINGPOLICY_H
13#define ALICEO2_DATASAMPLINGPOLICY_H
14
19
20#include "Headers/DataHeader.h"
21#include "Framework/InputSpec.h"
22#include "Framework/Output.h"
26
27#include <boost/property_tree/ptree_fwd.hpp>
28
29namespace o2::utilities
30{
31
37{
38 private:
39 using PathVectorBase = std::vector<std::pair<framework::InputSpec, framework::OutputSpec>>;
40 class PathMap : public PathVectorBase
41 {
42 public:
43 PathMap() = default;
44 ~PathMap() = default;
45 const PathVectorBase::const_iterator find(const framework::ConcreteDataMatcher& input) const
46 {
47 return std::find_if(begin(), end(), [input](const auto& el) {
48 return framework::DataSpecUtils::match(el.first, input);
49 });
50 }
51 };
52
53 public:
55 static DataSamplingPolicy fromConfiguration(const boost::property_tree::ptree&);
56
58 DataSamplingPolicy(std::string name);
65
69 // void registerPolicy(framework::InputSpec&&, framework::OutputSpec&&);
71 void registerCondition(std::unique_ptr<DataSamplingCondition>&&);
73 void setFairMQOutputChannel(std::string);
74
78 bool decide(const o2::framework::DataRef&);
80 framework::Output prepareOutput(const framework::ConcreteDataMatcher& input, framework::Lifetime lifetime = framework::Lifetime::Timeframe) const;
81
82 const std::string& getName() const;
83 const PathMap& getPathMap() const;
84 // optional fairmq channel to send stuff outside of DPL
85 const std::string& getFairMQOutputChannel() const;
86 std::string getFairMQOutputChannelName() const;
87 uint32_t getTotalAcceptedMessages() const;
88 uint32_t getTotalEvaluatedMessages() const;
89 bool isActive() const;
90
92 static header::DataDescription createPolicyDataDescription(std::string policyName, size_t id);
93
94 private:
95 bool mActive = true;
96 std::string mName;
97 PathMap mPaths;
98 std::vector<std::unique_ptr<DataSamplingCondition>> mConditions;
99 std::string mFairMQOutputChannel;
100
101 // stats
102 uint32_t mTotalAcceptedMessages = 0;
103 uint32_t mTotalEvaluatedMessages = 0;
104};
105
106} // namespace o2::utilities
107
108#endif // ALICEO2_DATASAMPLINGPOLICY_H
A standarised data sampling condition, to decide if given data sample should be passed forward.
void setFairMQOutputChannel(std::string)
Sets a raw fair::mq::Channel. Deprecated, do not use.
static DataSamplingPolicy fromConfiguration(const boost::property_tree::ptree &)
Configures a policy using structured configuration entry.
~DataSamplingPolicy()=default
Destructor.
static header::DataDescription createPolicyDataDescription(std::string policyName, size_t id)
void registerPath(const framework::InputSpec &, const framework::OutputSpec &)
Adds a new association between inputs and outputs.
DataSamplingPolicy(DataSamplingPolicy &&)=default
Move constructor.
void registerCondition(std::unique_ptr< DataSamplingCondition > &&)
Adds a new association between inputs and outputs.
const framework::OutputSpec * match(const framework::ConcreteDataMatcher &input) const
Returns true if this policy requires data with given InputSpec.
static header::DataOrigin createPolicyDataOrigin()
const std::string & getFairMQOutputChannel() const
bool decide(const o2::framework::DataRef &)
Returns true if user-defined conditions of sampling are fulfilled.
const std::string & getName() const
DataSamplingPolicy & operator=(DataSamplingPolicy &&)=default
Move assignment.
framework::Output prepareOutput(const framework::ConcreteDataMatcher &input, framework::Lifetime lifetime=framework::Lifetime::Timeframe) const
Returns Output for given InputSpec to pass data forward.
GLuint GLuint end
Definition glcorearb.h:469
GLuint const GLchar * name
Definition glcorearb.h:781
Lifetime
Possible Lifetime of objects being exchanged by the DPL.
Definition Lifetime.h:18
A header which contains some meta-data generated by Data Sampling.
static bool match(InputSpec const &spec, ConcreteDataMatcher const &target)