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);
61 catch (
const boost::exception& e)
63 TLOG(TLVL_ERROR) <<
"Caught boost::exception starting RoutingMasterCore thread: " << boost::diagnostic_information(e) <<
", errno=" << errno;
64 std::cerr <<
"Caught boost::exception starting RoutingMasterCore thread: " << boost::diagnostic_information(e) <<
", errno=" << errno << std::endl;
68 return external_request_status_;
74 external_request_status_ = routing_master_ptr_->stop(timeout, timestamp);
75 if (!external_request_status_)
77 report_string_ =
"Error stopping ";
78 report_string_.append(app_name +
".");
82 if (routing_master_thread_.joinable()) routing_master_thread_.join();
84 TLOG_DEBUG(app_name +
"App") <<
"do_stop(uint64_t, uint64_t): "
85 <<
"Number of table entries sent = " << routing_master_ptr_->get_update_count()
88 return external_request_status_;
94 external_request_status_ = routing_master_ptr_->pause(timeout, timestamp);
95 if (!external_request_status_)
97 report_string_ =
"Error pausing ";
98 report_string_.append(app_name +
".");
100 if (routing_master_thread_.joinable()) routing_master_thread_.join();
102 TLOG_DEBUG(app_name +
"App") <<
"do_pause(uint64_t, uint64_t): "
103 <<
"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";
127 catch (boost::exception
const& e)
129 std::cerr <<
"Exception encountered starting Routing Master thread: " << boost::diagnostic_information(e) <<
", errno=" << errno << std::endl;
132 TLOG(TLVL_INFO) <<
"Started Routing Master thread";
134 return external_request_status_;
140 external_request_status_ = routing_master_ptr_->shutdown(timeout);
141 if (!external_request_status_)
143 report_string_ =
"Error shutting down ";
144 report_string_.append(app_name +
".");
146 return external_request_status_;
152 external_request_status_ = routing_master_ptr_->soft_initialize(pset, timeout, timestamp);
153 if (!external_request_status_)
155 report_string_ =
"Error soft-initializing ";
156 report_string_.append(app_name +
" ");
157 report_string_.append(
"with ParameterSet = \"" + pset.to_string() +
"\".");
159 return external_request_status_;
164 external_request_status_ = routing_master_ptr_->reinitialize(pset, timeout, timestamp);
165 if (!external_request_status_)
167 report_string_ =
"Error reinitializing ";
168 report_string_.append(app_name +
" ");
169 report_string_.append(
"with ParameterSet = \"" + pset.to_string() +
"\".");
171 return external_request_status_;
176 TLOG_DEBUG(app_name +
"App") <<
"Booted state entry action called.";
182 routing_master_ptr_.reset(
nullptr);
187 std::string resultString;
190 if (which ==
"transition_status")
192 if (report_string_.length() > 0) {
return report_string_; }
208 if (routing_master_ptr_.get() != 0)
210 resultString.append(routing_master_ptr_->report(which));
214 resultString.append(
"This RoutingMaster has not yet been initialized and ");
215 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.