10 #include "canvas/Utilities/Exception.h"
11 #include "cetlib_except/exception.h"
13 #define TRACE_NAME (app_name + "_RoutingMasterCore").c_str() // include these 2 first -
14 #include "artdaq/DAQdata/Globals.hh"
15 #include "artdaq-core/Data/Fragment.hh"
16 #include "artdaq-core/Utilities/ExceptionHandler.hh"
18 #include "artdaq/Application/RoutingMasterCore.hh"
19 #include "artdaq/Application/Routing/makeRoutingMasterPolicy.hh"
29 : received_token_counter_()
30 , shutdown_requested_(false)
31 , stop_requested_(false)
32 , pause_requested_(false)
37 TLOG(TLVL_DEBUG) <<
"Constructor" ;
40 metricMan = &metricMan_;
45 TLOG(TLVL_DEBUG) <<
"Destructor" ;
46 if (ev_token_receive_thread_.joinable()) ev_token_receive_thread_.join();
51 TLOG(TLVL_DEBUG) <<
"initialize method called with "
52 <<
"ParameterSet = \"" << pset.to_string()
56 fhicl::ParameterSet daq_pset;
59 daq_pset = pset.get<fhicl::ParameterSet>(
"daq");
64 <<
"Unable to find the DAQ parameters in the initialization "
65 <<
"ParameterSet: \"" + pset.to_string() +
"\"." ;
69 if (daq_pset.has_key(
"rank"))
71 if (my_rank >= 0 && daq_pset.get<
int>(
"rank") != my_rank) {
72 TLOG(TLVL_WARNING) <<
"Routing Master rank specified at startup is different than rank specified at configure! Using rank received at configure!";
74 my_rank = daq_pset.get<
int>(
"rank");
78 TLOG(TLVL_ERROR) <<
"Routing Master rank not specified at startup or in configuration! Aborting";
84 policy_pset_ = daq_pset.get<fhicl::ParameterSet>(
"policy");
89 <<
"Unable to find the policy parameters in the DAQ initialization ParameterSet: \"" + daq_pset.to_string() +
"\"." ;
94 fhicl::ParameterSet metric_pset;
97 metric_pset = daq_pset.get<fhicl::ParameterSet>(
"metrics");
101 if (metric_pset.is_empty())
103 TLOG(TLVL_INFO) <<
"No metric plugins appear to be defined" ;
107 metricMan_.initialize(metric_pset, app_name);
111 ExceptionHandler(ExceptionHandlerRethrow::no,
112 "Error loading metrics in RoutingMasterCore::initialize()");
116 auto policy_plugin_spec = policy_pset_.get<std::string>(
"policy",
"");
117 if (policy_plugin_spec.length() == 0)
120 <<
"No fragment generator (parameter name = \"policy\") was "
121 <<
"specified in the policy ParameterSet. The "
122 <<
"DAQ initialization PSet was \"" << daq_pset.to_string() <<
"\"." ;
131 std::stringstream exception_string;
132 exception_string <<
"Exception thrown during initialization of policy of type \""
133 << policy_plugin_spec <<
"\"";
135 ExceptionHandler(ExceptionHandlerRethrow::no, exception_string.str());
137 TLOG(TLVL_DEBUG) <<
"FHiCL parameter set used to initialize the policy which threw an exception: " << policy_pset_.to_string() ;
142 rt_priority_ = daq_pset.get<
int>(
"rt_priority", 0);
143 sender_ranks_ = daq_pset.get<std::vector<int>>(
"sender_ranks");
144 num_receivers_ = policy_->GetReceiverCount();
146 receive_ack_events_ = std::vector<epoll_event>(sender_ranks_.size());
147 receive_token_events_ = std::vector<epoll_event>(num_receivers_ + 1);
149 auto mode = daq_pset.get<
bool>(
"senders_send_by_send_count",
false);
151 max_table_update_interval_ms_ = daq_pset.get<
size_t>(
"table_update_interval_ms", 1000);
152 current_table_interval_ms_ = max_table_update_interval_ms_;
153 max_ack_cycle_count_ = daq_pset.get<
size_t>(
"table_ack_retry_count", 5);
154 receive_token_port_ = daq_pset.get<
int>(
"routing_token_port", 35555);
155 send_tables_port_ = daq_pset.get<
int>(
"table_update_port", 35556);
156 receive_acks_port_ = daq_pset.get<
int>(
"table_acknowledge_port", 35557);
157 send_tables_address_ = daq_pset.get<std::string>(
"table_update_address",
"227.128.12.28");
158 receive_address_ = daq_pset.get<std::string>(
"routing_master_hostname",
"localhost");
161 statsHelper_.createCollectors(daq_pset, 100, 30.0, 60.0, TABLE_UPDATES_STAT_KEY);
163 shutdown_requested_.store(
false);
164 start_recieve_token_thread_();
170 stop_requested_.store(
false);
171 pause_requested_.store(
false);
173 statsHelper_.resetStatistics();
176 metricMan_.do_start();
178 table_update_count_ = 0;
179 received_token_count_ = 0;
181 TLOG(TLVL_DEBUG) <<
"Started run " << std::to_string(run_id_.run()) ;
187 TLOG(TLVL_DEBUG) <<
"Stopping run " << std::to_string(run_id_.run())
188 <<
" after " << std::to_string(table_update_count_) <<
" table updates."
189 <<
" and " << received_token_count_ <<
" received tokens." ;
190 stop_requested_.store(
true);
196 TLOG(TLVL_DEBUG) <<
"Pausing run " << std::to_string(run_id_.run())
197 <<
" after " << table_update_count_ <<
" table updates."
198 <<
" and " << received_token_count_ <<
" received tokens." ;
199 pause_requested_.store(
true);
205 TLOG(TLVL_DEBUG) <<
"Resuming run " << run_id_.run() ;
207 pause_requested_.store(
false);
208 metricMan_.do_start();
214 shutdown_requested_.store(
true);
215 if (ev_token_receive_thread_.joinable()) ev_token_receive_thread_.join();
216 policy_.reset(
nullptr);
217 metricMan_.shutdown();
223 TLOG(TLVL_DEBUG) <<
"soft_initialize method called with "
224 <<
"ParameterSet = \"" << pset.to_string()
226 return initialize(pset, e, f);
231 TLOG(TLVL_DEBUG) <<
"reinitialize method called with "
232 <<
"ParameterSet = \"" << pset.to_string()
234 return initialize(pset, e, f);
239 if (rt_priority_ > 0)
241 #pragma GCC diagnostic push
242 #pragma GCC diagnostic ignored "-Wmissing-field-initializers"
243 sched_param s_param = {};
244 s_param.sched_priority = rt_priority_;
245 if (pthread_setschedparam(pthread_self(), SCHED_RR, &s_param))
246 TLOG(TLVL_WARNING) <<
"setting realtime priority failed" ;
247 #pragma GCC diagnostic pop
253 if (rt_priority_ > 0)
255 #pragma GCC diagnostic push
256 #pragma GCC diagnostic ignored "-Wmissing-field-initializers"
257 sched_param s_param = {};
258 s_param.sched_priority = rt_priority_;
259 int status = pthread_setschedparam(pthread_self(), SCHED_RR, &s_param);
263 <<
"Failed to set realtime priority to " << std::to_string(rt_priority_)
264 <<
", return code = " << status ;
266 #pragma GCC diagnostic pop
271 TLOG(TLVL_DEBUG) <<
"Sending initial table." ;
272 auto startTime = artdaq::MonitoredQuantity::getCurrentTime();
273 auto nextSendTime = startTime;
277 if (stop_requested_ || pause_requested_) {
break; }
278 startTime = artdaq::MonitoredQuantity::getCurrentTime();
280 if (startTime >= nextSendTime)
282 auto table = policy_->GetCurrentTable();
283 if (table.size() > 0)
285 send_event_table(table);
286 ++table_update_count_;
287 delta_time = artdaq::MonitoredQuantity::getCurrentTime() - startTime;
288 statsHelper_.addSample(TABLE_UPDATES_STAT_KEY, delta_time);
289 TLOG(16) <<
"process_fragments TABLE_UPDATES_STAT_KEY=" << std::to_string(delta_time) ;
293 TLOG(TLVL_WARNING) <<
"No tokens received in this update interval! This is most likely a Very Bad Thing!" ;
295 auto max_tokens = policy_->GetMaxNumberOfTokens();
298 auto frac = table.size() /
static_cast<double>(max_tokens);
299 if (frac > 0.75) current_table_interval_ms_ = 9 * current_table_interval_ms_ / 10;
300 if (frac < 0.5) current_table_interval_ms_ = 11 * current_table_interval_ms_ / 10;
301 if (current_table_interval_ms_ > max_table_update_interval_ms_) current_table_interval_ms_ = max_table_update_interval_ms_;
302 if (current_table_interval_ms_ < 1) current_table_interval_ms_ = 1;
304 nextSendTime = startTime + current_table_interval_ms_ / 1000.0;
305 TLOG(TLVL_DEBUG) <<
"current_table_interval_ms is now " << current_table_interval_ms_ ;
309 usleep(current_table_interval_ms_ * 10);
313 metricMan_.do_stop();
315 return table_update_count_;
321 if (table_socket_ == -1)
323 table_socket_ = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
324 if (table_socket_ < 0)
326 TLOG(TLVL_ERROR) <<
"I failed to create the socket for sending Data Requests! Errno: " << std::to_string(errno) ;
329 auto sts =
ResolveHost(send_tables_address_.c_str(), send_tables_port_, send_tables_addr_);
332 TLOG(TLVL_ERROR) <<
"Unable to resolve table_update_address" ;
337 if (receive_address_ !=
"localhost")
339 TLOG(TLVL_DEBUG) <<
"Making sure that multicast sending uses the correct interface for hostname " << receive_address_ ;
344 throw art::Exception(art::errors::Configuration) <<
"RoutingMasterCore: Unable to resolve routing_master_address" << std::endl;;
347 if (setsockopt(table_socket_, SOL_SOCKET, SO_REUSEADDR, &yes,
sizeof(yes)) < 0)
349 throw art::Exception(art::errors::Configuration) <<
350 "RoutingMasterCore: Unable to enable port reuse on table update socket" << std::endl;
354 if (setsockopt(table_socket_, IPPROTO_IP, IP_MULTICAST_LOOP, &yes,
sizeof(yes)) < 0)
356 TLOG(TLVL_ERROR) <<
"Unable to enable multicast loopback on table socket" ;
359 if (setsockopt(table_socket_, IPPROTO_IP, IP_MULTICAST_IF, &addr,
sizeof(addr)) == -1)
361 TLOG(TLVL_ERROR) <<
"Cannot set outgoing interface. Errno: " << std::to_string(errno) ;
365 if (setsockopt(table_socket_, SOL_SOCKET, SO_BROADCAST, (
void*)&yes,
sizeof(
int)) == -1)
367 TLOG(TLVL_ERROR) <<
"Cannot set request socket to broadcast. Errno: " << std::to_string(errno) ;
373 if (ack_socket_ == -1)
375 ack_socket_ = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
378 throw art::Exception(art::errors::Configuration) <<
"RoutingMasterCore: Error creating socket for receiving table update acks!" << std::endl;
382 struct sockaddr_in si_me_request;
385 if (setsockopt(ack_socket_, SOL_SOCKET, SO_REUSEADDR, &yes,
sizeof(yes)) < 0)
387 throw art::Exception(art::errors::Configuration) <<
388 "RoutingMasterCore: Unable to enable port reuse on ack socket" << std::endl;
391 memset(&si_me_request, 0,
sizeof(si_me_request));
392 si_me_request.sin_family = AF_INET;
393 si_me_request.sin_port = htons(receive_acks_port_);
394 si_me_request.sin_addr.s_addr = htonl(INADDR_ANY);
395 if (bind(ack_socket_, reinterpret_cast<struct sockaddr *>(&si_me_request),
sizeof(si_me_request)) == -1)
397 throw art::Exception(art::errors::Configuration) <<
398 "RoutingMasterCore: Cannot bind request socket to port " << receive_acks_port_ << std::endl;
401 TLOG(TLVL_DEBUG) <<
"Listening for acks on 0.0.0.0 port " << receive_acks_port_ ;
404 auto acks = std::unordered_map<int, bool>();
405 for (
auto& r : sender_ranks_)
410 auto start_time = std::chrono::steady_clock::now();
411 while (std::count_if(acks.begin(), acks.end(), [](std::pair<int, bool> p) {
return !p.second; }) > 0)
417 TLOG(TLVL_DEBUG) <<
"Sending table information for " << std::to_string(header.nEntries) <<
" events to multicast group " << send_tables_address_ <<
", port " << send_tables_port_ ;
418 if (sendto(table_socket_, &header,
sizeof(
detail::RoutingPacketHeader), 0, reinterpret_cast<struct sockaddr *>(&send_tables_addr_),
sizeof(send_tables_addr_)) < 0)
420 TLOG(TLVL_ERROR) <<
"Error sending request message header" ;
422 if (sendto(table_socket_, &packet[0], packetSize, 0, reinterpret_cast<struct sockaddr *>(&send_tables_addr_),
sizeof(send_tables_addr_)) < 0)
424 TLOG(TLVL_ERROR) <<
"Error sending request message data" ;
429 auto first = packet[0].sequence_id;
430 auto last = packet.rbegin()->sequence_id;
431 TLOG(TLVL_DEBUG) <<
"Expecting acks to have first= " << std::to_string(first) <<
", and last= " << std::to_string(last) ;
434 auto startTime = std::chrono::steady_clock::now();
435 while (std::count_if(acks.begin(), acks.end(), [](std::pair<int, bool> p) {
return !p.second; }) > 0)
437 auto table_ack_wait_time_ms = current_table_interval_ms_ / max_ack_cycle_count_;
438 if (TimeUtils::GetElapsedTimeMilliseconds(startTime) > table_ack_wait_time_ms)
440 if (counter > max_ack_cycle_count_ && table_update_count_ > 0)
442 TLOG(TLVL_ERROR) <<
"Did not receive acks from all senders after resending table " << std::to_string(counter)
443 <<
" times during the table_update_interval. Check the status of the senders!" ;
446 TLOG(TLVL_WARNING) <<
"Did not receive acks from all senders within the table_ack_wait_time. Resending table update" ;
450 TLOG(20) <<
"send_event_table: Polling Request socket for new requests" ;
457 if (errno == EWOULDBLOCK || errno == EAGAIN)
459 TLOG(20) <<
"send_event_table: No more ack datagrams on ack socket." ;
464 TLOG(TLVL_ERROR) <<
"An unexpected error occurred during ack packet receive" ;
470 TLOG(TLVL_DEBUG) <<
"Ack packet from rank " << buffer.
rank <<
" has first= " << std::to_string(buffer.
first_sequence_id)
474 TLOG(TLVL_DEBUG) <<
"Received table update acknowledgement from sender with rank " << std::to_string(buffer.
rank) <<
"." ;
475 acks[buffer.
rank] =
true;
476 TLOG(TLVL_DEBUG) <<
"There are now " << std::count_if(acks.begin(), acks.end(), [](std::pair<int, bool> p) {
return !p.second; })
477 <<
" acks outstanding" ;
481 if (!acks.count(buffer.
rank))
483 TLOG(TLVL_ERROR) <<
"Received acknowledgement from invalid rank " << buffer.
rank <<
"!"
484 <<
" Cross-talk between RoutingMasters means there's a configuration error!" ;
488 TLOG(TLVL_WARNING) <<
"Received acknowledgement from rank " << buffer.
rank
489 <<
" that had incorrect sequence ID information. Discarding." ;
494 usleep(table_ack_wait_time_ms * 1000 / 10);
499 artdaq::TimeUtils::seconds delta = std::chrono::steady_clock::now() - start_time;
500 metricMan->sendMetric(
"Avg Table Acknowledge Time", delta.count(),
"seconds", 3, MetricMode::Average);
504 void artdaq::RoutingMasterCore::receive_tokens_()
506 while (!shutdown_requested_)
508 TLOG(TLVL_DEBUG) <<
"Receive Token loop start" ;
509 if (token_socket_ == -1)
511 TLOG(TLVL_DEBUG) <<
"Opening token listener socket" ;
514 if (token_epoll_fd_ != -1) close(token_epoll_fd_);
515 struct epoll_event ev;
516 token_epoll_fd_ = epoll_create1(0);
517 ev.events = EPOLLIN | EPOLLPRI;
518 ev.data.fd = token_socket_;
519 if (epoll_ctl(token_epoll_fd_, EPOLL_CTL_ADD, token_socket_, &ev) == -1)
521 TLOG(TLVL_ERROR) <<
"Could not register listen socket to epoll fd" ;
525 if (token_socket_ == -1 || token_epoll_fd_ == -1)
527 TLOG(TLVL_DEBUG) <<
"One of the listen sockets was not opened successfully." ;
531 auto nfds = epoll_wait(token_epoll_fd_, &receive_token_events_[0], receive_token_events_.size(), current_table_interval_ms_);
534 perror(
"epoll_wait");
538 TLOG(TLVL_DEBUG) <<
"Received " << std::to_string(nfds) <<
" events" ;
539 for (
auto n = 0; n < nfds; ++n)
541 if (receive_token_events_[n].data.fd == token_socket_)
543 TLOG(TLVL_DEBUG) <<
"Accepting new connection on token_socket" ;
545 socklen_t arglen =
sizeof(addr);
546 auto conn_sock = accept(token_socket_, (
struct sockaddr *)&addr, &arglen);
554 receive_token_addrs_[conn_sock] = std::string(inet_ntoa(addr.sin_addr));
555 struct epoll_event ev;
556 ev.events = EPOLLIN | EPOLLET;
557 ev.data.fd = conn_sock;
558 if (epoll_ctl(token_epoll_fd_, EPOLL_CTL_ADD, conn_sock, &ev) == -1)
560 perror(
"epoll_ctl: conn_sock");
566 auto startTime = artdaq::MonitoredQuantity::getCurrentTime();
567 detail::RoutingToken buff;
568 auto sts = read(receive_token_events_[n].data.fd, &buff,
sizeof(detail::RoutingToken));
569 if (sts !=
sizeof(detail::RoutingToken) || buff.header != TOKEN_MAGIC)
571 TLOG(TLVL_ERROR) <<
"Received invalid token from " << receive_token_addrs_[receive_token_events_[n].data.fd] ;
575 TLOG(TLVL_DEBUG) <<
"Received token from " << std::to_string(buff.rank) <<
" indicating " << buff.new_slots_free <<
" slots are free." ;
576 received_token_count_ += buff.new_slots_free;
579 policy_->AddReceiverToken(buff.rank, buff.new_slots_free);
583 if (!received_token_counter_.count(buff.rank)) received_token_counter_[buff.rank] = 0;
584 received_token_counter_[buff.rank] += buff.new_slots_free;
585 TLOG(TLVL_DEBUG) <<
"RoutingMasterMode is RouteBySendCount. I have " << received_token_counter_[buff.rank] <<
" tokens for rank " << buff.rank <<
" and I need " << sender_ranks_.size() <<
"." ;
586 while (received_token_counter_[buff.rank] >= sender_ranks_.size())
588 TLOG(TLVL_DEBUG) <<
"RoutingMasterMode is RouteBySendCount. I have " << received_token_counter_[buff.rank] <<
" tokens for rank " << buff.rank <<
" and I need " << sender_ranks_.size()
589 <<
"... Sending token to policy" ;
590 policy_->AddReceiverToken(buff.rank, 1);
591 received_token_counter_[buff.rank] -= sender_ranks_.size();
595 auto delta_time = artdaq::MonitoredQuantity::getCurrentTime() - startTime;
596 statsHelper_.addSample(TOKENS_RECEIVED_STAT_KEY, delta_time);
603 void artdaq::RoutingMasterCore::start_recieve_token_thread_()
605 if (ev_token_receive_thread_.joinable()) ev_token_receive_thread_.join();
606 TLOG(TLVL_INFO) <<
"Starting Token Reception Thread" ;
607 ev_token_receive_thread_ = boost::thread(&RoutingMasterCore::receive_tokens_,
this);
612 std::string resultString;
615 auto tmpString = app_name +
" run number = " + std::to_string(run_id_.run())
616 +
", table updates sent = " + std::to_string(table_update_count_)
617 +
", Receiver tokens received = " + std::to_string(received_token_count_);
621 std::string artdaq::RoutingMasterCore::buildStatisticsString_()
const
623 std::ostringstream oss;
624 oss << app_name <<
" statistics:" << std::endl;
626 auto mqPtr = artdaq::StatisticsCollection::getInstance().getMonitoredQuantity(TABLE_UPDATES_STAT_KEY);
627 if (mqPtr.get() !=
nullptr)
629 artdaq::MonitoredQuantityStats stats;
630 mqPtr->getStats(stats);
631 oss <<
" Table Update statistics: "
632 << stats.recentSampleCount <<
" table updates sent at "
633 << stats.recentSampleRate <<
" table updates/sec, , monitor window = "
634 << stats.recentDuration <<
" sec" << std::endl;
635 oss <<
" Average times per table update: ";
636 if (stats.recentSampleRate > 0.0)
638 oss <<
" elapsed time = "
639 << (1.0 / stats.recentSampleRate) <<
" sec";
641 oss <<
", avg table acknowledgement wait time = "
642 << (mqPtr->getRecentValueSum() / sender_ranks_.size()) <<
" sec" << std::endl;
645 mqPtr = artdaq::StatisticsCollection::getInstance().getMonitoredQuantity(TOKENS_RECEIVED_STAT_KEY);
646 if (mqPtr.get() !=
nullptr)
648 artdaq::MonitoredQuantityStats stats;
649 mqPtr->getStats(stats);
650 oss <<
" Received Token statistics: "
651 << stats.recentSampleCount <<
" tokens received at "
652 << stats.recentSampleRate <<
" tokens/sec, , monitor window = "
653 << stats.recentDuration <<
" sec" << std::endl;
654 oss <<
" Average times per token: ";
655 if (stats.recentSampleRate > 0.0)
657 oss <<
" elapsed time = "
658 << (1.0 / stats.recentSampleRate) <<
" sec";
660 oss <<
", input token wait time = "
661 << mqPtr->getRecentValueSum() <<
" sec" << std::endl;
667 void artdaq::RoutingMasterCore::sendMetrics_()
669 auto mqPtr = artdaq::StatisticsCollection::getInstance().getMonitoredQuantity(TABLE_UPDATES_STAT_KEY);
670 if (mqPtr.get() !=
nullptr)
672 artdaq::MonitoredQuantityStats stats;
673 mqPtr->getStats(stats);
674 metricMan_.sendMetric(
"Table Update Count", static_cast<unsigned long>(stats.fullSampleCount),
"updates", 1, MetricMode::Accumulate);
675 metricMan_.sendMetric(
"Table Update Rate", stats.recentSampleRate,
"updates/sec", 1, MetricMode::Average);
676 metricMan_.sendMetric(
"Average Sender Acknowledgement Time", (mqPtr->getRecentValueSum() / sender_ranks_.size()),
"seconds", 3, MetricMode::Average);
679 mqPtr = artdaq::StatisticsCollection::getInstance().getMonitoredQuantity(TOKENS_RECEIVED_STAT_KEY);
680 if (mqPtr.get() !=
nullptr)
682 artdaq::MonitoredQuantityStats stats;
683 mqPtr->getStats(stats);
684 metricMan_.sendMetric(
"Receiver Token Count", static_cast<unsigned long>(stats.fullSampleCount),
"updates", 1, MetricMode::Accumulate);
685 metricMan_.sendMetric(
"Receiver Token Rate", stats.recentSampleRate,
"updates/sec", 1, MetricMode::Average);
686 metricMan_.sendMetric(
"Total Receiver Token Wait Time", mqPtr->getRecentValueSum(),
"seconds", 3, MetricMode::Average);
bool resume(uint64_t, uint64_t)
Resumes the RoutingMasterCore.
size_t 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.
void addMonitoredQuantityName(std::string const &statKey)
Add a MonitoredQuantity name to the list.
int ResolveHost(char const *host_in, in_addr &addr)
Convert a string hostname to a in_addr suitable for socket communication.
bool soft_initialize(fhicl::ParameterSet const &pset, uint64_t timeout, uint64_t timestamp)
Soft-Initializes the RoutingMasterCore.
static const std::string TOKENS_RECEIVED_STAT_KEY
Key for the Tokens Received MonitoredQuantity.
A row of the Routing Table.
bool reinitialize(fhicl::ParameterSet const &pset, uint64_t timeout, uint64_t timestamp)
Reinitializes the RoutingMasterCore.
bool start(art::RunID id, uint64_t, uint64_t)
Start the RoutingMasterCore.
A RoutingAckPacket contains the rank of the table receiver, plus the first and last sequence IDs in t...
RoutingMasterCore()
RoutingMasterCore Constructor.
Events should be routed by sequence ID (BR -> EB)
bool initialize(fhicl::ParameterSet const &pset, uint64_t, uint64_t)
Processes the initialize request.
The RoutingToken contains the magic bytes, the rank of the token sender, and the number of slots free...
int TCP_listen_fd(int port, int rcvbuf)
Create a TCP listening socket on the given port and INADDR_ANY, with the given receive buffer...
Fragment::sequence_id_t first_sequence_id
The first sequence ID in the received RoutingPacket.
bool pause(uint64_t, uint64_t)
Pauses the RoutingMasterCore.
Fragment::sequence_id_t last_sequence_id
The last sequence ID in the received RoutingPacket.
std::vector< RoutingPacketEntry > RoutingPacket
A RoutingPacket is simply a vector of RoutingPacketEntry objects. It is not suitable for network tran...
bool stop(uint64_t, uint64_t)
Stops the RoutingMasterCore.
int rank
The rank from which the RoutingAckPacket came.
std::unique_ptr< RoutingMasterPolicy > makeRoutingMasterPolicy(std::string const &policy_plugin_spec, fhicl::ParameterSet const &ps)
Load a RoutingMasterPolicy plugin.
std::string report(std::string const &) const
Send a report on the current status of the RoutingMasterCore.
static const std::string TABLE_UPDATES_STAT_KEY
Key for Table Update count MonnitoredQuantity.
bool shutdown(uint64_t)
Shuts Down the RoutingMasterCore.
void send_event_table(detail::RoutingPacket table)
Sends a detail::RoutingPacket to the table receivers.
Events should be routed by send count (EB -> Agg)