1 #ifndef artdaq_Application_MPI2_RoutingMasterCore_hh
2 #define artdaq_Application_MPI2_RoutingMasterCore_hh
8 #include <netinet/in.h>
11 #include "fhiclcpp/ParameterSet.h"
12 #include "canvas/Persistency/Provenance/RunID.h"
14 #include "artdaq-utilities/Plugins/MetricManager.hh"
16 #include "artdaq/DAQrate/StatisticsHelper.hh"
17 #include "artdaq/DAQrate/detail/RoutingPacket.hh"
18 #include "artdaq/RoutingPolicies/RoutingMasterPolicy.hh"
19 #include "artdaq/DAQrate/detail/FragCounter.hh"
23 class RoutingMasterCore;
81 bool initialize(fhicl::ParameterSet
const& pset, uint64_t, uint64_t);
88 bool start(art::RunID
id, uint64_t, uint64_t);
94 bool stop(uint64_t, uint64_t);
100 bool pause(uint64_t, uint64_t);
106 bool resume(uint64_t, uint64_t);
121 bool soft_initialize(fhicl::ParameterSet
const& pset, uint64_t timeout, uint64_t timestamp);
130 bool reinitialize(fhicl::ParameterSet
const& pset, uint64_t timeout, uint64_t timestamp);
155 std::string
report(std::string
const&)
const;
164 void receive_tokens_();
165 void start_recieve_token_thread_();
169 fhicl::ParameterSet policy_pset_;
172 size_t max_table_update_interval_ms_;
173 size_t max_ack_cycle_count_;
175 std::atomic<size_t> current_table_interval_ms_;
176 std::atomic<size_t> table_update_count_;
177 std::atomic<size_t> received_token_count_;
178 std::unordered_map<int, size_t> received_token_counter_;
180 std::vector<int> sender_ranks_;
181 size_t num_receivers_;
183 std::unique_ptr<RoutingMasterPolicy> policy_;
185 std::atomic<bool> shutdown_requested_;
186 std::atomic<bool> stop_requested_;
187 std::atomic<bool> pause_requested_;
192 std::string buildStatisticsString_()
const;
199 int receive_token_port_;
200 int send_tables_port_;
201 int receive_acks_port_;
202 std::string send_tables_address_;
203 std::string receive_address_;
204 struct sockaddr_in send_tables_addr_;
205 std::vector<epoll_event> receive_ack_events_;
206 std::vector<epoll_event> receive_token_events_;
207 std::unordered_map<int, std::string> receive_token_addrs_;
214 mutable std::mutex request_mutex_;
215 boost::thread ev_token_receive_thread_;
This class manages MonitoredQuantity instances for the *Core classes.
bool resume(uint64_t, uint64_t)
Resumes the RoutingMasterCore.
RoutingMasterMode
Mode indicating whether the RoutingMaster is routing events by Sequence ID or by Send Count...
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.
bool reinitialize(fhicl::ParameterSet const &pset, uint64_t timeout, uint64_t timestamp)
Reinitializes the RoutingMasterCore.
RoutingMasterCore & operator=(RoutingMasterCore const &)=delete
Copy Assignment operator is deleted.
bool start(art::RunID id, uint64_t, uint64_t)
Start the RoutingMasterCore.
RoutingMasterCore()
RoutingMasterCore Constructor.
bool initialize(fhicl::ParameterSet const &pset, uint64_t, uint64_t)
Processes the initialize request.
size_t get_update_count() const
Get the number of table updates sent by this RoutingMaster this run.
bool pause(uint64_t, uint64_t)
Pauses the RoutingMasterCore.
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.
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.
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.
void send_event_table(detail::RoutingPacket table)
Sends a detail::RoutingPacket to the table receivers.