Class: ModernTimes::ManagerMBean
- Inherits:
-
RubyDynamicMBean
- Object
- RubyDynamicMBean
- ModernTimes::ManagerMBean
- Defined in:
- lib/modern_times/manager_mbean.rb
Instance Attribute Summary collapse
-
#manager ⇒ Object
readonly
Returns the value of attribute manager.
Instance Method Summary collapse
- #allowed_workers ⇒ Object
-
#initialize(domain, manager) ⇒ ManagerMBean
constructor
A new instance of ManagerMBean.
- #start_worker(worker, count, options) ⇒ Object
Constructor Details
#initialize(domain, manager) ⇒ ManagerMBean
Returns a new instance of ManagerMBean.
8 9 10 11 |
# File 'lib/modern_times/manager_mbean.rb', line 8 def initialize(domain, manager) super(ModernTimes.manager_mbean_name(domain), 'Manager') @manager = manager end |
Instance Attribute Details
#manager ⇒ Object (readonly)
Returns the value of attribute manager.
5 6 7 |
# File 'lib/modern_times/manager_mbean.rb', line 5 def manager @manager end |
Instance Method Details
#allowed_workers ⇒ Object
13 14 15 16 17 |
# File 'lib/modern_times/manager_mbean.rb', line 13 def allowed_workers all = manager.allowed_workers || ['No Restrictions'] all = all.map {|worker_klass| worker_klass.name } java.util.ArrayList.new(all) end |
#start_worker(worker, count, options) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/modern_times/manager_mbean.rb', line 24 def start_worker(worker, count, ) ModernTimes.logger.debug "Attempting to start #{worker} with count=#{count} and options=#{}" opts = {} unless .empty? require 'json' opts_string_keys = ::JSON::Parser.new().parse opts_string_keys.each { |k,v| opts[k.to_sym] = v } end manager.add(worker, count, opts) return 'Successfuly started' rescue Exception => e ModernTimes.logger.error "Exception starting worker #{worker}: {e.message}\n\t#{e.backtrace.join("\n\t")}" return "Exception starting worker #{worker}: {e.message}" rescue java.lang.Exception => e ModernTimes.logger.error "Java exception starting worker #{worker}: {e.message}\n\t#{e.backtrace.join("\n\t")}" return "Java exception starting worker #{worker}: {e.message}" end |