1 #include "artdaq/Application/Routing/RoutingMasterPolicy.hh"
2 #include "artdaq/Application/Routing/PolicyMacros.hh"
3 #include "fhiclcpp/ParameterSet.h"
5 #define TRACE_NAME "RoundRobin_policy"
25 , use_all_tokens_(ps.get<bool>(
"use_all_tokens", false))
49 TLOG(12) <<
"RoundRobinPolicy::GetCurrentTable start";
51 TLOG(13) <<
"RoundRobinPolicy::GetCurrentTable token list size is " << tokens->size();
52 std::map<int, int> table;
53 for (
auto token : *tokens.get())
55 TLOG(14) <<
"RoundRobinPolicy::GetCurrentTable adding token for rank " << token <<
" to table";
59 TLOG(13) <<
"RoundRobinPolicy::GetCurrentTable table size is " << table.size() <<
", token list size is " << tokens->size();
62 auto endCondition = table.size() < (use_all_tokens_ ? 1 :
GetReceiverCount());
63 TLOG(15) <<
"RoundRobinPolicy::GetCurrentTable initial endCondition is " << endCondition;
67 for (
auto it = table.begin(); it != table.end();)
69 TLOG(16) <<
"RoundRobinPolicy::GetCurrentTable assigning sequenceID " <<
next_sequence_id_ <<
" to rank " << it->first;
73 if (table[it->first] <= 0) it = table.erase(it);
81 for(
auto i = 0;i < r.second; ++i)
83 tokens->push_back(r.first);
86 TLOG(13) <<
"RoundRobinPolicy::GetCurrentTable unused tokens for " << tokens->size() <<
" ranks will be saved for later";
89 TLOG(12) <<
"RoundRobinPolicy::GetCurrentTable return with table size " << output.size();
A row of the Routing Table.
A RoutingMasterPolicy which evenly distributes Sequence IDs to all receivers. If an uneven number of ...
virtual ~RoundRobinPolicy()=default
Default virtual Destructor.
The interface through which RoutingMasterCore obtains Routing Tables using received Routing Tokens...
detail::RoutingPacket GetCurrentTable() override
Create a Routing Table using the tokens that have been received.
std::vector< RoutingPacketEntry > RoutingPacket
A RoutingPacket is simply a vector of RoutingPacketEntry objects. It is not suitable for network tran...
Fragment::sequence_id_t next_sequence_id_
The next sequence ID to be assigned.
std::unique_ptr< std::deque< int > > getTokensSnapshot()
Gets the current token list, used for building Routing Tables.
void addUnusedTokens(std::unique_ptr< std::deque< int >> tokens)
If necessary, return unused tokens to the token list, for subsequent updates.
RoundRobinPolicy(fhicl::ParameterSet ps)
RoundRobinPolicy Constructor.
size_t GetReceiverCount() const
Get the number of configured receivers.