class Pione::Command::PioneDiagnosisNotificationContext
Constants
- NOTIFIER
Public Instance Methods
both?()
click to toggle source
# File lib/pione/command/pione-diagnosis-notification.rb, line 159 def both? model[:type] == "both" end
receive_notification()
click to toggle source
# File lib/pione/command/pione-diagnosis-notification.rb, line 200 def receive_notification Global.notification_receivers.each do |uri| thread = Thread.new do receiver = Notification::Receiver.new(uri) begin loop do Log::SystemLog.info('Notification receiver is waiting at "%s".' % uri.to_s) transmitter_host, message = receiver.receive Log::SystemLog.info('Notification has been received from "%s".' % transmitter_host) begin DRbObject.new_with_uri(message["front"]).touch(message["transmitter_id"]) Log::SystemLog.info('Receiver has touched transmitter at "%s".' % message["front"]) break rescue Object => e Log::SystemLog.warn(e.message) end end ensure receiver.close end end model[:receiver_threads].add(thread) end model[:receiver_threads].list.each {|thread| thread.join} end
receiver?()
click to toggle source
# File lib/pione/command/pione-diagnosis-notification.rb, line 155 def receiver? model[:type] == "receiver" end
transmit_notification()
click to toggle source
Transmit test notification messages to targets repeatedly.
# File lib/pione/command/pione-diagnosis-notification.rb, line 164 def transmit_notification Global.notification_targets.each do |uri| transmitter_id = uri.to_s thread = Thread.new do # register the current thread to front server Thread.current[:transmitter_id] = transmitter_id model[:front].register_transmitting_thread(Thread.current) # build a notification message message = Notification::Message.new( NOTIFIER, "TEST", {"front" => model[:front].uri, "transmitter_id" => transmitter_id} ) # create a transmitter transmitter = Notification::Transmitter.new(uri) # trasmitting loop for "TEST" notifications begin loop do transmitter.transmit(message) Log::SystemLog.info('Notification message has been sent to "%s".' % uri) sleep 1 end ensure transmitter.close end end model[:transmitting_threads].add(thread) end model[:transmitting_threads].list.each {|thread| thread.join} end
transmitter?()
click to toggle source
# File lib/pione/command/pione-diagnosis-notification.rb, line 151 def transmitter? model[:type] == "transmitter" end