1 #ifndef artdaq_Application_MPI2_RoutingManagerCore_hh
2 #define artdaq_Application_MPI2_RoutingManagerCore_hh
4 #include "artdaq/DAQrate/StatisticsHelper.hh"
5 #include "artdaq/DAQrate/detail/RoutingPacket.hh"
6 #include "artdaq/DAQrate/detail/TokenReceiver.hh"
7 #include "artdaq/RoutingPolicies/RoutingManagerPolicy.hh"
9 #include "canvas/Persistency/Provenance/RunID.h"
10 #include "fhiclcpp/ParameterSet.h"
12 #include <boost/thread.hpp>
15 #include <netinet/in.h>
16 #include <sys/epoll.h>
26 class RoutingManagerCore;
88 bool initialize(fhicl::ParameterSet
const& pset, uint64_t, uint64_t);
95 bool start(art::RunID
id, uint64_t, uint64_t);
101 bool stop(uint64_t, uint64_t);
107 bool pause(uint64_t, uint64_t);
113 bool resume(uint64_t, uint64_t);
128 bool soft_initialize(fhicl::ParameterSet
const& pset, uint64_t timeout, uint64_t timestamp);
137 bool reinitialize(fhicl::ParameterSet
const& pset, uint64_t timeout, uint64_t timestamp);
162 std::string
report(std::string
const&)
const;
173 fhicl::ParameterSet policy_pset_;
174 fhicl::ParameterSet token_receiver_pset_;
177 size_t max_table_update_interval_ms_;
178 std::atomic<size_t> current_table_interval_ms_;
179 double table_update_high_fraction_;
180 double table_update_low_fraction_;
181 std::atomic<size_t> table_update_count_;
183 std::shared_ptr<RoutingManagerPolicy> policy_;
184 std::unique_ptr<TokenReceiver> token_receiver_;
186 std::atomic<bool> shutdown_requested_;
187 std::atomic<bool> stop_requested_;
188 std::atomic<bool> pause_requested_;
190 std::unique_ptr<boost::thread> listen_thread_;
191 int table_listen_port_;
193 std::map<int, std::set<int>> connected_fds_;
195 mutable std::mutex fd_mutex_;
198 std::shared_ptr<artdaq::StatisticsHelper> statsHelperPtr_;
200 std::string buildStatisticsString_()
const;
206 int find_fd_(
int fd)
const;
bool shutdown(uint64_t)
Shuts Down the RoutingManagerCore.
bool start(art::RunID id, uint64_t, uint64_t)
Start the RoutingManagerCore.
RoutingManagerCore implements the state machine for the RoutingManager artdaq application. RoutingManagerCore collects tokens from receivers, and at regular intervals uses these tokens to build Routing Tables that are sent to the senders.
static const std::string TABLE_UPDATES_STAT_KEY
Key for Table Update count MonnitoredQuantity.
bool pause(uint64_t, uint64_t)
Pauses the RoutingManagerCore.
RoutingManagerCore & operator=(RoutingManagerCore const &)=delete
Copy Assignment operator is deleted.
size_t get_update_count() const
Get the number of table updates sent by this RoutingManager this run.
std::vector< RoutingPacketEntry > RoutingPacket
A RoutingPacket is simply a vector of RoutingPacketEntry objects. It is not suitable for network tran...
bool initialize(fhicl::ParameterSet const &pset, uint64_t, uint64_t)
Processes the initialize request.
bool stop(uint64_t, uint64_t)
Stops 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.
bool soft_initialize(fhicl::ParameterSet const &pset, uint64_t timeout, uint64_t timestamp)
Soft-Initializes the RoutingManagerCore.
static const std::string TOKENS_RECEIVED_STAT_KEY
Key for the Tokens Received MonitoredQuantity.
std::string report(std::string const &) const
Send a report on the current status of the RoutingManagerCore.
bool resume(uint64_t, uint64_t)
Resumes the RoutingManagerCore.
void send_event_table(detail::RoutingPacket packet)
Sends a detail::RoutingPacket to the table receivers.
RoutingManagerCore()
RoutingManagerCore Constructor.
static const std::string CURRENT_TABLE_INTERVAL_STAT_KEY
Key for the Current Table Interval MonitoredQuantity.
bool reinitialize(fhicl::ParameterSet const &pset, uint64_t timeout, uint64_t timestamp)
Reinitializes the RoutingManagerCore.