aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2011-08-19 14:11:52 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2011-08-19 14:11:52 +0100
commit638a0cb31b5dd3c0131035c19c14e0ac709a9a2e (patch)
tree601104ed74c1bf8d9df6c8f629b8695f778fbf9d /lib
parentcdd1b094b27960595a8750247c5b2f2576cd5872 (diff)
Added note-ability (fixes 1146)
Removed threaded notifications cos we don't need em. (ftw!)
Diffstat (limited to 'lib')
-rw-r--r--lib/mauve/notifier.rb21
-rw-r--r--lib/mauve/person.rb10
-rw-r--r--lib/mauve/server.rb12
-rw-r--r--lib/mauve/web_interface.rb12
4 files changed, 34 insertions, 21 deletions
diff --git a/lib/mauve/notifier.rb b/lib/mauve/notifier.rb
index d660a54..4737c37 100644
--- a/lib/mauve/notifier.rb
+++ b/lib/mauve/notifier.rb
@@ -14,32 +14,22 @@ module Mauve
#
sz = Server.notification_buffer_size
- my_threads = []
-
+ # Thread.current[:notification_threads] ||= []
+ logger.info "Sending #{sz} alerts" if sz > 0
+
sz.times do
person, *args = Server.notification_pop
#
# Nil person.. that's craaazy too!
#
- break if person.nil?
- my_threads << Thread.new {
- person.do_send_alert(*args)
- }
- end
+ next if person.nil?
- my_threads.each do |t|
- begin
- t.join
- rescue StandardError => ex
- logger.error ex.to_s
- logger.debug ex.backtrace.join("\n")
- end
+ person.do_send_alert(*args)
end
end
def start
-
if Configuration.current.notification_methods['xmpp']
#
# Connect to XMPP server
@@ -66,6 +56,7 @@ module Mauve
Configuration.current.people[username].xmpp = jid unless jid.nil?
end
end
+
super
end
diff --git a/lib/mauve/person.rb b/lib/mauve/person.rb
index 64ed07e..e52b644 100644
--- a/lib/mauve/person.rb
+++ b/lib/mauve/person.rb
@@ -176,10 +176,14 @@ module Mauve
return true
end
+
+ # FIXME current_alerts is very slow. So much so it slows everything
+ # down. A lot.
result = NotificationCaller.new(
self,
alert,
- current_alerts,
+ [],
+ # current_alerts,
{:is_suppressed => @suppressed,
:was_suppressed => was_suppressed, }
).instance_eval(&__send__(level))
@@ -202,8 +206,12 @@ module Mauve
return false
end
+ #
# Returns the subset of current alerts that are relevant to this Person.
#
+ # This is currently very CPU intensive, and slows things down a lot. So
+ # I've commented it out when sending notifications.
+ #
def current_alerts
Alert.all_raised.select do |alert|
my_last_update = AlertChanged.first(:person => username, :alert_id => alert.id)
diff --git a/lib/mauve/server.rb b/lib/mauve/server.rb
index 3d59049..047476d 100644
--- a/lib/mauve/server.rb
+++ b/lib/mauve/server.rb
@@ -117,6 +117,18 @@ module Mauve
thread_list.delete(Thread.current)
+ #
+ # Check buffer sizes
+ #
+ if self.class.notification_buffer_size > 10
+ logger.warn "Notification buffer has #{self.class.notification_buffer_size} messages in it"
+ end
+
+ if self.class.packet_buffer_size > 10
+ logger.warn "Packet buffer has #{self.class.packet_buffer_size} updates in it"
+ end
+
+
THREAD_CLASSES.each do |klass|
#
# No need to double check ourselves.
diff --git a/lib/mauve/web_interface.rb b/lib/mauve/web_interface.rb
index bf2c667..82dc654 100644
--- a/lib/mauve/web_interface.rb
+++ b/lib/mauve/web_interface.rb
@@ -220,11 +220,6 @@ EOF
begin
a.acknowledge!(@person, ack_until)
- logger.debug note
- unless note.to_s.empty?
- h = History.new(:alerts => [a], :type => "note", :event => note.to_s)
- logger.debug h.errors unless h.save
- end
succeeded << a
rescue StandardError => ex
logger.error "Caught #{ex.to_s} when trying to save #{a.inspect}"
@@ -232,6 +227,13 @@ EOF
failed << ex
end
end
+ #
+ # Add a note
+ #
+ unless note.to_s.empty?
+ h = History.new(:alerts => succeeded, :type => "note", :event => session['username']+" noted "+note.to_s)
+ logger.debug h.errors unless h.save
+ end
flash["error"] = "Failed to acknowledge #{failed.length} alerts." if failed.length > 0
flash["notice"] = "Successfully acknowledged #{succeeded.length} alerts" if succeeded.length > 0