-
Notifications
You must be signed in to change notification settings - Fork 96
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
Extract out console facing FSM from riak_cs_gc_d #1144
Conversation
riak_cs_gc_d used to have bunch of complex states not only name of states exposed in gen_fsm, but also many elements in gc_d_state record. This commit extracts operator-facing states such as idle, paused, running from riak_cs_gc_d. riak_cs_gc_d is not a long-running worker under supervision tree any more, but riak_cs_gc_manager is. The lifecycle of riak_cs_gc_d is now as long as one GC batch - if the GC has finished then riak_cs_gc_d process terminates. See comments in both riak_cs_gc_d.erl and riak_cs_gc_manager.erl for detail state diagram and description.
@@ -106,3 +93,14 @@ | |||
-define(DEFAULT_GC_BATCH_SIZE, 1000). | |||
-define(DEFAULT_GC_WORKERS, 2). | |||
-define(EPOCH_START, <<"0">>). | |||
|
|||
-record(gc_manager_state, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This state record is referenced only from manager module, I guess.
Maybe just historical(?) reason, how about putting it into manger module file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because they're also used in quickcheck tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
( ̄ー ̄)b
For now, pause and remove can be replaced with stopping and setting interval. This simplifies two FSMs drastically in clean way.
%%% Internal functions | ||
%%%=================================================================== | ||
|
||
maybe_fetch_first_key(?STATE{batch_start=BatchStart, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function fetches keys regardless of any condition. Then, "maybe" is not needed and s/key/keys/.
8cc4126
to
cf8ac7d
Compare
|
%% start -> idle -(start)-> running | ||
%% ^ | | ||
%% +----(finish)---+ | ||
%% +----(stop)-----+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/stop/cancel/
I don't think any usage of |
|
||
%% =================================================================== | ||
%% Test API and tests | ||
%% =================================================================== |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elapsed
below is not (only) for testing.
True. Sorry for my misunderstanding (again) 😞 |
Eunit, xref , dialyzer succeeded. +1 to merge. |
Extract out console facing FSM from riak_cs_gc_d Reviewed-by: shino
@borshop merge |
The pull request was merged Monday, without starting the sprint (Most of the work was finished, so I was working on next work). _[posted via JIRA by Kota Uenishi]_ |
No release note needed as this is just a code cleanup. _[posted via JIRA by Kota Uenishi]_ |
riak_cs_gc_d used to have bunch of complex states not only name of
states exposed in gen_fsm, but also many elements in gc_d_state
record. This commit extracts operator-facing states such as idle,
paused, running from riak_cs_gc_d. riak_cs_gc_d is not a long-running
worker under supervision tree any more, but riak_cs_gc_manager is.
The lifecycle of riak_cs_gc_d is now as long as one GC batch - if the
GC has finished then riak_cs_gc_d process terminates.
See comments in both riak_cs_gc_d.erl and riak_cs_gc_manager.erl for
detail state diagram and description.