35#include "nlohmann/json.hpp"
54 std::vector<const dunedaq::confmodel::ExcludableEntity*>& p_list,
55 std::list<std::vector<const dunedaq::confmodel::ExcludableEntity*>>&
out,
61 p_list.push_back(resource_set);
65 if (i->config_object().implementation() == child) {
66 out.push_back(p_list);
68 make_parents_list(child, rs, p_list,
out, cd_fuse);
79 std::vector<const dunedaq::confmodel::ExcludableEntity*>& p_list,
80 std::list<std::vector<const dunedaq::confmodel::ExcludableEntity*>>&
out,
87 p_list.push_back(segment);
91 if (seg->config_object().implementation() == child)
92 out.push_back(p_list);
94 make_parents_list(child, seg, p_list,
out, is_segment, cd_fuse);
98 if (
app->config_object().implementation() == child)
99 out.push_back(p_list);
101 make_parents_list(child, resource_set, p_list,
out, cd_fuse);
111check_segment(std::list<std::vector<const dunedaq::confmodel::ExcludableEntity*>>&
out,
119 std::vector<const dunedaq::confmodel::ExcludableEntity*> compList;
122 out.push_back(compList);
124 make_parents_list(child, segment, compList,
out, is_segment, cd_fuse);
138 TestCircularDependency cd_fuse(
"component parents", &session);
141 check_segment(
parents, session.get_segment(), obj_impl, is_segment, cd_fuse);
144 TLOG_DEBUG(1) <<
"cannot find segment/resource path(s) between ExcludableEntity " <<
this <<
" and session "
145 << &session <<
" objects (check this object is linked with the session as a segment or a resource)";
147 }
catch (ers::Issue& ex) {
154std::vector<const Application*>
157 std::vector<const Application*> apps;
160 for (
auto app : segapps) {
162 if (comp ==
nullptr || !comp->is_excluded(*
this)) {
163 apps.insert(apps.end(), app);
170 if (!included_only || !seg->is_excluded(*
this)) {
172 apps.insert(apps.end(), segapps.begin(), segapps.end());
178std::vector<const Application*>
181 std::vector<const Application*> apps;
183 apps.insert(apps.end(), segapps.begin(), segapps.end());
187std::vector<const Application*>
190 std::vector<const Application*> apps;
192 apps.insert(apps.end(), segapps.begin(), segapps.end());
198std::set<const HostComponent*>
201 std::set<const HostComponent*> res;
203 for (
auto hostresource : module->get_used_host_components()) {
204 res.insert(hostresource);
213 const std::string& class_name,
214 const std::string& uid,
216 bool skip_object_name)
218 using nlohmann::json;
220 TLOG_DBG(9) <<
"Getting attributes for " << uid <<
" of class " << class_name;
224 confdb.
get(class_name, uid,
obj);
225 for (
auto attr : class_info.p_attributes) {
232 }
else if (attr.p_type == type_t::u64_type) {
234 }
else if (attr.p_type == type_t::s8_type) {
236 }
else if (attr.p_type == type_t::s16_type) {
238 }
else if (attr.p_type == type_t::s32_type || attr.p_type == type_t::s16_type) {
240 }
else if (attr.p_type == type_t::s64_type) {
242 }
else if (attr.p_type == type_t::float_type) {
244 }
else if (attr.p_type == type_t::double_type) {
246 }
else if (attr.p_type == type_t::bool_type) {
248 }
else if ((attr.p_type == type_t::string_type) || (attr.p_type == type_t::enum_type) ||
249 (attr.p_type == type_t::date_type) || (attr.p_type == type_t::time_type)) {
254 TLOG_DBG(9) <<
"Processing relationships";
255 for (
auto iter : class_info.p_relationships) {
256 std::string rel_name = iter.p_name;
257 if (iter.p_cardinality == cardinality_t::zero_or_one || iter.p_cardinality == cardinality_t::only_one) {
258 ConfigObject rel_obj;
259 obj.get(rel_name, rel_obj);
261 TLOG_DBG(9) <<
"Getting attibute of relationship " << rel_name;
263 get_json_config(confdb, rel_obj.
class_name(), rel_obj.
UID(), direct_only, skip_object_name);
265 TLOG_DBG(9) <<
"Relationship " << rel_name <<
" not set";
268 TLOG_DBG(9) <<
"Relationship " << rel_name <<
" is multi value. "
269 <<
"Getting attibutes for relationship.";
270 std::vector<ConfigObject> rel_vec;
271 obj.get(rel_name, rel_vec);
272 std::vector<json> configs;
273 for (
auto rel_obj : rel_vec) {
274 TLOG_DBG(9) <<
"Getting attibute of relationship " << rel_obj.
UID();
275 auto rel_conf = get_json_config(confdb, rel_obj.
class_name(), rel_obj.
UID(), direct_only, skip_object_name);
276 configs.push_back(rel_conf);
283 if (skip_object_name) {
298const std::vector<std::string>
306const std::vector<std::string>
311 const std::string configuration_uri = confdb.
get_impl_spec();
314 const std::string controller_log_level =
session->get_controller_log_level();
317 if (as->UID().ends_with(
"_control")) {
319 throw DuplicatedControlService(
ERS_HERE, as->UID());
320 control_service = as;
324 if (control_service ==
nullptr)
328 std::to_string(control_service->
get_port());
330 std::vector<std::string> ret = {
"-l", controller_log_level };
331 ret.push_back(configuration_uri);
332 ret.push_back(control_uri);
333 ret.push_back(
UID());
338std::vector<const confmodel::DetectorStream*>
341 std::vector<const confmodel::DetectorStream*> all_streams;
343 for (
auto sender : this->
senders()) {
344 auto sender_streams = sender->get_streams();
345 all_streams.insert(all_streams.end(), sender_streams.begin(), sender_streams.end());
355 if (type ==
"file") {
359 if (type ==
"stream") {
371 for (
auto excluded_resource : excluded_vec) {
372 if (excluded_resource == res) {
376 excluded_vec.push_back(res);
387 auto count = std::erase(excluded_vec, res);
405 TLOG_DEBUG(6) <<
"No compute_excluded_state method defined for ExcludableEntity " <<
class_name();
406 if (excluded_resources.contains(
UID())) {
412std::vector<const ExcludableEntity*>
418std::vector<const ExcludableEntity*>
431 if (excluded_resources.contains(
UID())) {
434 bool send_excluded =
true;
435 for (
auto sender :
senders()) {
436 if (!sender->compute_excluded_state(excluded_resources)) {
437 send_excluded =
false;
442 <<
" senders excluded=" << send_excluded;
445 return send_excluded;
447 return (rec->compute_excluded_state(excluded_resources) || send_excluded);
450std::vector<const ExcludableEntity*>
458 TLOG_DBG(6) <<
"Checking " << app->UID();
460 if (res !=
nullptr) {
461 TLOG_DBG(6) <<
"Adding " << app->UID();
462 resources.push_back(res);
465 TLOG_DBG(6) <<
"Returning vector of " << resources.size() <<
" resources";
472 if (excluded.contains(
UID())) {
477 if (res ==
nullptr) {
482 if (!res->compute_excluded_state(excluded)) {
Implements database objects.
Represents database objects.
const std::string & UID() const noexcept
Return object identity.
bool is_null() const noexcept
Check if object's implementation points to null.
const ConfigObjectImpl * implementation() const noexcept
Returns pointer on implementation.
const std::string & class_name() const noexcept
Return object's class name.
void get(const std::string &class_name, const std::string &id, ConfigObject &object, unsigned long rlevel=0, const std::vector< std::string > *rclasses=0)
Get object by class name and object id (multi-thread safe).
void update(const std::vector< std::string > &modified, const std::vector< std::string > &removed, const std::vector< std::string > &created) noexcept
Update cache of objects in case of modification.
const std::string & get_impl_spec() const noexcept
const dunedaq::conffwk::class_t & get_class_info(const std::string &class_name, bool direct_only=false)
The method provides access to description of class.
std::string full_name() const noexcept
bool castable(const std::string &target) const noexcept
const TARGET * cast() const noexcept
Casts object to different class.
const std::string & class_name() const noexcept
Configuration & configuration() const noexcept
const ConfigObject & config_object() const
const std::string & UID() const noexcept
DalRegistry & p_registry
Configuration object.
Configuration & configuration()
const std::vector< const dunedaq::confmodel::Service * > & get_exposes_service() const
Get "exposes_service" relationship value. Services exposed i.e. provided by this application.
const dunedaq::confmodel::VirtualHost * get_runs_on() const
Get "runs_on" relationship value. VirtualHost to run this application on.
const std::vector< const dunedaq::confmodel::DaqModule * > & get_modules() const
Get "modules" relationship value.
const std::vector< std::string > construct_commandline_parameters(const conffwk::Configuration &confdb, const dunedaq::confmodel::Session *session) const
std::set< const dunedaq::confmodel::HostComponent * > get_used_host_components() const
virtual std::vector< const ExcludableEntity * > contained_excludable_entities() const override
const std::vector< const dunedaq::confmodel::DetectorStream * > & get_streams() const
Get "streams" relationship value.
virtual const DetDataReceiver * receiver() const =0
bool compute_excluded_state(const std::set< std::string > &excluded) const final
std::vector< const confmodel::DetectorStream * > streams() const
virtual std::vector< const DetDataSender * > senders() const =0
virtual std::vector< const ExcludableEntity * > contained_excludable_entities() const override
virtual std::vector< const ExcludableEntity * > contained_excludable_entities() const =0
const dunedaq::confmodel::ExcludedEntities & excluded_entities() const
virtual const ExcludableEntitySet * root_entity() const =0
void exclude(const ExcludableEntity *)
void include(const ExcludableEntity *)
const std::vector< const dunedaq::confmodel::ExcludableEntity * > & get_excluded() const
Get "excluded" relationship value. ExcludableEntitys that should not participate in the current run.
ExcludedEntities m_excluded_entities
void set_excluded(const std::vector< const dunedaq::confmodel::ExcludableEntity * > &value)
Set "excluded" relationship value. ExcludableEntitys that should not participate in the current run.
ExcludableEntityTree(conffwk::DalRegistry &db, const conffwk::ConfigObject &obj) noexcept
bool is_excluded(const dunedaq::confmodel::ExcludableEntityTree &session) const
void parents(const dunedaq::confmodel::Session &session, std::list< std::vector< const dunedaq::confmodel::ExcludableEntity * > > &parents) const
virtual bool compute_excluded_state(const std::set< std::string > &) const
void update(const ExcludableEntitySet *root, std::vector< const ExcludableEntity * > initial_list)
bool is_included(const ExcludableEntity *component) const
nlohmann::json to_json(bool direct=false, bool skip_name=false) const
std::string get_URI(const std::string &app) const
const std::string & get_type() const
Get "type" attribute value. type of the OpMonFacility.
const std::string & get_path() const
Get "path" attribute value. property used to generate the final URI.
const std::vector< std::string > construct_commandline_parameters(const conffwk::Configuration &confdb, const dunedaq::confmodel::Session *session) const
virtual std::vector< const ExcludableEntity * > contained_excludable_entities() const
bool compute_excluded_state(const std::set< std::string > &excluded) const final
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.
static const std::string & s_class_name
const std::string & get_protocol() const
Get "protocol" attribute value.
uint16_t get_port() const
Get "port" attribute value.
const dunedaq::confmodel::Segment * get_segment() const
Get "segment" relationship value. List of configuration Segments that form this Session.
std::vector< const dunedaq::confmodel::Application * > included_applications() const
std::vector< const dunedaq::confmodel::Application * > all_applications() const
std::vector< const Application * > getSegmentApps(const Segment *, bool) const
const dunedaq::confmodel::PhysicalHost * get_runs_on() const
Get "runs_on" relationship value. The physical host that this virtual host runs on.
std::vector< const dunedaq::confmodel::ExcludableEntity * > to_resources(const std::vector< T * > &vector_of_children)
#define TLOG_DEBUG(lvl,...)
std::vector< T > attributes(tref const &item)
const std::vector< std::string > construct_commandline_parameters_appfwk(const T *app, const conffwk::Configuration &confdb, const dunedaq::confmodel::Session *session)
void add_json_value(conffwk::ConfigObject &obj, std::string &name, bool multi_value, nlohmann::json &attributes)
FELIX Initialization std::string initerror FELIX queue timed out
void error(const Issue &issue)