Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change ModuleConfiguration to ConfigurationManager #397

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/dfmodules/DataStore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#ifndef DFMODULES_INCLUDE_DFMODULES_DATASTORE_HPP_
#define DFMODULES_INCLUDE_DFMODULES_DATASTORE_HPP_

#include "appfwk/ModuleConfiguration.hpp"
#include "appfwk/ConfigurationManager.hpp"
#include "opmonlib/MonitorableObject.hpp"
#include "cetlib/BasicPluginFactory.h"
#include "cetlib/compiler_macros.h"
Expand Down Expand Up @@ -47,7 +47,7 @@
#define DEFINE_DUNE_DATA_STORE(klass) \
EXTERN_C_FUNC_DECLARE_START \
std::shared_ptr<dunedaq::dfmodules::DataStore> make(const std::string& name, \
std::shared_ptr<dunedaq::appfwk::ModuleConfiguration> mcfg, \
std::shared_ptr<dunedaq::appfwk::ConfigurationManager> mcfg, \
const std::string& writer_name ) \
{ \
return std::shared_ptr<dunedaq::dfmodules::DataStore>(new klass(name, mcfg, writer_name)); \
Expand Down Expand Up @@ -163,7 +163,7 @@ class DataStore : public utilities::NamedObject, public opmonlib::MonitorableObj
inline std::shared_ptr<DataStore>
make_data_store(const std::string& type,
const std::string& name,
std::shared_ptr<dunedaq::appfwk::ModuleConfiguration> mcfg,
std::shared_ptr<dunedaq::appfwk::ConfigurationManager> mcfg,
const std::string& writer_identifier)
{
static cet::BasicPluginFactory bpf("duneDataStore", "make"); // NOLINT
Expand Down
4 changes: 2 additions & 2 deletions plugins/DFOModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ DFOModule::DFOModule(const std::string& name)
}

void
DFOModule::init(std::shared_ptr<appfwk::ModuleConfiguration> mcfg)
DFOModule::init(std::shared_ptr<appfwk::ConfigurationManager> mcfg)
{
TLOG_DEBUG(TLVL_ENTER_EXIT_METHODS) << get_name() << ": Entering init() method";

auto mdal = mcfg->module<appmodel::DFOModule>(get_name());
auto mdal = mcfg->get_dal<appmodel::DFOModule>(get_name());
if (!mdal) {
throw appfwk::CommandFailed(ERS_HERE, "init", get_name(), "Unable to retrieve configuration object");
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/DFOModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class DFOModule : public dunedaq::appfwk::DAQModule
DFOModule(DFOModule&&) = delete; ///< DFOModule is not move-constructible
DFOModule& operator=(DFOModule&&) = delete; ///< DFOModule is not move-assignable

void init(std::shared_ptr<appfwk::ModuleConfiguration> mcfg) override;
void init(std::shared_ptr<appfwk::ConfigurationManager> mcfg) override;

protected:
virtual std::shared_ptr<AssignedTriggerDecision> find_slot(const dfmessages::TriggerDecision& decision);
Expand Down
6 changes: 3 additions & 3 deletions plugins/DataWriterModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ DataWriterModule::DataWriterModule(const std::string& name)
}

void
DataWriterModule::init(std::shared_ptr<appfwk::ModuleConfiguration> mcfg)
DataWriterModule::init(std::shared_ptr<appfwk::ConfigurationManager> mcfg)
{
TLOG_DEBUG(TLVL_ENTER_EXIT_METHODS) << get_name() << ": Entering init() method";
auto mdal = mcfg->module<appmodel::DataWriterModule>(get_name());
auto mdal = mcfg->get_dal<appmodel::DataWriterModule>(get_name());
if (!mdal) {
throw appfwk::CommandFailed(ERS_HERE, "init", get_name(), "Unable to retrieve configuration object");
}
Expand Down Expand Up @@ -102,7 +102,7 @@ DataWriterModule::init(std::shared_ptr<appfwk::ModuleConfiguration> mcfg)
}
}

auto trbdal = mcfg->module<appmodel::TRBModule>(trb_uid);
auto trbdal = mcfg->get_dal<appmodel::TRBModule>(trb_uid);
if (!trbdal) {
throw appfwk::CommandFailed(ERS_HERE, "init", get_name(), "Unable to retrieve TRB configuration object");
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/DataWriterModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class DataWriterModule : public dunedaq::appfwk::DAQModule
DataWriterModule(DataWriterModule&&) = delete; ///< DataWriterModule is not move-constructible
DataWriterModule& operator=(DataWriterModule&&) = delete; ///< DataWriterModule is not move-assignable

void init(std::shared_ptr<appfwk::ModuleConfiguration> mcfg) override;
void init(std::shared_ptr<appfwk::ConfigurationManager> mcfg) override;
void generate_opmon_data() override;

private:
Expand All @@ -60,7 +60,7 @@ class DataWriterModule : public dunedaq::appfwk::DAQModule
std::atomic<bool> m_running = false;

// Configuration
std::shared_ptr<appfwk::ModuleConfiguration> m_module_configuration;
std::shared_ptr<appfwk::ConfigurationManager> m_module_configuration;
const appmodel::DataWriterConf* m_data_writer_conf;
std::string m_writer_identifier;

Expand Down
4 changes: 2 additions & 2 deletions plugins/FakeDataProdModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ FakeDataProdModule::FakeDataProdModule(const std::string& name)
}

void
FakeDataProdModule::init(std::shared_ptr<appfwk::ModuleConfiguration> mcfg)
FakeDataProdModule::init(std::shared_ptr<appfwk::ConfigurationManager> mcfg)
{
TLOG_DEBUG(TLVL_ENTER_EXIT_METHODS) << get_name() << ": Entering init() method";
auto mdal = mcfg->module<appmodel::FakeDataProdModule>(get_name());
auto mdal = mcfg->get_dal<appmodel::FakeDataProdModule>(get_name());
if (!mdal) {
throw appfwk::CommandFailed(ERS_HERE, "init", get_name(), "Unable to retrieve configuration object");
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/FakeDataProdModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class FakeDataProdModule : public dunedaq::appfwk::DAQModule
FakeDataProdModule(FakeDataProdModule&&) = delete; ///< FakeDataProdModule is not move-constructible
FakeDataProdModule& operator=(FakeDataProdModule&&) = delete; ///< FakeDataProdModule is not move-assignable

void init(std::shared_ptr<appfwk::ModuleConfiguration> mcfg) override;
void init(std::shared_ptr<appfwk::ConfigurationManager> mcfg) override;

private:
// Commands
Expand Down
4 changes: 2 additions & 2 deletions plugins/FragmentAggregatorModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ FragmentAggregatorModule::FragmentAggregatorModule(const std::string& name)
}

void
FragmentAggregatorModule::init(std::shared_ptr<appfwk::ModuleConfiguration> mcfg)
FragmentAggregatorModule::init(std::shared_ptr<appfwk::ConfigurationManager> mcfg)
{
auto mdal = mcfg->module<appmodel::FragmentAggregatorModule>(get_name());
auto mdal = mcfg->get_dal<appmodel::FragmentAggregatorModule>(get_name());
if (!mdal) {
throw appfwk::CommandFailed(ERS_HERE, "init", get_name(), "Unable to retrieve configuration object");
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/FragmentAggregatorModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class FragmentAggregatorModule : public dunedaq::appfwk::DAQModule
FragmentAggregatorModule(FragmentAggregatorModule&&) = delete;
FragmentAggregatorModule& operator=(FragmentAggregatorModule&&) = delete;

void init(std::shared_ptr<appfwk::ModuleConfiguration> mcfg) override;
void init(std::shared_ptr<appfwk::ConfigurationManager> mcfg) override;
// void get_info(opmonlib::InfoCollector& ci, int level) override;

private:
Expand Down
10 changes: 5 additions & 5 deletions plugins/HDF5DataStore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class HDF5DataStore : public DataStore
*
*/
explicit HDF5DataStore(std::string const& name,
std::shared_ptr<appfwk::ModuleConfiguration> mcfg,
std::shared_ptr<appfwk::ConfigurationManager> mcfg,
std::string const& writer_name)
: DataStore(name)
, m_basic_name_of_open_file("")
Expand All @@ -124,11 +124,11 @@ class HDF5DataStore : public DataStore
{
TLOG_DEBUG(TLVL_BASIC) << get_name();

m_config_params = mcfg->module<appmodel::DataStoreConf>(name);
m_config_params = mcfg->get_dal<appmodel::DataStoreConf>(name);
m_file_layout_params = m_config_params->get_file_layout_params();
m_session = mcfg->configuration_manager()->session();
m_operational_environment = mcfg->configuration_manager()->session()->get_detector_configuration()->get_op_env();
m_offline_data_stream = mcfg->configuration_manager()->session()->get_detector_configuration()->get_offline_data_stream();
m_session = mcfg->session();
m_operational_environment = mcfg->session()->get_detector_configuration()->get_op_env();
m_offline_data_stream = mcfg->session()->get_detector_configuration()->get_offline_data_stream();

m_operation_mode = m_config_params->get_mode();
m_path = m_config_params->get_directory_path();
Expand Down
4 changes: 2 additions & 2 deletions plugins/TPStreamWriterModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ TPStreamWriterModule::TPStreamWriterModule(const std::string& name)
}

void
TPStreamWriterModule::init(std::shared_ptr<appfwk::ModuleConfiguration> mcfg)
TPStreamWriterModule::init(std::shared_ptr<appfwk::ConfigurationManager> mcfg)
{
TLOG_DEBUG(TLVL_ENTER_EXIT_METHODS) << get_name() << ": Entering init() method";
auto mdal = mcfg->module<appmodel::TPStreamWriterModule>(get_name());
auto mdal = mcfg->get_dal<appmodel::TPStreamWriterModule>(get_name());
if (!mdal) {
throw appfwk::CommandFailed(ERS_HERE, "init", get_name(), "Unable to retrieve configuration object");
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/TPStreamWriterModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class TPStreamWriterModule : public dunedaq::appfwk::DAQModule
TPStreamWriterModule(TPStreamWriterModule&&) = delete; ///< TPStreamWriterModule is not move-constructible
TPStreamWriterModule& operator=(TPStreamWriterModule&&) = delete; ///< TPStreamWriterModule is not move-assignable

void init(std::shared_ptr<appfwk::ModuleConfiguration> mcfg) override;
void init(std::shared_ptr<appfwk::ConfigurationManager> mcfg) override;
void generate_opmon_data() override;

private:
Expand All @@ -59,7 +59,7 @@ class TPStreamWriterModule : public dunedaq::appfwk::DAQModule

// Configuration

std::shared_ptr<appfwk::ModuleConfiguration> m_module_configuration;
std::shared_ptr<appfwk::ConfigurationManager> m_module_configuration;
const appmodel::TPStreamWriterConf* m_tp_writer_conf;
std::chrono::milliseconds m_queue_timeout;
size_t m_accumulation_interval_ticks;
Expand Down
4 changes: 2 additions & 2 deletions plugins/TRBModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ TRBModule::TRBModule(const std::string& name)
}

void
TRBModule::init(std::shared_ptr<appfwk::ModuleConfiguration> mcfg)
TRBModule::init(std::shared_ptr<appfwk::ConfigurationManager> mcfg)
{

TLOG_DEBUG(TLVL_ENTER_EXIT_METHODS) << get_name() << ": Entering init() method";
Expand All @@ -79,7 +79,7 @@ TRBModule::init(std::shared_ptr<appfwk::ModuleConfiguration> mcfg)
// Get single queues
//---------------------------------

auto mdal = mcfg->module<appmodel::TRBModule>(get_name());
auto mdal = mcfg->get_dal<appmodel::TRBModule>(get_name());
if (!mdal) {
throw appfwk::CommandFailed(ERS_HERE, "init", get_name(), "Unable to retrieve configuration object");
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/TRBModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class TRBModule : public dunedaq::appfwk::DAQModule
TRBModule(TRBModule&&) = delete; ///< TRBModule is not move-constructible
TRBModule& operator=(TRBModule&&) = delete; ///< TRBModule is not move-assignable

void init(std::shared_ptr<appfwk::ModuleConfiguration> mcfg) override;
void init(std::shared_ptr<appfwk::ConfigurationManager> mcfg) override;

void generate_opmon_data() override;

Expand Down
12 changes: 5 additions & 7 deletions unittest/DFOModule_test.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ struct CfgFixture
std::string appName = "TestApp";
std::string sessionName = "partition_name";
cfgMgr = std::make_shared<dunedaq::appfwk::ConfigurationManager>(oksConfig, appName, sessionName);
modCfg = std::make_shared<dunedaq::appfwk::ModuleConfiguration>(cfgMgr);
get_iomanager()->configure(sessionName, modCfg->queues(), modCfg->networkconnections(), nullptr, opmgr);
get_iomanager()->configure(sessionName, cfgMgr->queues(), cfgMgr->networkconnections(), nullptr, opmgr);
}
~CfgFixture() {
get_iomanager()->reset();
Expand All @@ -63,7 +62,6 @@ struct CfgFixture

dunedaq::opmonlib::TestOpMonManager opmgr;
std::shared_ptr<dunedaq::appfwk::ConfigurationManager> cfgMgr;
std::shared_ptr<dunedaq::appfwk::ModuleConfiguration> modCfg;
};

BOOST_FIXTURE_TEST_SUITE(DFOModule_test, CfgFixture)
Expand Down Expand Up @@ -140,14 +138,14 @@ BOOST_AUTO_TEST_CASE(Constructor)
BOOST_AUTO_TEST_CASE(Init)
{
auto dfo = appfwk::make_module("DFOModule", "test");
dfo->init(modCfg);
dfo->init(cfgMgr);
}

BOOST_AUTO_TEST_CASE(Commands)
{
auto dfo = appfwk::make_module("DFOModule", "test");
opmgr.register_node("dfo", dfo);
dfo->init(modCfg);
dfo->init(cfgMgr);

auto conf_json = "{\"thresholds\": { \"free\": 1, \"busy\": 2 }, "
"\"general_queue_timeout\": 100, \"td_send_retries\": 5}"_json;
Expand Down Expand Up @@ -175,7 +173,7 @@ BOOST_AUTO_TEST_CASE(DataFlow)
{
auto dfo = appfwk::make_module("DFOModule", "test");
opmgr.register_node("dfo", dfo);
dfo->init(modCfg);
dfo->init(cfgMgr);

auto conf_json = "{\"thresholds\": { \"free\": 1, \"busy\": 2 }, "
"\"general_queue_timeout\": 100, \"td_send_retries\": 5}"_json;
Expand Down Expand Up @@ -244,7 +242,7 @@ BOOST_AUTO_TEST_CASE(SendTrigDecFailed)
{
auto dfo = appfwk::make_module("DFOModule", "test");
opmgr.register_node("dfo", dfo);
dfo->init(modCfg);
dfo->init(cfgMgr);

auto conf_json = "{\"thresholds\": { \"free\": 1, \"busy\": 2 }, "
"\"general_queue_timeout\": 100, \"td_send_retries\": 5}"_json;
Expand Down
23 changes: 10 additions & 13 deletions unittest/HDF5Write_test.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/

#include "dfmodules/DataStore.hpp"
#include "appfwk/ModuleConfiguration.hpp"

#include "appmodel/DataWriterModule.hpp"
#include "appmodel/DataWriterConf.hpp"
Expand Down Expand Up @@ -129,7 +128,6 @@ struct CfgFixture
std::string oksConfig = "oksconflibs:test/config/hdf5write_test.data.xml";
std::string appName = "TestApp";
cfgMgr = std::make_shared<dunedaq::appfwk::ConfigurationManager>(oksConfig, appName, sessionName);
modCfg = std::make_shared<dunedaq::appfwk::ModuleConfiguration>(cfgMgr);
TLOG_DEBUG(4) << "Done with CfgFixture";
}

Expand All @@ -139,7 +137,6 @@ struct CfgFixture
}

std::shared_ptr<dunedaq::appfwk::ConfigurationManager> cfgMgr;
std::shared_ptr<dunedaq::appfwk::ModuleConfiguration> modCfg;
};

BOOST_AUTO_TEST_SUITE(HDF5Write_test)
Expand All @@ -159,14 +156,14 @@ BOOST_AUTO_TEST_CASE(WriteEventFiles)

// create the DataStore
CfgFixture cfg("test-session-3-1");
auto data_writer_conf = cfg.modCfg->module<dunedaq::appmodel::DataWriterModule>("dwm-01")->get_configuration();
auto data_writer_conf = cfg.cfgMgr->get_dal<dunedaq::appmodel::DataWriterModule>("dwm-01")->get_configuration();
auto data_store_conf = data_writer_conf->get_data_store_params();

auto data_store_conf_obj = data_store_conf->config_object();
data_store_conf_obj.set_by_val<std::string>("directory_path", file_path);
data_store_conf_obj.set_by_val<std::string>("mode", "one-event-per-file");

auto data_store_ptr = make_data_store(data_store_conf->get_type(), data_store_conf->UID(), cfg.modCfg, "dwm-01");
auto data_store_ptr = make_data_store(data_store_conf->get_type(), data_store_conf->UID(), cfg.cfgMgr, "dwm-01");

// write several events, each with several fragments
for (int trigger_number = 1; trigger_number <= trigger_count; ++trigger_number)
Expand Down Expand Up @@ -200,13 +197,13 @@ BOOST_AUTO_TEST_CASE(WriteOneFile)

// create the DataStore
CfgFixture cfg("test-session-3-1");
auto data_writer_conf = cfg.modCfg->module<dunedaq::appmodel::DataWriterModule>("dwm-01")->get_configuration();
auto data_writer_conf = cfg.cfgMgr->get_dal<dunedaq::appmodel::DataWriterModule>("dwm-01")->get_configuration();
auto data_store_conf = data_writer_conf->get_data_store_params();

auto data_store_conf_obj = data_store_conf->config_object();
data_store_conf_obj.set_by_val<std::string>("directory_path", file_path);

auto data_store_ptr = make_data_store(data_store_conf->get_type(), data_store_conf->UID(), cfg.modCfg, "dwm-01");
auto data_store_ptr = make_data_store(data_store_conf->get_type(), data_store_conf->UID(), cfg.cfgMgr, "dwm-01");

// write several events, each with several fragments
for (int trigger_number = 1; trigger_number <= trigger_count; ++trigger_number)
Expand Down Expand Up @@ -240,13 +237,13 @@ BOOST_AUTO_TEST_CASE(CheckWritingSuffix)

// create the DataStore
CfgFixture cfg("test-session-3-1");
auto data_writer_conf = cfg.modCfg->module<dunedaq::appmodel::DataWriterModule>("dwm-01")->get_configuration();
auto data_writer_conf = cfg.cfgMgr->get_dal<dunedaq::appmodel::DataWriterModule>("dwm-01")->get_configuration();
auto data_store_conf = data_writer_conf->get_data_store_params();

auto data_store_conf_obj = data_store_conf->config_object();
data_store_conf_obj.set_by_val<std::string>("directory_path", file_path);

auto data_store_ptr = make_data_store(data_store_conf->get_type(), data_store_conf->UID(), cfg.modCfg, "dwm-01");
auto data_store_ptr = make_data_store(data_store_conf->get_type(), data_store_conf->UID(), cfg.cfgMgr, "dwm-01");

// write several events, each with several fragments
for (int trigger_number = 1; trigger_number <= trigger_count; ++trigger_number) {
Expand Down Expand Up @@ -289,14 +286,14 @@ BOOST_AUTO_TEST_CASE(FileSizeLimitResultsInMultipleFiles)

// create the DataStore
CfgFixture cfg("test-session-5-10");
auto data_writer_conf = cfg.modCfg->module<dunedaq::appmodel::DataWriterModule>("dwm-01")->get_configuration();
auto data_writer_conf = cfg.cfgMgr->get_dal<dunedaq::appmodel::DataWriterModule>("dwm-01")->get_configuration();
auto data_store_conf = data_writer_conf->get_data_store_params();

auto data_store_conf_obj = data_store_conf->config_object();
data_store_conf_obj.set_by_val<std::string>("directory_path", file_path);
data_store_conf_obj.set_by_val<int>("max_file_size", 3000000); // goal is 6 events per file

auto data_store_ptr = make_data_store(data_store_conf->get_type(), data_store_conf->UID(), cfg.modCfg, "dwm-01");
auto data_store_ptr = make_data_store(data_store_conf->get_type(), data_store_conf->UID(), cfg.cfgMgr, "dwm-01");

// write several events, each with several fragments
for (int trigger_number = 1; trigger_number <= trigger_count; ++trigger_number)
Expand Down Expand Up @@ -333,14 +330,14 @@ BOOST_AUTO_TEST_CASE(SmallFileSizeLimitDataBlockListWrite)

// create the DataStore
CfgFixture cfg("test-session-5-1");
auto data_writer_conf = cfg.modCfg->module<dunedaq::appmodel::DataWriterModule>("dwm-01")->get_configuration();
auto data_writer_conf = cfg.cfgMgr->get_dal<dunedaq::appmodel::DataWriterModule>("dwm-01")->get_configuration();
auto data_store_conf = data_writer_conf->get_data_store_params();

auto data_store_conf_obj = data_store_conf->config_object();
data_store_conf_obj.set_by_val<std::string>("directory_path", file_path);
data_store_conf_obj.set_by_val<int>("max_file_size", 150000); // ~1.5 Fragment, ~0.3 TR

auto data_store_ptr = make_data_store(data_store_conf->get_type(), data_store_conf->UID(), cfg.modCfg,"dwm-01");
auto data_store_ptr = make_data_store(data_store_conf->get_type(), data_store_conf->UID(), cfg.cfgMgr,"dwm-01");

// write several events, each with several fragments
for (int trigger_number = 1; trigger_number <= trigger_count; ++trigger_number)
Expand Down
Loading