Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes wm stats for multiple client connections #558

Merged
merged 1 commit into from Mar 10, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 48 additions & 8 deletions src/riak_repl_wm_stats.erl
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