32#include "nlohmann/json.hpp"
56 std::vector<const dunedaq::confmodel::Resource *> & p_list,
57 std::list< std::vector<const dunedaq::confmodel::Resource *> >& out,
63 p_list.push_back(resource_set);
67 if (i->config_object().implementation() == child) {
68 out.push_back(p_list);
71 make_parents_list(child, rs, p_list, out, cd_fuse);
83 std::vector<const dunedaq::confmodel::Resource *> & p_list,
84 std::list<std::vector<const dunedaq::confmodel::Resource *> >& out,
91 p_list.push_back(segment);
95 if (seg->config_object().implementation() == child)
96 out.push_back(p_list);
98 make_parents_list(child, seg, p_list, out, is_segment, cd_fuse);
102 if (app->config_object().implementation() == child)
103 out.push_back(p_list);
105 make_parents_list(child, resource_set, p_list, out, cd_fuse);
117 std::list< std::vector<const dunedaq::confmodel::Resource *> >& out,
125 std::vector<const dunedaq::confmodel::Resource *> compList;
128 out.push_back(compList);
130 make_parents_list(child, segment, compList, out, is_segment, cd_fuse);
140 std::list<std::vector<const Resource *>>& parents)
const
150 check_segment(
parents,
session.get_segment(), obj_impl, is_segment,
155 TLOG_DEBUG(1) <<
"cannot find segment/resource path(s) between Resource " <<
this <<
" and session " << &
session <<
" objects (check this object is linked with the session as a segment or a resource)" ;
165std::vector<const Application*>
167 bool enabled_only)
const {
168 std::vector<const Application*> apps;
171 for (
auto app : segapps) {
173 if (comp ==
nullptr || !comp->is_disabled(*
this)) {
174 apps.insert(apps.end(), app);
182 if (!enabled_only || !seg->is_disabled(*
this)) {
184 apps.insert(apps.end(), segapps.begin(),segapps.end());
190std::vector<const Application*>
192 std::vector<const Application*> apps;
194 apps.insert(apps.end(), segapps.begin(),segapps.end());
198std::vector<const Application*>
200 std::vector<const Application*> apps;
202 apps.insert(apps.end(), segapps.begin(),segapps.end());
209std::set<const HostComponent*>
211 std::set<const HostComponent*> res;
213 for (
auto hostresource : module->get_used_resources()) {
214 res.insert(hostresource);
222 const std::string& class_name,
223 const std::string& uid,
225 bool skip_object_name) {
226 using nlohmann::json;
228 TLOG_DBG(9) <<
"Getting attributes for " << uid <<
" of class " << class_name;
232 confdb.
get(class_name, uid,
obj);
233 for (
auto attr : class_info.p_attributes) {
234 if (attr.p_type == type_t::u8_type) {
237 else if (attr.p_type == type_t::u16_type) {
240 else if (attr.p_type == type_t::u32_type) {
243 else if (attr.p_type == type_t::u64_type) {
246 else if (attr.p_type == type_t::s8_type) {
249 else if (attr.p_type == type_t::s16_type) {
252 else if (attr.p_type == type_t::s32_type ||
253 attr.p_type == type_t::s16_type) {
256 else if (attr.p_type == type_t::s64_type) {
259 else if (attr.p_type == type_t::float_type) {
262 else if (attr.p_type == type_t::double_type) {
265 else if (attr.p_type == type_t::bool_type) {
268 else if ((attr.p_type == type_t::string_type) ||
269 (attr.p_type == type_t::enum_type) ||
270 (attr.p_type == type_t::date_type) ||
271 (attr.p_type == type_t::time_type)) {
276 TLOG_DBG(9) <<
"Processing relationships";
277 for (
auto iter: class_info.p_relationships) {
278 std::string rel_name = iter.p_name;
279 if (iter.p_cardinality == cardinality_t::zero_or_one ||
280 iter.p_cardinality == cardinality_t::only_one) {
282 obj.
get(rel_name, rel_obj);
284 TLOG_DBG(9) <<
"Getting attibute of relationship " << rel_name;
291 TLOG_DBG(9) <<
"Relationship " << rel_name <<
" not set";
295 TLOG_DBG(9) <<
"Relationship " << rel_name <<
" is multi value. "
296 <<
"Getting attibutes for relationship.";
297 std::vector<ConfigObject> rel_vec;
298 obj.get(rel_name, rel_vec);
299 std::vector<json> configs;
300 for (
auto rel_obj : rel_vec) {
301 TLOG_DBG(9) <<
"Getting attibute of relationship " << rel_obj.
UID();
302 auto rel_conf = get_json_config(confdb, rel_obj.
class_name(), rel_obj.
UID(),
303 direct_only, skip_object_name);
304 configs.push_back(rel_conf);
311 if (skip_object_name) {
321 bool skip_object_name)
const {
337 const std::string configuration_uri = confdb.
get_impl_spec();
340 const std::string controller_log_level =
session->get_controller_log_level();
343 if (as->UID().ends_with(
"_control")) {
345 throw DuplicatedControlService(
ERS_HERE, as->UID());
346 control_service = as;
350 if (control_service ==
nullptr)
353 const std::string control_uri =
358 + std::to_string(control_service->
get_port());
360 std::vector<std::string> ret = {
"-l", controller_log_level };
361 ret.push_back(configuration_uri);
362 ret.push_back(control_uri);
363 ret.push_back(
UID());
370std::vector<const confmodel::DetectorStream*>
372 std::vector<const confmodel::DetectorStream*> all_streams;
374 for (
auto sender : this->
senders()) {
375 auto sender_streams = sender->get_streams();
376 all_streams.insert(all_streams.end(), sender_streams.begin(), sender_streams.end());
384 if ( type ==
"file" ) {
388 if ( type ==
"stream" ) {
400 if (disabled_resources.contains(
UID())) {
419 if (disabled_resources.contains(
UID())) {
422 bool send_disabled =
true;
424 if (!sender->compute_disabled_state(disabled_resources)) {
425 send_disabled =
false;
430 <<
" senders disabled=" << send_disabled;
437std::vector<const Resource*>
444 TLOG_DBG(6) <<
"Checking " << app->UID();
445 auto res=app->cast<
const Resource>();
446 if (res !=
nullptr) {
447 TLOG_DBG(6) <<
"Adding " << app->UID();
448 resources.push_back(res);
451 TLOG_DBG(6) <<
"Returning vector of " << resources.size() <<
" resources";
457 if (disabled.contains(
UID())) {
461 auto res=app->cast<
const Resource>();
462 if (res ==
nullptr) {
467 if (!res->compute_disabled_state(disabled)) {
Implements database objects.
Represents database objects.
const std::string & UID() const noexcept
Return object identity.
void get(const std::string &name, T &value)
Get value of object's attribute or relationship.
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).
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
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_hostresources() const
virtual std::vector< const Resource * > contained_resources() const override
const std::vector< const dunedaq::confmodel::DetectorStream * > & get_streams() const
Get "streams" relationship value.
bool compute_disabled_state(const std::set< std::string > &disabled) const final
virtual const DetDataReceiver * receiver() const =0
virtual std::vector< const Resource * > contained_resources() const override
std::vector< const confmodel::DetectorStream * > streams() const
virtual std::vector< const DetDataSender * > senders() const =0
bool is_enabled(const Resource *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 Resource * > contained_resources() const =0
const dunedaq::confmodel::DisabledResources & disabled_components() const
virtual bool compute_disabled_state(const std::set< std::string > &) const
void parents(const dunedaq::confmodel::Session &session, std::list< std::vector< const dunedaq::confmodel::Resource * > > &parents) const
bool is_disabled(const dunedaq::confmodel::ResourceTree &session) const
bool compute_disabled_state(const std::set< std::string > &disabled) 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
virtual std::vector< const Resource * > contained_resources() const
const std::string & get_protocol() const
Get "protocol" attribute value.
uint16_t get_port() const
Get "port" attribute value.
std::vector< const dunedaq::confmodel::Application * > enabled_applications() const
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 * > 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.
Base class for any user define issue.
std::vector< const dunedaq::confmodel::Resource * > 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)