Skip to content

Commit

Permalink
Merge pull request #558 from basho/bug/mw/repl-wm-stats-mutliple-fs-s…
Browse files Browse the repository at this point in the history
…ource-2.0

Fixes wm stats for multiple client connections
  • Loading branch information
cmeiklejohn committed Mar 10, 2014
2 parents 179d0b7 + 5a1b14d commit 8e759f6
Showing 1 changed file with 48 additions and 8 deletions.
56 changes: 48 additions & 8 deletions src/riak_repl_wm_stats.erl
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,18 @@ jsonify_stats([{K, V}|T], Acc) when is_atom(K) and is_tuple(V)
jsonify_stats([{active, false}, {reactivation_scheduled, true} | T], Acc)
end;
jsonify_stats([{K,V}|T], Acc) when is_atom(K)
andalso (K == server_stats orelse K == client_stats) ->
case V of
[{Pid, Mq, {status, Stats}}] ->
andalso (K == server_stats orelse K == client_stats), is_list(V) ->
StackedStats = lists:foldl(fun
({Pid, Mq, {status, Stats}}, FoldAcc) ->
FormattedPid = format_pid(Pid),
NewStats = {status, lists:map(fun format_pid_stat/1, Stats)},
% could be client or server pid
ServerPid = [{pid, FormattedPid}],
jsonify_stats([NewStats | T], [Mq | [ServerPid | Acc]]);
[] ->
jsonify_stats(T, Acc)
end;
ServerPid = {pid, FormattedPid},
[ServerPid, Mq, NewStats] ++ FoldAcc;
(_, FoldAcc) ->
FoldAcc
end, [], V),
jsonify_stats(StackedStats ++ T, Acc);
jsonify_stats([{S,IP,Port}|T], Acc) when is_atom(S) andalso is_list(IP) andalso is_integer(Port) ->
jsonify_stats(T, [{S,
list_to_binary(IP++":"++integer_to_list(Port))}|Acc]);
Expand Down Expand Up @@ -429,6 +430,45 @@ jsonify_stats_test_() ->
_Result = mochijson2:encode({struct, Actual}) % fail if crash
end},

{"multiple fs client connections",
fun() ->
Pid = spawn(fun() -> ok end),
Actual = [{client_stats, [
{Pid, {message_queue_len,0}, {status, [
{node,'riak@test-riak-1'},
{site,"test3"},
{strategy,riak_repl_keylist_server},
{fullsync_worker,Pid},
{queue_pid,Pid},
{dropped_count,0},
{queue_length,0},
{queue_byte_size,0},
{queue_max_size,104857600},
{queue_percentage,0},
{queue_pending,0},
{queue_max_pending,5},
{state,wait_for_partition}
]}},
{Pid, {message_queue_len,0}, {status, [
{node,'riak@test-riak-1'},
{site,"site2"},
{strategy,riak_repl_keylist_server},
{fullsync_worker,Pid},
{queue_pid,Pid},
{dropped_count,0},
{queue_length,0},
{queue_byte_size,0},
{queue_max_size,104857600},
{queue_percentage,0},
{queue_pending,0},
{queue_max_pending,5},
{state,wait_for_partition}
]}}
]}],
Jsonified = jsonify_stats(Actual, []),
_ = mochijson2:encode({struct, Jsonified})
end},

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% tests during basho bench, bnw fullsync, 1.2 + 1.3 realtime, source side

Expand Down

0 comments on commit 8e759f6

Please sign in to comment.