Skip to content
Browse files

Move core read-only stats from riak_kv to riak_core

  • Loading branch information...
1 parent 519c80b commit 53e9b15aa54060de2cf45e73a869c51c3c56f17f @russelldb committed Apr 30, 2012
View
5 ebin/riak_core.app
@@ -40,10 +40,15 @@
riak_core_metric,
riak_core_metric_counter,
riak_core_metric_duration,
+ riak_core_metric_erl,
+ riak_core_metric_env,
riak_core_metric_histogram,
+ riak_core_metric_host,
riak_core_metric_meter,
riak_core_metric_proc,
+ riak_core_metric_ring,
riak_core_metric_sup,
+ riak_core_metric_vnodeq,
riak_core_nodeid,
riak_core_node_watcher,
riak_core_node_watcher_events,
View
13 src/riak_core_metric.erl
@@ -29,19 +29,6 @@
-include_lib("eunit/include/eunit.hrl").
-endif.
--export_type([stat_specs/0]).
-
--type stat_specs() :: [stat()].
-
--type stat() :: {Name :: atom(),
- Args :: [type() | group() | presentation()]
- }.
-
--type type() :: {type, counter | meter | histogram | duration}.
--type group() :: {group, GroupName::atom()}.
--type presentation() :: {presentation, [{Name :: atom(),
- Spec :: riak_core_metric_duration:display_spec() |
- riak_core_metric_histogram:display_spec()}]}.
behaviour_info(callbacks) ->
[{new, 0},
{value, 3},
View
47 src/riak_core_metric_env.erl
@@ -0,0 +1,47 @@
+%%
+%% Copyright (c) 2007-2012 Basho Technologies, Inc. All Rights Reserved.
+%%
+%% This file is provided to you under the Apache License,
+%% Version 2.0 (the "License"); you may not use this file
+%% except in compliance with the License. You may obtain
+%% a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing,
+%% software distributed under the License is distributed on an
+%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+%% KIND, either express or implied. See the License for the
+%% specific language governing permissions and limitations
+%% under the License.
+%%
+%% -------------------------------------------------------------------
+
+%% TODO provide access to app envs by app/name
+-module(riak_core_metric_env).
+
+-behaviour(riak_core_metric).
+
+-export([new/0, value/3, value/4, update/2, options/1]).
+
+new() ->
+ env.
+
+options(env) ->
+ [{App, [K || {K, _V} <- app_helper:get_env(App)]} || {App, _Mod} <- [{riak_core, vnode}|riak_core:vnode_modules()]].
+
+update(_Arg, env) ->
+ env.
+
+value(Level, _Name, env) when Level < 3 ->
+ [];
+value(_Level, _Name, env) ->
+ [{App, [E || E <- app_helper:get_env(App)]} || {App, _Mod} <- [{riak_core, vnode}|riak_core:vnode_modules()]].
+
+value(_Level, App, _Name, env) when is_atom(App)->
+ app_helper:get_env(App);
+value(_Level, [App, Var], _Name, env) ->
+ {riak_core_metric:join_as_atom([App, '_', Var]), app_helper:get_env(App, Var)}.
+
+
+
View
105 src/riak_core_metric_erl.erl
@@ -0,0 +1,105 @@
+%%
+%% Copyright (c) 2007-2012 Basho Technologies, Inc. All Rights Reserved.
+%%
+%% This file is provided to you under the Apache License,
+%% Version 2.0 (the "License"); you may not use this file
+%% except in compliance with the License. You may obtain
+%% a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing,
+%% software distributed under the License is distributed on an
+%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+%% KIND, either express or implied. See the License for the
+%% specific language governing permissions and limitations
+%% under the License.
+%%
+%% -------------------------------------------------------------------
+
+%% @doc Read only stat for cpu
+-module(riak_core_metric_erl).
+
+-behaviour(riak_core_metric).
+
+-export([new/0, value/3, value/4, update/2, options/1]).
+
+new() ->
+ erl.
+
+options(erl) ->
+ [{memory, [K || {K, _} <- erlang:memory()]},
+ {app, [A || {A,_, _} <- application:which_applications()]},
+ {system, system(1)}].
+
+update(_Arg, erl) ->
+ erl.
+
+value(Level, _Name, erl) ->
+ lists:flatten([value(Field, Level) || Field <- [memory, app, system]]).
+
+value(Level, Field, _Name, erl) when is_atom(Field) ->
+ value(Field, Level);
+value(_Level, [app, Elem], _Name, erl) ->
+ Stat = value(app, 5),
+ ElemName = riak_core_metric:join_as_atom([Elem, '_', version]),
+ proplists:lookup(ElemName, Stat);
+value(_Level, [system, Elem], _Name, erl) ->
+ system_info(Elem);
+value(_Level, [Field, Elem], _Name, erl) ->
+ Stat = value(Field, 5),
+ ElemName = riak_core_metric:join_as_atom([Field, '_', Elem]),
+ proplists:lookup(ElemName, Stat).
+
+value(memory, 0) ->
+ [{list_to_atom("memory_" ++ atom_to_list(K)), V} || {K,V} <- erlang:memory(),
+ lists:member(K, memory(0))];
+value(memory, _Level) ->
+ [{list_to_atom("memory_" ++ atom_to_list(K)), V} || {K,V} <- erlang:memory()];
+value(app, Level) when Level < 2 ->
+ [];
+value(app, Level) when Level > 1 ->
+ [{list_to_atom(atom_to_list(A) ++ "_version"), list_to_binary(V)}
+ || {A,_,V} <- application:which_applications()];
+value(system, Level) ->
+ [system_info(Field) || Field <- system(Level)].
+
+system_info(nodename) ->
+ {nodename, node()};
+system_info(connected_nodes) ->
+ {connected_nodes, nodes()};
+system_info(system_version) ->
+ {sys_system_version, list_to_binary(string:strip(erlang:system_info(system_version), right, $\n))};
+system_info(threads_enabled) ->
+ {sys_threads_enabled, erlang:system_info(threads)};
+system_info(Field) ->
+ Key = riak_core_metric:join_as_atom([sys, '_', Field]),
+ Val = maybe_to_binary(erlang:system_info(Field)),
+ {Key, Val}.
+
+maybe_to_binary(SysInfo) when is_list(SysInfo) ->
+ list_to_binary(SysInfo);
+maybe_to_binary(SysInfo) ->
+ SysInfo.
+
+memory(0) ->
+ [total, processes].
+
+system(0) ->
+ [nodename, connected_nodes];
+system(_Level) ->
+ system(0) ++ system_info().
+
+system_info() ->
+ [driver_version,
+ global_heaps_size,
+ heap_type,
+ logical_processors,
+ otp_release,
+ process_count,
+ smp_support,
+ system_version,
+ system_architecture,
+ threads_enabled,
+ thread_pool_size,
+ wordsize].
View
61 src/riak_core_metric_host.erl
@@ -0,0 +1,61 @@
+%%
+%% Copyright (c) 2007-2012 Basho Technologies, Inc. All Rights Reserved.
+%%
+%% This file is provided to you under the Apache License,
+%% Version 2.0 (the "License"); you may not use this file
+%% except in compliance with the License. You may obtain
+%% a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing,
+%% software distributed under the License is distributed on an
+%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+%% KIND, either express or implied. See the License for the
+%% specific language governing permissions and limitations
+%% under the License.
+%%
+%% -------------------------------------------------------------------
+
+%% @doc Read only stat for cpu
+-module(riak_core_metric_host).
+
+-behaviour(riak_core_metric).
+
+-export([new/0, value/3, value/4, update/2, options/1]).
+
+new() ->
+ host.
+
+options(host) ->
+ [{cpu, [nprocs, avg1, avg5, avg15]},
+ {mem, [total, allocated]},
+ {disk, [Id || {Id, _, _} <- disksup:get_disk_data()]}].
+
+update(_Arg, host) ->
+ host.
+
+value(_Level, _Name, host) ->
+ lists:flatten([value(Field) || Field <- [cpu, mem, disk]]).
+
+value(_Level, Field, _Name, host) when is_atom(Field) ->
+ value(Field);
+value(_Level, [disk, Disk], _Name, host) ->
+ {disk, Disks} = value(disk),
+ proplists:lookup(Disk, Disks);
+value(_Level, [Field, Elem], _Name, host) ->
+ Stat = value(Field),
+ ElemName = riak_core_metric:join_as_atom([Field, '_', Elem]),
+ proplists:lookup(ElemName, Stat).
+
+value(cpu) ->
+ [{cpu_nprocs, cpu_sup:nprocs()},
+ {cpu_avg1, cpu_sup:avg1()},
+ {cpu_avg5, cpu_sup:avg5()},
+ {cpu_avg15, cpu_sup:avg15()}];
+value(mem) ->
+ {Total, Alloc, _} = memsup:get_memory_data(),
+ [{mem_total, Total},
+ {mem_allocated, Alloc}];
+value(disk) ->
+ {disk, disksup:get_disk_data()}.
View
12 src/riak_core_metric_proc.erl
@@ -30,7 +30,7 @@
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
--record(state, {name, mod, mod_state, description}).
+-record(state, {name, mod, mod_state, description, level}).
%%%===================================================================
%%% API
@@ -62,6 +62,7 @@ init(Args) ->
{type, Type} = proplists:lookup(type, Args), %% Does mod need init args?
Mod = mod_from_type(Type),
Description = proplists:get_value(description, Args),
+ Level = proplists:get_value(level, Args, 0),
ModState = Mod:new(),
DoTicks = do_ticks(Mod),
if DoTicks == true ->
@@ -70,10 +71,13 @@ init(Args) ->
ok
end,
{ok, #state{name=Name, mod=Mod, mod_state=ModState,
- description=Description}}.
+ description=Description, level=Level}}.
-handle_call({level, Level}, _From, #state{mod=Mod, mod_state=ModState, name=Name}=State) ->
- Stat = Mod:value(Level, Name, ModState),
+handle_call({level, Level}, _From, #state{mod=Mod, mod_state=ModState, name=Name, level=ActiveLevel}=State) ->
+ Stat = if Level >= ActiveLevel ->
+ Mod:value(Level, Name, ModState);
+ true -> []
+ end,
{reply, {ok, Stat}, State};
handle_call({spec, Level, Spec}, _From, #state{mod=Mod, mod_state=ModState, name=Name}=State) ->
Stat = Mod:value(Level, Spec, Name, ModState),
View
64 src/riak_core_metric_ring.erl
@@ -0,0 +1,64 @@
+%%
+%% Copyright (c) 2007-2012 Basho Technologies, Inc. All Rights Reserved.
+%%
+%% This file is provided to you under the Apache License,
+%% Version 2.0 (the "License"); you may not use this file
+%% except in compliance with the License. You may obtain
+%% a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing,
+%% software distributed under the License is distributed on an
+%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+%% KIND, either express or implied. See the License for the
+%% specific language governing permissions and limitations
+%% under the License.
+%%
+%% -------------------------------------------------------------------
+
+%% TODO add the rings_reonciled stuff here?
+-module(riak_core_metric_ring).
+
+-behaviour(riak_core_metric).
+
+-export([new/0, value/3, value/4, update/2, options/1]).
+
+new() ->
+ ring.
+
+options(ring) ->
+ fields(5).
+
+update(_Arg, ring) ->
+ ring.
+
+value(Level, _Name, ring) ->
+ {ok, R} = riak_core_ring_manager:get_my_ring(),
+ [value(R, F) || F <- fields(Level)].
+
+value(_Level, Field, _Name, ring) ->
+ {ok, R} = riak_core_ring_manager:get_my_ring(),
+ value(R, Field).
+
+value(Ring, members) ->
+ {ring_members, riak_core_ring:all_members(Ring)};
+value(Ring, num_partitions) ->
+ {ring_num_partitions, riak_core_ring:num_partitions(Ring)};
+value(_Ring, creation_size) ->
+ {ring_creation_size, app_helper:get_env(riak_core, ring_creation_size)};
+value(Ring, ownership) ->
+ {ring_ownership, list_to_binary(lists:flatten(io_lib:format("~p", [dict:to_list(
+ lists:foldl(fun({_P, N}, Acc) ->
+ case dict:find(N, Acc) of
+ {ok, V} ->
+ dict:store(N, V+1, Acc);
+ error ->
+ dict:store(N, 1, Acc)
+ end
+ end, dict:new(), riak_core_ring:all_owners(Ring)))])))}.
+
+fields(0) ->
+ [members, num_partitions, creation_size];
+fields(_Level) ->
+ fields(0) ++ [ownership].
View
3 src/riak_core_metric_sup.erl
@@ -68,7 +68,8 @@ mod_refs(App, Mod) ->
[stat_ref(App, Stat, Args) || {Stat, Args} <- Stats].
stat_ref(App, Stat, Args) ->
- {{App, Stat}, {riak_core_metric_proc, start_link, [Stat, Args]},
+ Group = proplists:get_value(group, Args),
+ {{App, Stat, Group}, {riak_core_metric_proc, start_link, [Stat, Args]},
permanent, 5000, worker, [riak_core_metric_proc]}.
remove_slide_private_dirs() ->
View
155 src/riak_core_metric_vnodeq.erl
@@ -0,0 +1,155 @@
+%%
+%% Copyright (c) 2007-2012 Basho Technologies, Inc. All Rights Reserved.
+%%
+%% This file is provided to you under the Apache License,
+%% Version 2.0 (the "License"); you may not use this file
+%% except in compliance with the License. You may obtain
+%% a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing,
+%% software distributed under the License is distributed on an
+%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+%% KIND, either express or implied. See the License for the
+%% specific language governing permissions and limitations
+%% under the License.
+%%
+%% -------------------------------------------------------------------
+
+%% @doc Read only stat for the vnodeq
+%% Is a metric for querying by level/field
+-module(riak_core_metric_vnodeq).
+
+-behaviour(riak_core_metric).
+
+-export([new/0, value/3, value/4, update/2, options/1]).
+
+-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
+-endif.
+
+-define(FIELDS, [running, min, median, mean, max, total]).
+
+new() ->
+ vnodeq.
+
+options(vnodeq) ->
+ [{App, ?FIELDS} || {App, _Mod} <- riak_core:vnode_modules()].
+
+update(_Arg, vnodeq) ->
+ vnodeq.
+
+%% Provide aggregate stats for vnode queues. Compute instantaneously for now,
+%% may need to cache if stats are called heavily (multiple times per seconds)
+value(Level, _Name, vnodeq) ->
+ Fields = fields(Level),
+ vnodeq_stats(Fields, riak_core_vnode_manager:all_vnodes()).
+
+value(Level, Service, _Name, vnodeq) when is_atom(Service) ->
+ Fields = fields(Level),
+ VnodeMod = proplists:get_value(Service, riak_core:vnode_modules()),
+ vnodeq_stats(Fields, riak_core_vnode_manager:all_vnodes(VnodeMod));
+value(_Level, [Service, Field], _Name, vnodeq) ->
+ VnodeMod = proplists:get_value(Service, riak_core:vnode_modules()),
+ vnodeq_stats([Field], riak_core_vnode_manager:all_vnodes(VnodeMod)).
+
+vnode_info(VNodes) ->
+ [{Service, element(2, erlang:process_info(Pid, message_queue_len))} ||
+ {Service, _Index, Pid} <- VNodes].
+
+service_info(VnodesInfo) ->
+ lists:foldl(fun({S,MQL}, A) ->
+ orddict:append_list(S, [MQL], A)
+ end, orddict:new(), VnodesInfo).
+
+vnodeq_stats(Fields, VNodes) ->
+ VnodesInfo = vnode_info(VNodes),
+ ServiceInfo = service_info(VnodesInfo),
+ lists:flatten([vnodeq_aggregate(S, MQLs, Fields) || {S, MQLs} <- ServiceInfo]).
+
+vnodeq_aggregate(_Service, [], _Fields) ->
+ []; % no vnodes, no stats
+vnodeq_aggregate(Service, MQLs0, Fields) ->
+ MQLs = lists:sort(MQLs0),
+ Len = length(MQLs),
+ Total = lists:sum(MQLs),
+ Mean = Total div Len,
+ Median = case (Len rem 2) of
+ 0 -> % even number, average middle two
+ (lists:nth(Len div 2, MQLs) +
+ lists:nth(Len div 2 + 1, MQLs)) div 2;
+ 1 ->
+ lists:nth(Len div 2 + 1, MQLs)
+ end,
+ Stats = [{running, Len},
+ {min, lists:nth(1, MQLs)},
+ {median, Median},
+ {mean, Mean},
+ {max, lists:nth(Len, MQLs)},
+ {total, Total}],
+ [{riak_core_metric:join_as_atom([Service, vnode_suffix(Field), Field]),
+ proplists:get_value(Field, Stats)} || Field <- Fields].
+
+fields(0) ->
+ [running, total];
+fields(Level) when Level >0 ->
+ ?FIELDS.
+
+vnode_suffix(running) ->
+ 's_';
+vnode_suffix(_) ->
+ 'q_'.
+
+-ifdef(TEST).
+
+%% Check vnodeq aggregation function
+vnodeq_aggregate_empty_test() ->
+ ?assertEqual([], vnodeq_aggregate(service_vnode, [], ?FIELDS)).
+
+vnodeq_aggregate_odd1_test() ->
+ ?assertEqual([{service_vnodes_running, 1},
+ {service_vnodeq_min, 10},
+ {service_vnodeq_median, 10},
+ {service_vnodeq_mean, 10},
+ {service_vnodeq_max, 10},
+ {service_vnodeq_total, 10}],
+ vnodeq_aggregate(service_vnode, [10], ?FIELDS)).
+
+vnodeq_aggregate_odd3_test() ->
+ ?assertEqual([{service_vnodes_running, 3},
+ {service_vnodeq_min, 1},
+ {service_vnodeq_median, 2},
+ {service_vnodeq_mean, 2},
+ {service_vnodeq_max, 3},
+ {service_vnodeq_total, 6}],
+ vnodeq_aggregate(service_vnode, [1, 2, 3], ?FIELDS)).
+
+vnodeq_aggregate_odd5_test() ->
+ ?assertEqual([{service_vnodes_running, 5},
+ {service_vnodeq_min, 0},
+ {service_vnodeq_median, 1},
+ {service_vnodeq_mean, 2},
+ {service_vnodeq_max, 5},
+ {service_vnodeq_total, 10}],
+ vnodeq_aggregate(service_vnode, [1, 0, 5, 0, 4], ?FIELDS)).
+
+vnodeq_aggregate_even2_test() ->
+ ?assertEqual([{service_vnodes_running, 2},
+ {service_vnodeq_min, 10},
+ {service_vnodeq_median, 15},
+ {service_vnodeq_mean, 15},
+ {service_vnodeq_max, 20},
+ {service_vnodeq_total, 30}],
+ vnodeq_aggregate(service_vnode, [10, 20], ?FIELDS)).
+
+vnodeq_aggregate_even4_test() ->
+ ?assertEqual([{service_vnodes_running, 4},
+ {service_vnodeq_min, 0},
+ {service_vnodeq_median, 5},
+ {service_vnodeq_mean, 7},
+ {service_vnodeq_max, 20},
+ {service_vnodeq_total, 30}],
+ vnodeq_aggregate(service_vnode, [0, 10, 0, 20], ?FIELDS)).
+
+-endif.
View
113 src/riak_core_stat.erl
@@ -26,6 +26,7 @@
%% Metrics API
-export([stat_specs/0]).
+
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
-endif.
@@ -37,21 +38,22 @@ stat_specs() ->
{handoff_timeouts, [{type, counter}, {group, gossip}]},
{gossip_received, [{type, meter}, {group, gossip}]},
{rings_reconciled, [{type, meter}, {group, gossip}]},
- {converge_delay, [{type, duration}, {group, gossip},
- {presentation,
- [{legacy, [min, max, mean, last]}]}]},
- {rebalance_delay, [{type, duration}, {group, gossip},
- {presentation,
- [{legacy, [min, max, mean, last]}]}]}
+ {converge_delay, [{type, duration}, {group, gossip}]},
+ {rebalance_delay, [{type, duration}, {group, gossip}]},
+ {vnode_queue, [{type, vnodeq}, {group, vnodeq}]},
+ {host, [{type, host}, {group, system}]},
+ {erl, [{type, erl}, {group, system}]},
+ {ring, [{type, ring}, {group, system}]},
+ {env, [{type, env}, {group, system}]}
].
%% @spec get_stats() -> proplist()
%% @doc Get the current aggregation of stats.
get_stats() ->
- produce_stats(legacy).
+ produce_stats(5).
get_stats(_Moment) ->
- produce_stats(legacy).
+ produce_stats(5).
%% @doc Update the given stat
-spec update(Stat::atom()) -> ok.
@@ -82,100 +84,15 @@ update(_) ->
%% @spec produce_stats(Presentation : atom()) -> proplist()
%% @doc Produce a proplist-formatted view of the current aggregation
%% of stats.
-produce_stats(Presentation) ->
- lists:append([gossip_stats(Presentation),
+produce_stats(Level) ->
+ lists:append([gossip_stats(Level),
vnodeq_stats()]).
%% @spec gossip_stats(integer()) -> proplist()
%% @doc Get the gossip stats proplist.
-gossip_stats(Presentation) ->
- GossipStats = [riak_core_metric_proc:value(Name, Presentation) || {Name, Spec} <- stat_specs(), lists:keyfind(gossip, 2, Spec) /= false],
+gossip_stats(Level) ->
+ GossipStats = [riak_core_metric_proc:value(Name, Level) || {Name, Spec} <- stat_specs(), lists:keyfind(gossip, 2, Spec) /= false],
lists:flatten( GossipStats ).
-%% Provide aggregate stats for vnode queues. Compute instantaneously for now,
-%% may need to cache if stats are called heavily (multiple times per seconds)
vnodeq_stats() ->
- VnodesInfo = [{Service, element(2, erlang:process_info(Pid, message_queue_len))} ||
- {Service, _Index, Pid} <- riak_core_vnode_manager:all_vnodes()],
- ServiceInfo = lists:foldl(fun({S,MQL}, A) ->
- orddict:append_list(S, [MQL], A)
- end, orddict:new(), VnodesInfo),
- lists:flatten([vnodeq_aggregate(S, MQLs) || {S, MQLs} <- ServiceInfo]).
-
-vnodeq_aggregate(_Service, []) ->
- []; % no vnodes, no stats
-vnodeq_aggregate(Service, MQLs0) ->
- MQLs = lists:sort(MQLs0),
- Len = length(MQLs),
- Total = lists:sum(MQLs),
- Mean = Total div Len,
- Median = case (Len rem 2) of
- 0 -> % even number, average middle two
- (lists:nth(Len div 2, MQLs) +
- lists:nth(Len div 2 + 1, MQLs)) div 2;
- 1 ->
- lists:nth(Len div 2 + 1, MQLs)
- end,
- [{vnodeq_atom(Service, <<"s_running">>), Len},
- {vnodeq_atom(Service, <<"q_min">>), lists:nth(1, MQLs)},
- {vnodeq_atom(Service, <<"q_median">>), Median},
- {vnodeq_atom(Service, <<"q_mean">>), Mean},
- {vnodeq_atom(Service, <<"q_max">>), lists:nth(Len, MQLs)},
- {vnodeq_atom(Service, <<"q_total">>), Total}].
-
-vnodeq_atom(Service, Desc) ->
- binary_to_atom(<<(atom_to_binary(Service, latin1))/binary, Desc/binary>>, latin1).
-
-
--ifdef(TEST).
-
-%% Check vnodeq aggregation function
-vnodeq_aggregate_empty_test() ->
- ?assertEqual([], vnodeq_aggregate(service_vnode, [])).
-
-vnodeq_aggregate_odd1_test() ->
- ?assertEqual([{service_vnodes_running, 1},
- {service_vnodeq_min, 10},
- {service_vnodeq_median, 10},
- {service_vnodeq_mean, 10},
- {service_vnodeq_max, 10},
- {service_vnodeq_total, 10}],
- vnodeq_aggregate(service_vnode, [10])).
-
-vnodeq_aggregate_odd3_test() ->
- ?assertEqual([{service_vnodes_running, 3},
- {service_vnodeq_min, 1},
- {service_vnodeq_median, 2},
- {service_vnodeq_mean, 2},
- {service_vnodeq_max, 3},
- {service_vnodeq_total, 6}],
- vnodeq_aggregate(service_vnode, [1, 2, 3])).
-
-vnodeq_aggregate_odd5_test() ->
- ?assertEqual([{service_vnodes_running, 5},
- {service_vnodeq_min, 0},
- {service_vnodeq_median, 1},
- {service_vnodeq_mean, 2},
- {service_vnodeq_max, 5},
- {service_vnodeq_total, 10}],
- vnodeq_aggregate(service_vnode, [1, 0, 5, 0, 4])).
-
-vnodeq_aggregate_even2_test() ->
- ?assertEqual([{service_vnodes_running, 2},
- {service_vnodeq_min, 10},
- {service_vnodeq_median, 15},
- {service_vnodeq_mean, 15},
- {service_vnodeq_max, 20},
- {service_vnodeq_total, 30}],
- vnodeq_aggregate(service_vnode, [10, 20])).
-
-vnodeq_aggregate_even4_test() ->
- ?assertEqual([{service_vnodes_running, 4},
- {service_vnodeq_min, 0},
- {service_vnodeq_median, 5},
- {service_vnodeq_mean, 7},
- {service_vnodeq_max, 20},
- {service_vnodeq_total, 30}],
- vnodeq_aggregate(service_vnode, [0, 10, 0, 20])).
-
--endif.
+ riak_core_metric_proc:value(vnode_queue, 3).

0 comments on commit 53e9b15

Please sign in to comment.
Something went wrong with that request. Please try again.