diff options
author | Matthias Radestock <matthias@lshift.net> | 2008-10-16 03:56:41 +0100 |
---|---|---|
committer | Matthias Radestock <matthias@lshift.net> | 2008-10-16 03:56:41 +0100 |
commit | 38a6518f6e790ff48f3efb0ab64564154a69ba77 (patch) | |
tree | e41f18c6e60a4d110c22c2987444b5d660eb2060 | |
parent | 25380b49849b81e2c2f03ec4303c3414094b5db2 (diff) | |
download | rabbitmq-server-38a6518f6e790ff48f3efb0ab64564154a69ba77.tar.gz |
branch off for effect-less alarm handling
so we can later experiment with different effects
-rw-r--r-- | src/rabbit_alarm.erl | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/rabbit_alarm.erl b/src/rabbit_alarm.erl index e71dda59..be0f0cea 100644 --- a/src/rabbit_alarm.erl +++ b/src/rabbit_alarm.erl @@ -34,6 +34,8 @@ -define(MEMSUP_CHECK_INTERVAL, 1000). +-record(alarms, {system_memory_high_watermark = false}). + %%---------------------------------------------------------------------------- -ifdef(use_specs). @@ -53,6 +55,11 @@ start() -> %% a granularity of minutes. So we have to peel off one layer of %% the API to get to the underlying layer which operates at the %% granularity of milliseconds. + %% + %% Note that the new setting will only take effect after the first + %% check has completed, i.e. after one minute. So if rabbit eats + %% all the memory within the first minute after startup then we + %% are out of luck. ok = os_mon:call(memsup, {set_check_interval, ?MEMSUP_CHECK_INTERVAL}, infinity), @@ -64,12 +71,18 @@ stop() -> %%---------------------------------------------------------------------------- init([]) -> - {ok, none}. + {ok, #alarms{}}. handle_call(_Request, State) -> {ok, not_understood, State}. -handle_event(Event, State) -> +handle_event({set_alarm, {system_memory_high_watermark, []}}, State) -> + {ok, State#alarms{system_memory_high_watermark = true}}; + +handle_event({clear_alarm, system_memory_high_watermark}, State) -> + {ok, State#alarms{system_memory_high_watermark = false}}; + +handle_event(_Event, State) -> {ok, State}. handle_info(_Info, State) -> |