Skip to content

Commit

Permalink
Merge pull request #285 from flaviogrossi/fix_ra_overview_not_started
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelklishin authored May 24, 2022
2 parents 13f8ed0 + cff8641 commit e819c76
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
32 changes: 18 additions & 14 deletions src/ra.erl
Original file line number Diff line number Diff line change
Expand Up @@ -711,20 +711,24 @@ overview() ->
%% @end
-spec overview(atom()) -> map() | system_not_started.
overview(System) ->

#{names := #{segment_writer := SegWriter,
open_mem_tbls := OpenTbls,
closed_mem_tbls := ClosedTbls,
wal := Wal}} = ra_system:fetch(System),
#{node => node(),
servers => ra_directory:overview(System),
%% TODO:filter counter keys by system
counters => ra_counters:overview(),
wal => #{status => lists:nth(5, element(4, sys:get_status(Wal))),
open_mem_tables => ets:info(OpenTbls, size),
closed_mem_tables => ets:info(ClosedTbls, size)},
segment_writer => ra_log_segment_writer:overview(SegWriter)
}.
case ra_system:fetch(System) of
undefined ->
system_not_started;
Config ->
#{names := #{segment_writer := SegWriter,
open_mem_tbls := OpenTbls,
closed_mem_tbls := ClosedTbls,
wal := Wal}} = Config,
#{node => node(),
servers => ra_directory:overview(System),
%% TODO:filter counter keys by system
counters => ra_counters:overview(),
wal => #{status => lists:nth(5, element(4, sys:get_status(Wal))),
open_mem_tables => ets:info(OpenTbls, size),
closed_mem_tables => ets:info(ClosedTbls, size)},
segment_writer => ra_log_segment_writer:overview(SegWriter)
}
end.

%% @doc Submits a command to a ra server. Returns after the command has
%% been applied to the Raft state machine. If the state machine returned a
Expand Down
6 changes: 5 additions & 1 deletion test/ra_system_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ all_tests() ->
start_cluster,
start_clusters_in_systems,
restart_system,
ra_overview
ra_overview,
ra_overview_not_started
].

groups() ->
Expand Down Expand Up @@ -157,6 +158,9 @@ ra_overview(Config) ->
?assert(maps:is_key(servers, Overview)),
ok.

ra_overview_not_started(_Config) ->
?assertEqual(ra:overview(unstarted_system), system_not_started).


%% Utility

Expand Down

0 comments on commit e819c76

Please sign in to comment.