From e3d7ee7b4ed31ffd87d5252830394daac23059f5 Mon Sep 17 00:00:00 2001 From: Andriy Zavada Date: Thu, 12 Dec 2024 21:48:35 +0200 Subject: [PATCH] getters of various fields needed for riak admin aae-progress-report --- src/aae_controller.erl | 22 ++++++++++++++++++++++ src/aae_keystore.erl | 10 +++++++++- src/aae_treecache.erl | 10 +++++++++- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/aae_controller.erl b/src/aae_controller.erl index 824517d..7d0acd1 100644 --- a/src/aae_controller.erl +++ b/src/aae_controller.erl @@ -53,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]). @@ -1371,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 diff --git a/src/aae_keystore.erl b/src/aae_keystore.erl index ca139fa..6e463cd 100644 --- a/src/aae_keystore.erl +++ b/src/aae_keystore.erl @@ -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(), @@ -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 @@ -1859,4 +1867,4 @@ generate_objectspecs(Op, B, KeyList) -> --endif. \ No newline at end of file +-endif. diff --git a/src/aae_treecache.erl b/src/aae_treecache.erl index b5e22e5..44a4267 100644 --- a/src/aae_treecache.erl +++ b/src/aae_treecache.erl @@ -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). @@ -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 %%%============================================================================ @@ -826,4 +834,4 @@ test_setup_funs(InitialKeys) -> {AddFun, AlterFun, RemoveFun}. --endif. \ No newline at end of file +-endif.