diff options
| author | Francesco Mazzoli <francesco@rabbitmq.com> | 2012-07-10 18:04:24 +0100 |
|---|---|---|
| committer | Francesco Mazzoli <francesco@rabbitmq.com> | 2012-07-10 18:04:24 +0100 |
| commit | 68a0e6655b383a89caa819a91257cdc18112b693 (patch) | |
| tree | a84ccb3b66ae8367d7819e61dacc242737ec2f4d | |
| parent | 63477af925d226c937aee6984c6380699ede0a11 (diff) | |
| download | rabbitmq-server-git-68a0e6655b383a89caa819a91257cdc18112b693.tar.gz | |
add replacement for the stock alarm_handler - not doing anything yet
| -rw-r--r-- | src/rabbit.erl | 8 | ||||
| -rw-r--r-- | src/rabbit_alarm_handler.erl | 53 |
2 files changed, 60 insertions, 1 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl index fda489fe61..61e6f274c8 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -93,10 +93,16 @@ [{description, "kernel ready"}, {requires, external_infrastructure}]}). +-rabbit_boot_step({rabbit_alarm_handler, + [{description, "stock alarm handler replacement"}, + {mfa, {rabbit_alarm_handler, start, []}}, + {requires, kernel_ready}, + {enables, core_initialized}]}). + -rabbit_boot_step({rabbit_alarm, [{description, "alarm handler"}, {mfa, {rabbit_alarm, start, []}}, - {requires, kernel_ready}, + {requires, rabbit_alarm_handler}, {enables, core_initialized}]}). -rabbit_boot_step({rabbit_memory_monitor, diff --git a/src/rabbit_alarm_handler.erl b/src/rabbit_alarm_handler.erl new file mode 100644 index 0000000000..dd5fe64167 --- /dev/null +++ b/src/rabbit_alarm_handler.erl @@ -0,0 +1,53 @@ +%% The contents of this file are subject to the Mozilla Public License +%% Version 1.1 (the "License"); you may not use this file except in +%% compliance with the License. You may obtain a copy of the License +%% at http://www.mozilla.org/MPL/ +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and +%% limitations under the License. +%% +%% The Original Code is RabbitMQ. +%% +%% The Initial Developer of the Original Code is VMware, Inc. +%% Copyright (c) 2007-2012 VMware, Inc. All rights reserved. +%% + +-module(rabbit_alarm_handler). + +-behaviour(gen_event). + +-export([start/0]). + +-export([init/1, handle_call/2, handle_event/2, handle_info/2, + terminate/2, code_change/3]). + +start() -> + alarm_handler:delete_alarm_handler(alarm_handler), + alarm_handler:add_alarm_handler(?MODULE). + +init(_) -> + {ok, []}. + +handle_event({set_alarm, Alarm}, Alarms)-> + error_logger:info_report([{alarm_handler, {set, Alarm}}]), + {ok, [Alarm | Alarms]}; +handle_event({clear_alarm, AlarmId}, Alarms)-> + error_logger:info_report([{alarm_handler, {clear, AlarmId}}]), + {ok, lists:keydelete(AlarmId, 1, Alarms)}; +handle_event(_, Alarms)-> + {ok, Alarms}. + +handle_info(_, Alarms) -> {ok, Alarms}. + +handle_call(get_alarms, Alarms) -> {ok, Alarms, Alarms}; +handle_call(_Query, Alarms) -> {ok, {error, bad_query}, Alarms}. + +terminate(swap, Alarms) -> + {alarm_handler, Alarms}; +terminate(_, _) -> + ok. + +code_change(_OldVsn, State, _Extra) -> + {ok, State}. |
