DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
opmonlib
include
opmonlib
OpMonManager.hpp
Go to the documentation of this file.
1
8
9
#ifndef OPMONLIB_INCLUDE_OPMONLIB_OPMONMANAGER_HPP_
10
#define OPMONLIB_INCLUDE_OPMONLIB_OPMONMANAGER_HPP_
11
12
#include <cstddef>
13
#include <thread>
14
15
#include "
opmonlib/MonitorableObject.hpp
"
16
#include "
opmonlib/Utils.hpp
"
17
18
#include "
confmodel/OpMonConf.hpp
"
19
#include "
logging/Logging.hpp
"
// NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG<<issue wont work.
20
21
namespace
dunedaq
{
22
23
ERS_DECLARE_ISSUE
(
opmonlib
,
24
ThreadNameTooLong,
25
"The name "
<< name <<
" is too long for a thread name"
,
26
((std::string)name)
27
)
28
29
ERS_DECLARE_ISSUE
(
opmonlib
,
30
MonitoringThreadNotSet
,
31
"Monitoring thread not set"
,
32
ERS_EMPTY
)
33
34
ERS_DECLARE_ISSUE
(
opmonlib
,
35
FailedMonitoringThread,
36
"Monitoring thread failed to start"
,
37
ERS_EMPTY
)
38
39
ERS_DECLARE_ISSUE
(
opmonlib
,
40
MissingConfiguration
,
41
"Confiration is not set"
,
42
ERS_EMPTY
)
43
}
44
45
46
47
namespace
dunedaq
::
opmonlib
{
48
49
class
OpMonManager
:
protected
MonitorableObject
50
{
51
52
friend
class
TestOpMonManager
;
53
54
public
:
55
56
/*
57
* Construtor expected to be used for standard operations,
58
* yet, general developers should not concern themselves with this as the framework handles this for them
59
*/
60
explicit
OpMonManager
(std::string
session
,
61
std::string name,
62
std::string opmon_facility_uri =
"stdout"
) :
63
OpMonManager
(
session
, name,
makeOpMonFacility
(opmon_facility_uri,
make_origin
(
session
, name)) ){;}
64
65
virtual
~OpMonManager
() =
default
;
66
67
using
MonitorableObject::get_opmon_id
;
68
using
MonitorableObject::get_opmon_level
;
69
using
MonitorableObject::register_node
;
70
using
MonitorableObject::set_opmon_level
;
71
72
// data collecting loop
73
void
start_monitoring
();
74
// The stop command is not necessary, although it is provided to facilitate complex object behaviour
75
// The stop is invoked during the destruction of the thread
76
// the method requires a valid configuration because the time period is taken from there
77
78
void
stop_monitoring
();
79
// on top of stopping the monitorin thread, this method will also join the thread
80
81
void
set_opmon_conf
(
const
confmodel::OpMonConf
* c ) {
82
m_cfg
.store(c);
83
set_opmon_level
(
m_cfg
.load()->get_level() );
84
}
85
86
protected
:
87
using
MonitorableObject::collect
;
88
89
//obtain the opmon facility
90
auto
get_opmon_facility
()
const
{
return
m_facility
.load(); }
91
92
OpMonManager
(std::string
session
,
93
std::string name,
94
facility_ptr_t );
95
96
void
run
( std::stop_token );
// function used by the jthread
97
98
private
:
99
100
std::jthread
m_thread
;
101
std::atomic<const confmodel::OpMonConf*>
m_cfg
{
nullptr
};
102
103
};
104
105
106
}
// namespace dunedaq::opmonlib
107
108
#endif
// OPMONLIB_INCLUDE_OPMONLIB_OPMONMANAGER_HPP_
ERS_EMPTY
#define ERS_EMPTY
Definition
IssueDeclarationMacro.hpp:22
MonitorableObject.hpp
dunedaq::confmodel::OpMonConf
Definition
OpMonConf.hpp:24
dunedaq::opmonlib::MonitorableObject::get_opmon_level
auto get_opmon_level() const noexcept
Definition
MonitorableObject.hpp:95
dunedaq::opmonlib::MonitorableObject::collect
opmon::MonitoringTreeInfo collect() noexcept
Definition
MonitorableObject.cpp:101
dunedaq::opmonlib::MonitorableObject::get_opmon_id
auto get_opmon_id() const noexcept
Definition
MonitorableObject.hpp:93
dunedaq::opmonlib::MonitorableObject::set_opmon_level
void set_opmon_level(OpMonLevel) noexcept
Definition
MonitorableObject.cpp:180
dunedaq::opmonlib::MonitorableObject::m_facility
std::atomic< facility_ptr_t > m_facility
Definition
MonitorableObject.hpp:171
dunedaq::opmonlib::MonitorableObject::register_node
void register_node(ElementId name, NewNodePtr)
Definition
MonitorableObject.cpp:32
dunedaq::opmonlib::MonitorableObject::MonitorableObject
MonitorableObject(const MonitorableObject &)=delete
dunedaq::opmonlib::OpMonManager
Definition
OpMonManager.hpp:50
dunedaq::opmonlib::OpMonManager::m_cfg
std::atomic< const confmodel::OpMonConf * > m_cfg
Definition
OpMonManager.hpp:101
dunedaq::opmonlib::OpMonManager::TestOpMonManager
friend class TestOpMonManager
Definition
OpMonManager.hpp:52
dunedaq::opmonlib::OpMonManager::~OpMonManager
virtual ~OpMonManager()=default
dunedaq::opmonlib::OpMonManager::OpMonManager
OpMonManager(std::string session, std::string name, std::string opmon_facility_uri="stdout")
Definition
OpMonManager.hpp:60
dunedaq::opmonlib::OpMonManager::start_monitoring
void start_monitoring()
Definition
OpMonManager.cpp:25
dunedaq::opmonlib::OpMonManager::stop_monitoring
void stop_monitoring()
Definition
OpMonManager.cpp:43
dunedaq::opmonlib::OpMonManager::m_thread
std::jthread m_thread
Definition
OpMonManager.hpp:100
dunedaq::opmonlib::OpMonManager::get_opmon_facility
auto get_opmon_facility() const
Definition
OpMonManager.hpp:90
dunedaq::opmonlib::OpMonManager::set_opmon_conf
void set_opmon_conf(const confmodel::OpMonConf *c)
Definition
OpMonManager.hpp:81
OpMonConf.hpp
run
static volatile sig_atomic_t run
Definition
kafka_opmon_consumer.cxx:38
Logging.hpp
ERS_DECLARE_ISSUE
#define ERS_DECLARE_ISSUE( namespace_name, class_name, message_, attributes)
Definition
macro.hpp:65
dunedaq::opmonlib::makeOpMonFacility
std::shared_ptr< OpMonFacility > makeOpMonFacility(std::string const &facility, OptionalOrigin=OptionalOrigin())
Definition
OpMonFacility.cpp:14
dunedaq::opmonlib::make_origin
opmon::OpMonId make_origin(const std::string &session, const std::string &app)
Definition
Utils.cpp:12
dunedaq
Including Qt Headers.
Definition
module.cpp:16
dunedaq::MonitoringThreadNotSet
MonitoringThreadNotSet
Definition
OpMonManager.hpp:30
dunedaq::ERS_DECLARE_ISSUE
ERS_DECLARE_ISSUE(snbmodules, InvalidGroupTransferIDError, "InvalidGroupTransferIDError: Transfer ID "<< transfer_id<< " not found in "<< location,((std::string) transfer_id)((std::string) location)) ERS_DECLARE_ISSUE(snbmodules
dunedaq::MissingConfiguration
Monitoring thread not ERS_EMPTY MissingConfiguration
Definition
OpMonManager.hpp:40
opmonlib
Definition
__init__.py:1
session
Definition
session.py:1
Utils.hpp
Generated on
for DUNE-DAQ by
1.17.0