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

WIP Expose some controller state fields for Tictac AAE and NextGenRepl CLI commands #4

Open
wants to merge 2 commits into
base: openriak-3.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/aae_controller.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
aae_start/7,
aae_start/8,
aae_nextrebuild/1,
aae_schedulenextrebuild/2,
aae_put/7,
aae_close/1,
aae_destroy/1,
Expand All @@ -52,6 +53,10 @@
hash_clocks/2,
wrapped_splitobjfun/1]).

-export([get_key_store/1,
get_next_rebuild/1,
get_tree_caches/1]).

-export([wait_on_sync/5]).

-export([generate_returnfun/2]).
Expand Down Expand Up @@ -210,6 +215,13 @@ aae_start(
aae_nextrebuild(Pid) ->
gen_server:call(Pid, rebuild_time, ?SYNC_TIMEOUT).

-spec aae_schedulenextrebuild(pid(), non_neg_integer()) -> ok.
%% @doc
%% Schedule the next keystore rebuild, assuming last rebuild
%% occurred now + specified delay
aae_schedulenextrebuild(Pid, Delay) ->
gen_server:call(Pid, {schedule_nextrebuild, Delay}, ?SYNC_TIMEOUT).

-spec aae_put(pid(), responsible_preflist(),
aae_keystore:bucket(), aae_keystore:key(),
version_vector(), version_vector(),
Expand Down Expand Up @@ -578,6 +590,11 @@ init([Opts]) ->

handle_call(rebuild_time, _From, State) ->
{reply, State#state.next_rebuild, State};
handle_call({schedule_rebuild, Delay}, _From, State) ->
{Mega, Sec, Micros} = os:timestamp(),
Next = schedule_rebuild({Mega, Sec + Delay, Micros},
State#state.rebuild_schedule),
{reply, ok, State#state{next_rebuild = Next}};
handle_call(close, _From, State) ->
ok = maybe_flush_puts(State#state.key_store,
State#state.objectspecs_queue,
Expand Down Expand Up @@ -1358,6 +1375,24 @@ preflist_wrapper_fun(FoldObjectsFun, IndexNs) ->
end
end.

-spec get_key_store(#state{}) -> pid() | undefined.
%% @doc
%% Expose key_store pid, to gather info for aae-progress-report.
get_key_store(#state{key_store = A}) ->
A.

-spec get_next_rebuild(#state{}) -> erlang:timestamp() | undefined.
%% @doc
%% Expose next_rebuild field, to gather info for aae-progress-report.
get_next_rebuild(#state{next_rebuild = A}) ->
A.

-spec get_tree_caches(#state{}) -> tree_caches().
%% @doc
%% Expose tree_cahches field, to gather info for aae-progress-report.
get_tree_caches(#state{tree_caches = A}) ->
A.


%%%============================================================================
%%% Test
Expand Down
10 changes: 9 additions & 1 deletion src/aae_keystore.erl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
generate_treesegment/1,
value/3]).

-export([get_last_rebuild/1]).

-record(state, {vnode :: pid()|undefined,
store :: pid()|undefined,
id = key_store :: any(),
Expand Down Expand Up @@ -1291,6 +1293,12 @@ disklog_filename(RootPath, GUID) ->
filename:join(RootPath, GUID ++ ?DISKLOG_EXT).


-spec get_last_rebuild(#state{}) -> erlang:timestamp() | never.
%% @doc
%% Expose last_rebuild field (used in generation of aae-progress-report).
get_last_rebuild(#state{last_rebuild = A}) ->
A.


%%%============================================================================
%%% Test
Expand Down Expand Up @@ -1859,4 +1867,4 @@ generate_objectspecs(Op, B, KeyList) ->



-endif.
-endif.
10 changes: 9 additions & 1 deletion src/aae_treecache.erl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
cache_loglevel/2,
cache_close/1]).

-export([dirty_segment_count/1]).

-define(PENDING_EXT, ".pnd").
-define(FINAL_EXT, ".aae").
-define(START_SQN, 1).
Expand Down Expand Up @@ -450,6 +452,12 @@ binary_extractfun(Key, {CurrentHash, OldHash}) ->
end,
{Key, {is_hash, CurrentHash bxor RemoveH}}.

-spec dirty_segment_count(#state{}) -> non_neg_integer().
%% @doc
%% Expose dirty_segments length, for aae-progress-report.
dirty_segment_count(#state{dirty_segments = A}) ->
length(A).

%%%============================================================================
%%% Test
%%%============================================================================
Expand Down Expand Up @@ -826,4 +834,4 @@ test_setup_funs(InitialKeys) ->
{AddFun, AlterFun, RemoveFun}.


-endif.
-endif.
Loading