Class: ModernTimes::JMS::Supervisor
- Inherits:
-
Base::Supervisor
- Object
- Base::Supervisor
- ModernTimes::JMS::Supervisor
- Defined in:
- lib/modern_times/jms/supervisor.rb
Instance Attribute Summary
Attributes inherited from Base::Supervisor
#manager, #name, #worker_klass, #worker_options, #workers
Instance Method Summary collapse
- #average_response_time ⇒ Object
-
#create_mbean(domain) ⇒ Object
Make JMS::SupervisorMBean our mbean.
-
#initialize(manager, worker_name, supervisor_options, worker_options) ⇒ Supervisor
constructor
A new instance of Supervisor.
- #max_response_time ⇒ Object
- #message_counts ⇒ Object
- #min_response_time ⇒ Object
Methods inherited from Base::Supervisor
#join, #mbean_description, #mbean_name, #stop, #stopped?, #worker_count, #worker_count=, #worker_statuses
Constructor Details
#initialize(manager, worker_name, supervisor_options, worker_options) ⇒ Supervisor
Returns a new instance of Supervisor.
5 6 7 |
# File 'lib/modern_times/jms/supervisor.rb', line 5 def initialize(manager, worker_name, , ) super end |
Instance Method Details
#average_response_time ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/modern_times/jms/supervisor.rb', line 13 def average_response_time count = 0 total = 0.0 workers.each do |w| pair = w.time_track.total_time_reset count += pair.first total += pair.last end return 0.0 if count == 0 return total / count end |
#create_mbean(domain) ⇒ Object
Make JMS::SupervisorMBean our mbean
44 45 46 |
# File 'lib/modern_times/jms/supervisor.rb', line 44 def create_mbean(domain) SupervisorMBean.new(mbean_name(domain), mbean_description, self, {}) end |
#max_response_time ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/modern_times/jms/supervisor.rb', line 34 def max_response_time max_time = 0.0 workers.each do |w| wmax_time = w.time_track.max_time_reset max_time = wmax_time if wmax_time > max_time end return max_time end |
#message_counts ⇒ Object
9 10 11 |
# File 'lib/modern_times/jms/supervisor.rb', line 9 def workers.map { |w| w. } end |
#min_response_time ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/modern_times/jms/supervisor.rb', line 25 def min_response_time min_time = nil workers.each do |w| wmin_time = w.time_track.min_time_reset min_time = wmin_time if wmin_time && (!min_time || wmin_time < min_time) end return min_time || 0.0 end |