Skip to content

Commit 8ea452d

Browse files
committed
QQ Reconciliator - move hardcoded triggers to events subscription
1 parent 2d02964 commit 8ea452d

File tree

3 files changed

+52
-5
lines changed

3 files changed

+52
-5
lines changed

deps/rabbit/src/rabbit_node_monitor.erl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,6 @@ handle_dead_rabbit(Node, State) ->
857857
%% statements on *one* node, rather than all of them.
858858
ok = rabbit_amqqueue:on_node_down(Node),
859859
ok = rabbit_alarm:on_node_down(Node),
860-
ok = rabbit_quorum_queue_periodic_membership_reconciliation:on_node_down(Node),
861860
State1 = case rabbit_khepri:is_enabled() of
862861
true -> State;
863862
false -> on_node_down_using_mnesia(Node, State)
@@ -898,8 +897,7 @@ handle_live_rabbit(Node) ->
898897
true -> ok;
899898
false -> on_node_up_using_mnesia(Node)
900899
end,
901-
ok = rabbit_vhosts:on_node_up(Node),
902-
ok = rabbit_quorum_queue_periodic_membership_reconciliation:on_node_up(Node).
900+
ok = rabbit_vhosts:on_node_up(Node).
903901

904902
on_node_up_using_mnesia(Node) ->
905903
ok = rabbit_mnesia:on_node_up(Node).

deps/rabbit/src/rabbit_policy.erl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,13 +378,11 @@ validate(_VHost, <<"operator_policy">>, Name, Term, _User) ->
378378
notify(VHost, <<"policy">>, Name, Term0, ActingUser) ->
379379
Term = rabbit_data_coercion:atomize_keys(Term0),
380380
update_matched_objects(VHost, Term, ActingUser),
381-
rabbit_quorum_queue_periodic_membership_reconciliation:policy_set(),
382381
rabbit_event:notify(policy_set, [{name, Name}, {vhost, VHost},
383382
{user_who_performed_action, ActingUser} | Term]);
384383
notify(VHost, <<"operator_policy">>, Name, Term0, ActingUser) ->
385384
Term = rabbit_data_coercion:atomize_keys(Term0),
386385
update_matched_objects(VHost, Term, ActingUser),
387-
rabbit_quorum_queue_periodic_membership_reconciliation:policy_set(),
388386
rabbit_event:notify(policy_set, [{name, Name}, {vhost, VHost},
389387
{user_who_performed_action, ActingUser} | Term]).
390388

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
%% This Source Code Form is subject to the terms of the Mozilla Public
2+
%% License, v. 2.0. If a copy of the MPL was not distributed with this
3+
%% file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
%%
5+
%% Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.
6+
%%
7+
8+
-module(rabbit_quorum_event_subscriber).
9+
10+
-behaviour(gen_event).
11+
12+
-export([init/1, handle_event/2, handle_call/2]).
13+
-export([register/0, unregister/0]).
14+
15+
-include_lib("rabbit_common/include/rabbit.hrl").
16+
17+
-rabbit_boot_step({rabbit_quorum_event_subscriber,
18+
[{description, "quorum queue event subscriber"},
19+
{mfa, {?MODULE, register, []}},
20+
{cleanup, {?MODULE, unregister, []}},
21+
{requires, rabbit_event},
22+
{enables, recovery}]}).
23+
24+
register() ->
25+
gen_event:add_handler(rabbit_alarm, ?MODULE, []),
26+
gen_event:add_handler(rabbit_event, ?MODULE, []).
27+
28+
unregister() ->
29+
gen_event:delete_handler(rabbit_alarm, ?MODULE, []),
30+
gen_event:delete_handler(rabbit_event, ?MODULE, []).
31+
32+
init([]) ->
33+
{ok, []}.
34+
35+
handle_call( _, State) ->
36+
{ok, ok, State}.
37+
38+
handle_event({node_up, Node}, State) ->
39+
rabbit_quorum_queue_periodic_membership_reconciliation:on_node_up(Node),
40+
{ok, State};
41+
handle_event({node_down, Node}, State) ->
42+
rabbit_quorum_queue_periodic_membership_reconciliation:on_node_down(Node),
43+
{ok, State};
44+
handle_event(#event{type = policy_set}, State) ->
45+
rabbit_quorum_queue_periodic_membership_reconciliation:policy_set(),
46+
{ok, State};
47+
handle_event(#event{type = operator_policy_set}, State) ->
48+
rabbit_quorum_queue_periodic_membership_reconciliation:policy_set(),
49+
{ok, State};
50+
handle_event(_, State) ->
51+
{ok, State}.

0 commit comments

Comments
 (0)