Skip to content

Commit dba72aa

Browse files
anuthanAliaksey Artamonau
authored andcommitted
Add takeover stats to rebalance kv stats
Helps with, MB-30803: Collect rebalance related stats Part of EPIC, MB-30894: Rebalance visibility and reporting Change-Id: If8fe09850db8e19f5fdf23738c54f1b8dc9c03fe Reviewed-on: http://review.couchbase.org/101825 Reviewed-by: Aliaksey Artamonau <[email protected]> Well-Formed: Build Bot <[email protected]> Tested-by: Aliaksey Artamonau <[email protected]>
1 parent 2ab54d1 commit dba72aa

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

src/ns_rebalance_observer.erl

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,15 @@
4646
after_chain :: [node()],
4747
stats :: [#replica_building_stats{}],
4848
move = #stat_info{},
49-
backfill = #stat_info{}}).
49+
backfill = #stat_info{},
50+
takeover = #stat_info{}}).
5051

5152
-record(total_stat_info, {total_time = 0,
5253
completed_count = 0}).
5354

5455
-record(vbucket_level_info, {move = #total_stat_info{},
5556
backfill = #total_stat_info{},
57+
takeover = #total_stat_info{},
5658
vbucket_info = dict:new()}).
5759

5860
-record(compaction_info, {per_node = [] :: [{node(), #total_stat_info{}}],
@@ -116,6 +118,10 @@ is_interesting_master_event({_, compaction_uninhibit_started, _BucketName, _}) -
116118
fun handle_compaction_uninhibit/2;
117119
is_interesting_master_event({_, compaction_uninhibit_done, _BucketName, _}) ->
118120
fun handle_compaction_uninhibit/2;
121+
is_interesting_master_event({_, takeover_started, _BucketName, _VBucketId, _, _}) ->
122+
fun handle_takeover/2;
123+
is_interesting_master_event({_, takeover_ended, _BucketName, _VBucketId, _, _}) ->
124+
fun handle_takeover/2;
119125
is_interesting_master_event({_, backfill_phase_started, _BucketName, _VBucketId}) ->
120126
fun handle_generic_vb_stat_event/2;
121127
is_interesting_master_event({_, backfill_phase_ended, _BucketName, _VBucketId}) ->
@@ -380,6 +386,9 @@ handle_vbucket_move_done({TS, vbucket_move_done, BucketName, VBucket},
380386
handle_compaction_uninhibit({TS, Event, BucketName, Node}, State) ->
381387
{noreply, update_info(Event, State, {TS, BucketName, Node})}.
382388

389+
handle_takeover({TS, Event, BucketName, VBucket, _, _}, State) ->
390+
{noreply, update_info(Event, State, {TS, BucketName, VBucket})}.
391+
383392
handle_generic_vb_stat_event({TS, Event, BucketName, VBucket}, State) ->
384393
{noreply, update_info(Event, State, {TS, BucketName, VBucket})}.
385394

@@ -693,7 +702,12 @@ find_event_action(Event) ->
693702
{backfill_phase_started, undefined,
694703
#vbucket_info.backfill, start_time},
695704
{backfill_phase_ended, #vbucket_level_info.backfill,
696-
#vbucket_info.backfill, end_time}
705+
#vbucket_info.backfill, end_time},
706+
707+
{takeover_started, undefined,
708+
#vbucket_info.takeover, start_time},
709+
{takeover_ended, #vbucket_level_info.takeover,
710+
#vbucket_info.takeover, end_time}
697711
],
698712
lists:keyfind(Event, 1, EventAction).
699713

@@ -791,13 +805,15 @@ construct_vbucket_info_json(Id, #vbucket_info{before_chain = BC,
791805
after_chain = AC,
792806
stats = RBS,
793807
move = Move,
794-
backfill = Backfill}) ->
808+
backfill = Backfill,
809+
takeover = Takeover}) ->
795810
{[{id, Id},
796811
{beforeChain, BC},
797812
{afterChain, AC},
798813
{stats, {[construct_replica_building_stats_json(X) || X <- RBS]}},
799814
{move, construct_stat_info_json(Move)},
800-
{backfill, construct_stat_info_json(Backfill)}]}.
815+
{backfill, construct_stat_info_json(Backfill)},
816+
{takeover, construct_stat_info_json(Takeover)}]}.
801817

802818
construct_vbucket_level_info_json(VBLevelInfo, Options) ->
803819
case dict:is_empty(VBLevelInfo#vbucket_level_info.vbucket_info) of
@@ -811,6 +827,7 @@ construct_vbucket_level_info_json(VBLevelInfo, Options) ->
811827
construct_vbucket_level_info_json_inner(
812828
#vbucket_level_info{move = Move,
813829
backfill = Backfill,
830+
takeover = Takeover,
814831
vbucket_info = AllVBInfo}, Options) ->
815832
VBI = case proplists:get_bool(add_vbucket_info, Options) of
816833
true ->
@@ -822,7 +839,8 @@ construct_vbucket_level_info_json_inner(
822839
[]
823840
end,
824841
{[{move, construct_total_stat_info_json(Move)},
825-
{backfill, construct_total_stat_info_json(Backfill)}]
842+
{backfill, construct_total_stat_info_json(Backfill)},
843+
{takeover, construct_total_stat_info_json(Takeover)}]
826844
++ VBI}.
827845

828846
get_all_stage_rebalance_details(#state{bucket_info = BucketLevelInfo},

0 commit comments

Comments
 (0)