1 #ifndef ARTDAQ_DAQRATE_DATATRANSFERMANAGER_HH
2 #define ARTDAQ_DAQRATE_DATATRANSFERMANAGER_HH
4 #include <condition_variable>
9 #include "fhiclcpp/fwd.h"
11 #include "artdaq-core/Data/Fragment.hh"
12 #include "artdaq-utilities/Plugins/MetricManager.hh"
13 #include "artdaq/DAQrate/detail/FragCounter.hh"
14 #include "artdaq/TransferPlugins/TransferInterface.hh"
17 class FragmentReceiverManager;
18 class FragmentStoreElement;
56 FragmentPtr
recvFragment(
int& rank,
size_t timeout_usec = 0);
95 void runReceiver_(
int);
97 bool fragments_ready_()
const;
99 int get_next_source_()
const;
101 std::atomic<bool> stop_requested_;
103 std::map<int, boost::thread> source_threads_;
104 std::map<int, std::unique_ptr<TransferInterface>> source_plugins_;
105 std::unordered_map<int, std::pair<size_t, double>> source_metric_data_;
106 std::unordered_map<int, std::chrono::steady_clock::time_point> source_metric_send_time_;
107 std::unordered_map<int, std::atomic<bool>> enabled_sources_;
108 std::unordered_map<int, std::atomic<bool>> running_sources_;
110 std::map<int, FragmentStoreElement> fragment_store_;
112 std::mutex input_cv_mutex_;
113 std::condition_variable input_cv_;
114 std::mutex output_cv_mutex_;
115 std::condition_variable output_cv_;
120 bool suppress_noisy_senders_;
121 size_t suppression_threshold_;
123 size_t receive_timeout_;
124 mutable int last_source_;
145 std::cout <<
"FragmentStoreElement CONSTRUCTOR" << std::endl;
163 std::unique_lock<std::mutex> lk(mutex_);
164 frags_.emplace_front(std::move(frag));
174 std::unique_lock<std::mutex> lk(mutex_);
175 frags_.emplace_back(std::move(frag));
185 std::unique_lock<std::mutex> lk(mutex_);
186 auto current_fragment = std::move(frags_.front());
188 empty_ = frags_.size() == 0;
189 return current_fragment;
207 size_t size()
const {
return frags_.size(); }
210 mutable std::mutex mutex_;
212 std::atomic<bool> empty_;
220 return recv_frag_count_.
count();
227 return recv_frag_count_.slotCount(rank);
234 return recv_frag_size_.count();
236 #endif //ARTDAQ_DAQRATE_DATATRANSFERMANAGER_HH
void start_threads()
Start receiver threads for all enabled sources.
std::set< int > enabled_sources() const
Get the list of enabled sources.
void emplace_front(FragmentPtr &&frag)
Add a Fragment to the front of the FragmentStoreElement.
size_t byteCount() const
Get the total size of all data recieved by this FragmentReceiverManager.
void emplace_back(FragmentPtr &&frag)
Add a Fragment to the end of the FragmentStoreElement.
This class contains tracking information for all Fragment objects which have been received from a spe...
size_t count() const
Return the count of Fragment objects received by this FragmentReceiverManager.
virtual ~FragmentReceiverManager()
FragmentReceiverManager Destructor.
Receives Fragment objects from one or more DataSenderManager instances using TransferInterface plugin...
Keep track of the count of Fragments received from a set of sources.
bool empty() const
Are any Fragment objects contained in this FragmentStoreElement?
FragmentReceiverManager(const fhicl::ParameterSet &ps)
FragmentReceiverManager Constructor.
void SetEndOfData(size_t eod)
Set the End-Of-Data marker value for this Receiver.
size_t size() const
Get the number of Fragments stored in this FragmentStoreElement.
FragmentPtr recvFragment(int &rank, size_t timeout_usec=0)
Receive a Fragment.
size_t slotCount(size_t rank) const
Get the count of Fragment objects received by this FragmentReceiverManager from a given source...
size_t GetEndOfData() const
Get the value of the End-Of-Data marker for this Receiver.
FragmentStoreElement()
FragmentStoreElement Constructor.
std::set< int > running_sources() const
Get the list of sources which are still receiving data.
FragmentPtr front()
Remove the first Fragment from the FragmentStoreElement and return it.
size_t count() const
Get the total number of Fragments received.