Skip to content

Commit

Permalink
DEBUG
Browse files Browse the repository at this point in the history
  • Loading branch information
RoadRunnr committed May 13, 2024
1 parent fc4b045 commit 1e45e04
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/ergw_aaa_diameter_srv.erl
Original file line number Diff line number Diff line change
Expand Up @@ -368,29 +368,29 @@ relative_peer_load(OH, _, {Load, Cands} = State, Peers) ->
pick_peers(CandidateMap, Peers) ->
{_, Cands} = maps:fold(relative_peer_load(_, _, _, Peers), {infinity, []}, CandidateMap),

LoadStr =
["<table><tr><th>Peer</th><th>TS</th><th>Outstanding</th><th>Capacity</th><th>Rate</th>"
"<th>Tokens</th><th>Limited</th><th>PeerLoad</th><th>Cap</th><th>Token</th></tr>\n"] ++
[begin
#peer{last_ts = TS,
outstanding = Cnt,
capacity = Cap,
rate = Rate,
tokens = Tokens} = get_peer(OH, Peers),
CapLoad = erlang:floor((Cnt / Cap) * ?LoadBuckets),
TokLoad = erlang:floor(((1.0 - Tokens / Rate) * ?LoadBuckets)),
PeerLoad = CapLoad + TokLoad,
io_lib:format("<tr><td>~p</td><td>~s</td><td>~p</td><td>~p</td><td>~p</td><td>~p</td><td>~p</td><td>~p</td><td>~p</td><td>~p</td></tr>\n",
[OH,
calendar:system_time_to_rfc3339(
TS + erlang:time_offset(microsecond), [{unit, microsecond}]),
Cnt, Cap, Rate, Tokens, Tokens < Rate,
PeerLoad, CapLoad, TokLoad])
end ||
OH <- maps:keys(CandidateMap)] ++
["</table"],
ct:pal(LoadStr),
ct:pal("PeerLoad Candidates: ~p", [Cands]),
%% LoadStr =
%% ["<table><tr><th>Peer</th><th>TS</th><th>Outstanding</th><th>Capacity</th><th>Rate</th>"
%% "<th>Tokens</th><th>Limited</th><th>PeerLoad</th><th>Cap</th><th>Token</th></tr>\n"] ++
%% [begin
%% #peer{last_ts = TS,
%% outstanding = Cnt,
%% capacity = Cap,
%% rate = Rate,
%% tokens = Tokens} = get_peer(OH, Peers),
%% CapLoad = erlang:floor((Cnt / Cap) * ?LoadBuckets),
%% TokLoad = erlang:floor(((1.0 - Tokens / Rate) * ?LoadBuckets)),
%% PeerLoad = CapLoad + TokLoad,
%% io_lib:format("<tr><td>~p</td><td>~s</td><td>~p</td><td>~p</td><td>~p</td><td>~p</td><td>~p</td><td>~p</td><td>~p</td><td>~p</td></tr>\n",
%% [OH,
%% calendar:system_time_to_rfc3339(
%% TS + erlang:time_offset(microsecond), [{unit, microsecond}]),
%% Cnt, Cap, Rate, Tokens, Tokens < Rate,
%% PeerLoad, CapLoad, TokLoad])
%% end ||
%% OH <- maps:keys(CandidateMap)] ++
%% ["</table"],
%% ct:pal(LoadStr),
%% ct:pal("PeerLoad Candidates: ~p", [Cands]),

N = rand:uniform(length(Cands)),
OH = lists:nth(N, Cands),
Expand Down

0 comments on commit 1e45e04

Please sign in to comment.