21 m_num_of_slr_enabled_resources(0),
22 m_num_of_slr_disabled_resources(0)
24 TLOG_DEBUG(2) <<
"construct the object " << (
void *)
this ;
30 TLOG_DEBUG(2) <<
"destroy the object " << (
void *)
this ;
37 TLOG_DEBUG(2) <<
"reset session components because of notification callback on object " << (
void *)
this ;
44 TLOG_DEBUG(2) <<
"reset session components because of configuration load on object " << (
void *)
this ;
51 TLOG_DEBUG(2) <<
"reset session components because of configuration unload on object " << (
void *)
this ;
58 TLOG_DEBUG(2) <<
"reset session components because of configuration update (obj = " << obj <<
", name = \'" << name <<
"\') on object " << (
void *)
this ;
65 TLOG_DEBUG(2) <<
"reset disabled by explicit user call" ;
91 TLOG_DEBUG(6) <<
"disable segment " << seg <<
" because it's parent segment " << &segment <<
" is disabled" ;
102 for (
const auto& comp : objs) {
115 for (
const auto& i : objs) {
127 ReadMaxAllowedIterations,
129 "Has exceeded the maximum of iterations allowed (" << limit <<
") during calculation of disabled objects",
131 ((
unsigned int)limit)
141 std::vector<const ResourceSetOR *>& rs_or,
142 std::vector<const ResourceSetAND *>& rs_and,
148 rs_and.push_back(r1);
160 fill(*rs2, rs_or, rs_and, cd_fuse);
170 std::vector<const ResourceSetOR *>& rs_or,
171 std::vector<const ResourceSetAND *>& rs_and,
175 for (
auto & app : s.get_applications()) {
178 fill(*rs, rs_or, rs_and, cd_fuse);
182 for (
auto & seg : s.get_segments()) {
183 TLOG_DEBUG(6) <<
"Filling segment " << seg->UID();
185 fill(*seg, rs_or, rs_and, cd_fuse);
194 std::vector<const ResourceSetOR *>& rs_or,
195 std::vector<const ResourceSetAND *>& rs_and,
200 if (
const OnlineSegment * onlseg = p.get_OnlineInfrastructure())
203 fill(*onlseg, rs_or, rs_and, cd_fuse);
206 for (
auto &a : p.get_OnlineInfrastructureApplications())
210 fill(*rs, rs_or, rs_and, cd_fuse);
216 auto seg =
session.get_segment();
218 fill(*seg, rs_or, rs_and, cd_fuse);
229 if (
session.m_disabled_components.size() == 0) {
230 if (
session.get_disabled().empty() &&
231 session.m_disabled_components.m_user_disabled.empty()) {
232 TLOG_DEBUG( 6) <<
"Session has no disabled components";
239 std::vector<const ResourceSetOR *> rs_or;
240 std::vector<const ResourceSetAND *> rs_and;
245 std::vector<const Component *> vector_of_disabled;
246 vector_of_disabled.reserve(
session.get_disabled().size() +
session.m_disabled_components.m_user_disabled.size());
249 for (
auto & i :
session.m_disabled_components.m_user_disabled) {
250 vector_of_disabled.push_back(i);
251 TLOG_DEBUG(6) <<
"disable component " << i->UID() <<
" because it is explicitly disabled by user" ;
255 for (
auto & i :
session.get_disabled()) {
256 TLOG_DEBUG(6) <<
"check component " << i->UID() <<
" explicitly disabled in session" ;
258 if (
session.m_disabled_components.m_user_enabled.find(i) ==
session.m_disabled_components.m_user_enabled.end()) {
259 vector_of_disabled.push_back(i);
260 TLOG_DEBUG(6) <<
"disable component " << i->UID() <<
" because it is not explicitly enabled in session" ;
263 TLOG_DEBUG(6) <<
"skip component " << i->UID() <<
" because it is enabled by user" ;
268 for (
auto & i : vector_of_disabled) {
269 session.m_disabled_components.disable(*i);
272 session.m_disabled_components.disable_children(*rs);
275 TLOG_DEBUG(6) <<
"Disabling children of segment " << seg->UID();
276 session.m_disabled_components.disable_children(*seg);
281 for (
unsigned long count = 1;
true; ++count) {
282 const unsigned long num(
session.m_disabled_components.size());
284 TLOG_DEBUG(6) <<
"before auto-disabling iteration " << count <<
" the number of disabled components is " << num ;
286 TLOG_DEBUG(6) <<
"Session has " << rs_or.size() <<
" resourceSetORs";
287 for (
const auto& i : rs_or) {
288 if (
session.m_disabled_components.is_enabled(i)) {
290 TLOG_DEBUG(6) <<
"ResourceSetOR " << i->UID() <<
" contains " << i->get_contains().size() <<
" resources";
291 for (
auto & i2 : i->get_contains()) {
292 if (!
session.m_disabled_components.is_enabled(i2)) {
293 TLOG_DEBUG(6) <<
"disable resource-set-OR " << i->UID() <<
" because it's child " << i2 <<
" is disabled" ;
294 session.m_disabled_components.disable(*i);
295 session.m_disabled_components.disable_children(*i);
302 TLOG_DEBUG(6) <<
"Session has " << rs_and.size() <<
" resourceSetANDs";
303 for (
const auto& j : rs_and) {
304 if (
session.m_disabled_components.is_enabled(j)) {
305 const std::vector<const ResourceBase*> &resources = j->get_contains();
306 TLOG_DEBUG(6) <<
"Checking " << resources.size() <<
" ResourceSetAND resources";
307 if (!resources.empty()) {
309 bool found_enabled =
false;
310 for (
auto & j2 : resources) {
311 if (
session.m_disabled_components.is_enabled(j2)) {
312 found_enabled =
true;
313 TLOG_DEBUG(6) <<
"Found enabled resource " << j2->UID();
317 if (found_enabled ==
false) {
318 TLOG_DEBUG(6) <<
"disable resource-set-AND " << j->UID() <<
" because all it's children are disabled" ;
319 session.m_disabled_components.disable(*j);
320 session.m_disabled_components.disable_children(*j);
326 if (
session.m_disabled_components.size() == num) {
327 TLOG_DEBUG(6) <<
"after " << count <<
" iteration(s) auto-disabling algorithm found no newly disabled sets, exiting loop ..." ;
331 unsigned int iLimit(1000);
332 if (count > iLimit) {
340 bool result(!
session.m_disabled_components.is_enabled(
this));
341 TLOG_DEBUG( 6) <<
"disabled(" <<
this <<
") (UID=" << UID() <<
") returns " << std::boolalpha << result ;
348 return (
session.m_disabled_components.m_num_of_slr_enabled_resources +
session.m_disabled_components.m_num_of_slr_disabled_resources);
#define ERS_DECLARE_ISSUE_BASE(namespace_name, class_name, base_class_name, message, base_attributes, attributes)
Represents database objects.
Defines base class for cache of template objects.
void remove_action(ConfigAction *ac)
void add_action(ConfigAction *ac)
const TARGET * cast() const noexcept
Casts object to different class.
bool disabled(const dunedaq::confmodel::Session &session) const
std::set< const std::string *, SortStringPtr > m_disabled
dunedaq::conffwk::Configuration & m_db
DisabledComponents(dunedaq::conffwk::Configuration &db, Session *session)
void load() noexcept
Call action on database file(s) load.
unsigned long m_num_of_slr_enabled_resources
void unload() noexcept
Call action on database file(s) unload.
unsigned long m_num_of_slr_disabled_resources
void disable_children(const dunedaq::confmodel::ResourceSet &)
std::set< const dunedaq::confmodel::Component * > m_user_enabled
void update(const dunedaq::conffwk::ConfigObject &obj, const std::string &name) noexcept
Call action on database object modification by user's code.
void notify(std::vector< dunedaq::conffwk::ConfigurationChange * > &) noexcept
Call action on database changes.
static unsigned long get_num_of_slr_resources(const dunedaq::confmodel::Session &p)
virtual ~DisabledComponents()
std::set< const dunedaq::confmodel::Component * > m_user_disabled
void disable(const dunedaq::confmodel::Component &c)
const std::vector< const dunedaq::confmodel::ResourceBase * > & get_contains() const
Get "contains" relationship value. A resource set is a container of resources to easily implement gro...
const std::vector< const dunedaq::confmodel::Segment * > & get_segments() const
Get "segments" relationship value. Nested list of Segments that form part of this Segment.
const std::vector< const dunedaq::confmodel::Application * > & get_applications() const
Get "applications" relationship value. List of Applications that run in this Segment.
void set_enabled(const std::set< const dunedaq::confmodel::Component * > &objs) const
void set_disabled(const std::vector< const dunedaq::confmodel::ResourceBase * > &value)
Set "disabled" relationship value. Resources that should not participate in the current run.
dunedaq::confmodel::DisabledComponents m_disabled_components
static void fill(const ResourceSet &rs, std::vector< const ResourceSetOR * > &rs_or, std::vector< const ResourceSetAND * > &rs_and, TestCircularDependency &cd_fuse)
#define TLOG_DEBUG(lvl,...)
void error(const Issue &issue)