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 catch (
const boost::exception& e)
63 TLOG(TLVL_ERROR) <<
"Caught boost::exception starting RoutingManagerCore thread: " << boost::diagnostic_information(e) <<
", errno=" << errno;
64 std::cerr <<
"Caught boost::exception starting RoutingManagerCore thread: " << boost::diagnostic_information(e) <<
", errno=" << errno << std::endl;
68 return external_request_status_;
74 external_request_status_ = routing_manager_ptr_->stop(timeout, timestamp);
75 if (!external_request_status_)
77 report_string_ =
"Error stopping ";
78 report_string_.append(app_name +
".");
82 if (routing_manager_thread_.joinable())
84 routing_manager_thread_.join();
87 TLOG_DEBUG(app_name +
"App") <<
"do_stop(uint64_t, uint64_t): "
88 <<
"Number of table entries sent = " << routing_manager_ptr_->get_update_count()
91 return external_request_status_;
97 external_request_status_ = routing_manager_ptr_->pause(timeout, timestamp);
98 if (!external_request_status_)
100 report_string_ =
"Error pausing ";
101 report_string_.append(app_name +
".");
103 if (routing_manager_thread_.joinable())
105 routing_manager_thread_.join();
108 TLOG_DEBUG(app_name +
"App") <<
"do_pause(uint64_t, uint64_t): "
109 <<
"Number of table entries sent = " << routing_manager_ptr_->get_update_count()
112 return external_request_status_;
118 external_request_status_ = routing_manager_ptr_->resume(timeout, timestamp);
119 if (!external_request_status_)
121 report_string_ =
"Error resuming ";
122 report_string_.append(app_name +
".");
125 boost::thread::attributes attrs;
126 attrs.set_stack_size(4096 * 2000);
128 TLOG(TLVL_INFO) <<
"Starting Routing Manager thread";
133 catch (boost::exception
const& e)
135 std::cerr <<
"Exception encountered starting Routing Manager thread: " << boost::diagnostic_information(e) <<
", errno=" << errno << std::endl;
138 TLOG(TLVL_INFO) <<
"Started Routing Manager thread";
140 return external_request_status_;
146 external_request_status_ = routing_manager_ptr_->shutdown(timeout);
147 if (!external_request_status_)
149 report_string_ =
"Error shutting down ";
150 report_string_.append(app_name +
".");
152 return external_request_status_;
158 external_request_status_ = routing_manager_ptr_->soft_initialize(pset, timeout, timestamp);
159 if (!external_request_status_)
161 report_string_ =
"Error soft-initializing ";
162 report_string_.append(app_name +
" ");
163 report_string_.append(
"with ParameterSet = \"" + pset.to_string() +
"\".");
165 return external_request_status_;
170 external_request_status_ = routing_manager_ptr_->reinitialize(pset, timeout, timestamp);
171 if (!external_request_status_)
173 report_string_ =
"Error reinitializing ";
174 report_string_.append(app_name +
" ");
175 report_string_.append(
"with ParameterSet = \"" + pset.to_string() +
"\".");
177 return external_request_status_;
182 TLOG_DEBUG(app_name +
"App") <<
"Booted state entry action called.";
188 routing_manager_ptr_.reset(
nullptr);
193 std::string resultString;
196 if (which ==
"transition_status")
198 if (report_string_.length() > 0) {
return report_string_; }
212 if (routing_manager_ptr_ !=
nullptr)
214 resultString.append(routing_manager_ptr_->report(which));
218 resultString.append(
"This RoutingManager has not yet been initialized and ");
219 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.