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);
100 void runReceiver_(
int);
102 bool fragments_ready_()
const;
104 int get_next_source_()
const;
106 std::atomic<bool> stop_requested_;
108 std::map<int, boost::thread> source_threads_;
109 std::map<int, std::unique_ptr<TransferInterface>> source_plugins_;
110 std::unordered_map<int, std::pair<size_t, double>> source_metric_data_;
111 std::unordered_map<int, std::chrono::steady_clock::time_point> source_metric_send_time_;
112 std::unordered_map<int, std::atomic<bool>> enabled_sources_;
113 std::unordered_map<int, std::atomic<bool>> running_sources_;
115 std::map<int, FragmentStoreElement> fragment_store_;
117 std::mutex input_cv_mutex_;
118 std::condition_variable input_cv_;
119 std::mutex output_cv_mutex_;
120 std::condition_variable output_cv_;
125 bool suppress_noisy_senders_;
126 size_t suppression_threshold_;
128 size_t receive_timeout_;
129 mutable int last_source_;
149 std::cout <<
"FragmentStoreElement CONSTRUCTOR" << std::endl;
167 std::unique_lock<std::mutex> lk(mutex_);
168 frags_.emplace_front(std::move(frag));
178 std::unique_lock<std::mutex> lk(mutex_);
179 frags_.emplace_back(std::move(frag));
189 std::unique_lock<std::mutex> lk(mutex_);
190 auto current_fragment = std::move(frags_.front());
192 empty_ = frags_.empty();
193 return current_fragment;
211 size_t size()
const {
return frags_.size(); }
214 mutable std::mutex mutex_;
216 std::atomic<bool> empty_;
217 size_t eod_marker_{0xFFFFFFFFFFFFFFFF};
224 return recv_frag_count_.
count();
231 return recv_frag_count_.slotCount(rank);
238 return recv_frag_size_.count();
240 #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.