1 #define TRACE_NAME "RoutingManagerApp"
5 #include "artdaq/Application/RoutingManagerApp.hh"
25 routing_manager_ptr_.reset(
nullptr);
26 routing_manager_ptr_ = std::make_unique<RoutingManagerCore>();
28 if (!external_request_status_)
32 report_string_.append(
"with ParameterSet = \"" + pset.to_string() +
"\".");
41 external_request_status_ = routing_manager_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 snprintf(tname,
sizeof(tname) - 1,
"%d-Routing", my_rank);
62 tname[
sizeof(tname) - 1] =
'\0';
63 auto handle = routing_manager_thread_.native_handle();
64 pthread_setname_np(handle, tname);
66 catch (
const boost::exception& e)
68 TLOG(TLVL_ERROR) <<
"Caught boost::exception starting RoutingManagerCore thread: " << boost::diagnostic_information(e) <<
", errno=" << errno;
69 std::cerr <<
"Caught boost::exception starting RoutingManagerCore thread: " << boost::diagnostic_information(e) <<
", errno=" << errno << std::endl;
73 return external_request_status_;
79 external_request_status_ = routing_manager_ptr_->stop(timeout, timestamp);
80 if (!external_request_status_)
82 report_string_ =
"Error stopping ";
83 report_string_.append(app_name +
".");
87 if (routing_manager_thread_.joinable())
89 routing_manager_thread_.join();
92 TLOG_DEBUG(app_name +
"App") <<
"do_stop(uint64_t, uint64_t): "
93 <<
"Number of table entries sent = " << routing_manager_ptr_->get_update_count()
96 return external_request_status_;
102 external_request_status_ = routing_manager_ptr_->pause(timeout, timestamp);
103 if (!external_request_status_)
105 report_string_ =
"Error pausing ";
106 report_string_.append(app_name +
".");
108 if (routing_manager_thread_.joinable())
110 routing_manager_thread_.join();
113 TLOG_DEBUG(app_name +
"App") <<
"do_pause(uint64_t, uint64_t): "
114 <<
"Number of table entries sent = " << routing_manager_ptr_->get_update_count()
117 return external_request_status_;
123 external_request_status_ = routing_manager_ptr_->resume(timeout, timestamp);
124 if (!external_request_status_)
126 report_string_ =
"Error resuming ";
127 report_string_.append(app_name +
".");
130 boost::thread::attributes attrs;
131 attrs.set_stack_size(4096 * 2000);
133 TLOG(TLVL_INFO) <<
"Starting Routing Manager thread";
138 snprintf(tname,
sizeof(tname) - 1,
"%d-Routing", my_rank);
139 tname[
sizeof(tname) - 1] =
'\0';
140 auto handle = routing_manager_thread_.native_handle();
141 pthread_setname_np(handle, tname);
143 catch (boost::exception
const& e)
145 std::cerr <<
"Exception encountered starting Routing Manager thread: " << boost::diagnostic_information(e) <<
", errno=" << errno << std::endl;
148 TLOG(TLVL_INFO) <<
"Started Routing Manager thread";
150 return external_request_status_;
156 external_request_status_ = routing_manager_ptr_->shutdown(timeout);
157 if (!external_request_status_)
159 report_string_ =
"Error shutting down ";
160 report_string_.append(app_name +
".");
162 return external_request_status_;
168 external_request_status_ = routing_manager_ptr_->soft_initialize(pset, timeout, timestamp);
169 if (!external_request_status_)
171 report_string_ =
"Error soft-initializing ";
172 report_string_.append(app_name +
" ");
173 report_string_.append(
"with ParameterSet = \"" + pset.to_string() +
"\".");
175 return external_request_status_;
180 external_request_status_ = routing_manager_ptr_->reinitialize(pset, timeout, timestamp);
181 if (!external_request_status_)
183 report_string_ =
"Error reinitializing ";
184 report_string_.append(app_name +
" ");
185 report_string_.append(
"with ParameterSet = \"" + pset.to_string() +
"\".");
187 return external_request_status_;
192 TLOG_DEBUG(app_name +
"App") <<
"Booted state entry action called.";
198 routing_manager_ptr_.reset(
nullptr);
203 std::string resultString;
206 if (which ==
"transition_status")
208 if (report_string_.length() > 0) {
return report_string_; }
222 if (routing_manager_ptr_ !=
nullptr)
224 resultString.append(routing_manager_ptr_->report(which));
228 resultString.append(
"This RoutingManager has not yet been initialized and ");
229 resultString.append(
"therefore can not provide reporting.");
bool do_resume(uint64_t timeout, uint64_t timestamp) override
Resume the RoutingManagerCore.
bool do_shutdown(uint64_t timeout) override
Shutdown the RoutingManagerCore.
bool do_stop(uint64_t timeout, uint64_t timestamp) override
Stop the RoutingManagerCore.
bool do_initialize(fhicl::ParameterSet const &pset, uint64_t timeout, uint64_t timestamp) override
Initialize the RoutingManagerCore.
bool external_request_status_
Whether the last command succeeded.
bool do_soft_initialize(fhicl::ParameterSet const &pset, uint64_t timeout, uint64_t timestamp) override
Soft-Initialize the RoutingManagerCore.
bool do_start(art::RunID id, uint64_t timeout, uint64_t timestamp) override
Start the RoutingManagerCore.
void BootedEnter() override
Action taken upon entering the "Booted" state.
std::string report(std::string const &) const override
If which is "transition_status", report the status of the last transition. Otherwise pass through to ...
std::string report_string_
Status information about the last command.
bool do_pause(uint64_t timeout, uint64_t timestamp) override
Pause the RoutingManagerCore.
void process_event_table()
Main loop of the RoutingManagerCore. Determines when to send the next table update, asks the RoutingManagerPolicy for the table to send, and sends it.
RoutingManagerApp()
RoutingManagerApp Constructor.
bool do_reinitialize(fhicl::ParameterSet const &pset, uint64_t timeout, uint64_t timestamp) override
Reinitialize the RoutingManagerCore.