1 #ifndef ARTDAQ_DAQRATE_DATATRANSFERMANAGER_HH
2 #define ARTDAQ_DAQRATE_DATATRANSFERMANAGER_HH
4 #include "TRACE/tracemf.h"
5 #include "artdaq-core/Data/Fragment.hh"
7 #include "artdaq/DAQrate/detail/FragCounter.hh"
8 #include "artdaq/TransferPlugins/TransferInterface.hh"
14 #include <condition_variable>
20 class FragmentReceiverManager;
21 class FragmentStoreElement;
59 FragmentPtr
recvFragment(
int& rank,
size_t timeout_usec = 0);
103 void runReceiver_(
int);
105 bool fragments_ready_()
const;
107 int get_next_source_()
const;
109 std::atomic<bool> stop_requested_;
111 std::map<int, boost::thread> source_threads_;
112 std::map<int, std::unique_ptr<TransferInterface>> source_plugins_;
113 std::unordered_map<int, std::pair<size_t, double>> source_metric_data_;
114 std::unordered_map<int, std::chrono::steady_clock::time_point> source_metric_send_time_;
115 std::unordered_map<int, std::atomic<bool>> enabled_sources_;
116 std::unordered_map<int, std::atomic<bool>> running_sources_;
118 std::map<int, FragmentStoreElement> fragment_store_;
120 std::mutex input_cv_mutex_;
121 std::condition_variable input_cv_;
122 std::mutex output_cv_mutex_;
123 std::condition_variable output_cv_;
128 bool suppress_noisy_senders_;
129 size_t suppression_threshold_;
131 size_t receive_timeout_;
132 mutable int last_source_;
152 std::cout <<
"FragmentStoreElement CONSTRUCTOR" << std::endl;
170 std::unique_lock<std::mutex> lk(mutex_);
171 frags_.emplace_front(std::move(frag));
181 std::unique_lock<std::mutex> lk(mutex_);
182 frags_.emplace_back(std::move(frag));
192 std::unique_lock<std::mutex> lk(mutex_);
193 auto current_fragment = std::move(frags_.front());
195 empty_ = frags_.empty();
196 return current_fragment;
214 size_t size()
const {
return frags_.size(); }
217 mutable std::mutex mutex_;
219 std::atomic<bool> empty_;
220 size_t eod_marker_{0xFFFFFFFFFFFFFFFF};
227 return recv_frag_count_.
count();
234 return recv_frag_count_.slotCount(rank);
241 return recv_frag_size_.count();
243 #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.