diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2012-07-05 14:00:13 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2012-07-05 14:00:13 +0100 |
commit | f4c1559078f0408375551964de73a892b8a6a9be (patch) | |
tree | 2f1dd60470899ac096b3a829d43937a3526b784e | |
parent | 4bc9c1005cdbb14d5d310ba7674e068b2098e19c (diff) |
Updated configuration for heartbeat to replace poll_every.
Removed poll_every from other classes.
Updated tests to reflect this.
-rw-r--r-- | lib/mauve/configuration_builders/server.rb | 10 | ||||
-rw-r--r-- | lib/mauve/heartbeat.rb | 17 | ||||
-rw-r--r-- | lib/mauve/udp_server.rb | 2 | ||||
-rw-r--r-- | test/tc_mauve_configuration_builders_server.rb | 11 |
4 files changed, 16 insertions, 24 deletions
diff --git a/lib/mauve/configuration_builders/server.rb b/lib/mauve/configuration_builders/server.rb index 734fb3b..ea12724 100644 --- a/lib/mauve/configuration_builders/server.rb +++ b/lib/mauve/configuration_builders/server.rb @@ -36,8 +36,6 @@ module Mauve is_attribute "port" # This is the IP address the server listens on. IPv6 is OK! e.g. [::] for all addresses is_attribute "ip" - # This is the sleep interval for the UDP server. - is_attribute "poll_every" # Sets up a Mauve::UDPServer singleton as the result # @@ -51,8 +49,6 @@ module Mauve # This is the thread that pulls packets from the queue for processing. # class Processor < ObjectBuilder - # This is the interval between polls of the packet queue. - is_attribute "poll_every" # This is the timeout for the transmission cache, which allows duplicate packets to be discarded. is_attribute "transmission_cache_expire_time" @@ -65,12 +61,6 @@ module Mauve end class Notifier < ObjectBuilder - # - # This is the interval at which the notification queue is polled for new - # notifications to be sent. This will not have any rate-limiting effect. - # - is_attribute "poll_every" - # Sets up a Mauve::Notifier singleton as the result # # @return [Mauve::Notifier] diff --git a/lib/mauve/heartbeat.rb b/lib/mauve/heartbeat.rb index 1fe2fab..11f4d5b 100644 --- a/lib/mauve/heartbeat.rb +++ b/lib/mauve/heartbeat.rb @@ -15,7 +15,7 @@ module Mauve # # Allow access to some basics. # - attr_reader :raise_after, :destination, :summary, :detail + attr_reader :raise_after, :destination, :summary, :detail, :send_every # # This sets up the Heartbeat singleton @@ -27,7 +27,7 @@ module Mauve @summary = "Mauve alert server heartbeat failed" @detail = "The Mauve server at #{Server.instance.hostname} has failed to send a heartbeat." @raise_after = 310 - @poll_every = 60 + @send_every = 60 end # @@ -38,8 +38,17 @@ module Mauve raise ArgumentError "raise_after must be an integer" unless i.is_a?(Integer) @raise_after = i end + + # + # This is the time period after which an alert is raised by the remote Mauve instance. + # @param [Integer] i Seconds + # @return [Integer] Seconds + def send_every=(i) + raise ArgumentError "send_every must be an integer" unless i.is_a?(Integer) + @send_every = i + end - alias send_every= poll_every= + alias poll_every= send_every= # Sets the summary of the heartbeat # @@ -97,6 +106,8 @@ module Mauve Mauve::Sender.new(self.destination).send(update) logger.debug "Sent to #{self.destination}" + + sleep @send_every end end diff --git a/lib/mauve/udp_server.rb b/lib/mauve/udp_server.rb index e3362e8..9dafdd0 100644 --- a/lib/mauve/udp_server.rb +++ b/lib/mauve/udp_server.rb @@ -22,7 +22,6 @@ module Mauve # Defaults: # * listening IP: 127.0.0.1 # * listening port: 32741 - # * polls every: 0 seconds # def initialize # @@ -30,7 +29,6 @@ module Mauve # self.ip = "127.0.0.1" self.port = 32741 - self.poll_every = 0 @socket = nil super diff --git a/test/tc_mauve_configuration_builders_server.rb b/test/tc_mauve_configuration_builders_server.rb index 213ff68..072a0c4 100644 --- a/test/tc_mauve_configuration_builders_server.rb +++ b/test/tc_mauve_configuration_builders_server.rb @@ -54,7 +54,7 @@ EOF assert_equal(summary, h.summary) assert_equal(destination, h.destination) assert_equal(raise_after, h.raise_after) - assert_equal(send_every, h.poll_every) + assert_equal(send_every, h.send_every) end def test_web_interface_params @@ -107,37 +107,32 @@ EOF def test_listener_params ip = "::" port = 12341 - sleep_interval = 5678 config=<<EOF + server { listener { ip "#{ip}" port #{port} - poll_every #{sleep_interval} } } EOF assert_nothing_raised { Mauve::ConfigurationBuilder.parse(config) } u = Mauve::UDPServer.instance - assert_equal(sleep_interval, u.poll_every) assert_equal(IPAddr.new(ip), u.ip) assert_equal(port, u.port) end def test_notifier_params - sleep_interval = 23 config=<<EOF server { notifier { - poll_every #{sleep_interval} } } EOF assert_nothing_raised { Mauve::ConfigurationBuilder.parse(config) } n = Mauve::Notifier.instance - assert_equal(sleep_interval, n.poll_every) end def test_processor_params @@ -148,7 +143,6 @@ EOF server { processor { transmission_cache_expire_time #{transmission_cache_expire_time} - poll_every #{sleep_interval} } } EOF @@ -156,7 +150,6 @@ EOF assert_nothing_raised { Mauve::ConfigurationBuilder.parse(config) } pr = Mauve::Processor.instance assert_equal(transmission_cache_expire_time, pr.transmission_cache_expire_time) - assert_equal(sleep_interval, pr.poll_every) end end |