1 #define TRACE_NAME "RoutingMasterApp"
3 #include "artdaq/Application/RoutingMasterApp.hh"
19 external_request_status_ =
true;
25 routing_master_ptr_.reset(
nullptr);
27 external_request_status_ = routing_master_ptr_->initialize(pset, timeout, timestamp);
28 if (!external_request_status_)
30 report_string_ =
"Error initializing ";
31 report_string_.append(app_name +
" ");
32 report_string_.append(
"with ParameterSet = \"" + pset.to_string() +
"\".");
35 return external_request_status_;
41 external_request_status_ = routing_master_ptr_->start(
id, timeout, timestamp);
42 if (!external_request_status_)
44 report_string_ =
"Error starting ";
45 report_string_.append(app_name +
" ");
46 report_string_.append(
"for run number ");
47 report_string_.append(boost::lexical_cast<std::string>(
id.run()));
48 report_string_.append(
", timeout ");
49 report_string_.append(boost::lexical_cast<std::string>(timeout));
50 report_string_.append(
", timestamp ");
51 report_string_.append(boost::lexical_cast<std::string>(timestamp));
52 report_string_.append(
".");
55 boost::thread::attributes attrs;
56 attrs.set_stack_size(4096 * 2000);
60 catch (
const boost::exception& e)
62 TLOG(TLVL_ERROR) <<
"Caught boost::exception starting RoutingMasterCore thread: " << boost::diagnostic_information(e) <<
", errno=" << errno;
63 std::cerr <<
"Caught boost::exception starting RoutingMasterCore thread: " << boost::diagnostic_information(e) <<
", errno=" << errno << std::endl;
67 return external_request_status_;
73 external_request_status_ = routing_master_ptr_->stop(timeout, timestamp);
74 if (!external_request_status_)
76 report_string_ =
"Error stopping ";
77 report_string_.append(app_name +
".");
81 if (routing_master_thread_.joinable()) routing_master_thread_.join();
83 TLOG_DEBUG(app_name +
"App") <<
"do_stop(uint64_t, uint64_t): "
84 <<
"Number of table entries sent = " << routing_master_ptr_->get_update_count()
87 return external_request_status_;
93 external_request_status_ = routing_master_ptr_->pause(timeout, timestamp);
94 if (!external_request_status_)
96 report_string_ =
"Error pausing ";
97 report_string_.append(app_name +
".");
99 if (routing_master_thread_.joinable()) routing_master_thread_.join();
101 TLOG_DEBUG(app_name +
"App") <<
"do_pause(uint64_t, uint64_t): "
102 <<
"Number of table entries sent = " << routing_master_ptr_->get_update_count()
106 return external_request_status_;
112 external_request_status_ = routing_master_ptr_->resume(timeout, timestamp);
113 if (!external_request_status_)
115 report_string_ =
"Error resuming ";
116 report_string_.append(app_name +
".");
119 boost::thread::attributes attrs;
120 attrs.set_stack_size(4096 * 2000);
122 TLOG(TLVL_INFO) <<
"Starting Routing Master thread";
126 catch (boost::exception
const& e)
128 std::cerr <<
"Exception encountered starting Routing Master thread: " << boost::diagnostic_information(e) <<
", errno=" << errno << std::endl;
131 TLOG(TLVL_INFO) <<
"Started Routing Master thread";
133 return external_request_status_;
139 external_request_status_ = routing_master_ptr_->shutdown(timeout);
140 if (!external_request_status_)
142 report_string_ =
"Error shutting down ";
143 report_string_.append(app_name +
".");
145 return external_request_status_;
151 external_request_status_ = routing_master_ptr_->soft_initialize(pset, timeout, timestamp);
152 if (!external_request_status_)
154 report_string_ =
"Error soft-initializing ";
155 report_string_.append(app_name +
" ");
156 report_string_.append(
"with ParameterSet = \"" + pset.to_string() +
"\".");
158 return external_request_status_;
163 external_request_status_ = routing_master_ptr_->reinitialize(pset, timeout, timestamp);
164 if (!external_request_status_)
166 report_string_ =
"Error reinitializing ";
167 report_string_.append(app_name +
" ");
168 report_string_.append(
"with ParameterSet = \"" + pset.to_string() +
"\".");
170 return external_request_status_;
175 TLOG_DEBUG(app_name +
"App") <<
"Booted state entry action called.";
181 routing_master_ptr_.reset(
nullptr);
186 std::string resultString;
189 if (which ==
"transition_status")
191 if (report_string_.length() > 0) {
return report_string_; }
192 else {
return "Success"; }
204 if (routing_master_ptr_.get() != 0)
206 resultString.append(routing_master_ptr_->report(which));
210 resultString.append(
"This RoutingMaster has not yet been initialized and ");
211 resultString.append(
"therefore can not provide reporting.");
bool do_initialize(fhicl::ParameterSet const &pset, uint64_t timeout, uint64_t timestamp) override
Initialize the RoutingMasterCore.
bool do_pause(uint64_t timeout, uint64_t timestamp) override
Pause the RoutingMasterCore.
RoutingMasterApp()
RoutingMasterApp Constructor.
bool do_resume(uint64_t timeout, uint64_t timestamp) override
Resume the RoutingMasterCore.
bool do_stop(uint64_t timeout, uint64_t timestamp) override
Stop the RoutingMasterCore.
std::string report(std::string const &) const override
If which is "transition_status", report the status of the last transition. Otherwise pass through to ...
bool do_shutdown(uint64_t timeout) override
Shutdown the RoutingMasterCore.
bool do_soft_initialize(fhicl::ParameterSet const &pset, uint64_t timeout, uint64_t timestamp) override
Soft-Initialize the RoutingMasterCore.
bool do_reinitialize(fhicl::ParameterSet const &pset, uint64_t timeout, uint64_t timestamp) override
Reinitialize the RoutingMasterCore.
bool do_start(art::RunID id, uint64_t timeout, uint64_t timestamp) override
Start the RoutingMasterCore.
void BootedEnter() override
Action taken upon entering the "Booted" state.
RoutingMasterCore implements the state machine for the RoutingMaster artdaq application. RoutingMasterCore collects tokens from receivers, and at regular intervals uses these tokens to build Routing Tables that are sent to the senders.
void process_event_table()
Main loop of the RoutingMasterCore. Determines when to send the next table update, asks the RoutingMasterPolicy for the table to send, and sends it.