1 #include "artdaq/Application/Routing/RoutingMasterPolicy.hh"
2 #include "artdaq/Application/Routing/PolicyMacros.hh"
3 #include <fhiclcpp/ParameterSet.h>
42 int tokenUsagePercent_;
47 , tokenUsagePercent_(ps.get<int>(
"tokens_used_per_table_percent", 50))
53 std::map<int, int> table;
55 for (
auto token : *tokens)
62 int tokensToUse = ceil(tokenCount * tokenUsagePercent_ / 100.0);
68 bool breakCondition =
false;
69 while (table[r.first] > 0) {
73 if(tokensUsed >= tokensToUse)
75 breakCondition =
true;
79 if (breakCondition)
break;
84 for (
auto i = 0; i < r.second; ++i)
86 tokens->push_back(r.first);
A row of the Routing Table.
detail::RoutingPacket GetCurrentTable() override
Apply the policy to the current tokens.
The interface through which RoutingMasterCore obtains Routing Tables using received Routing Tokens...
CapacityTestPolicy(fhicl::ParameterSet ps)
CapacityTestPolicy Constructor.
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.
A RoutingMasterPolicy which tries to fully load the first receiver, then the second, and so on.
virtual ~CapacityTestPolicy()=default
Default virtual Destructor.