Class: Wakame::AgentManagers::ActorManager
- Inherits:
-
Object
- Object
- Wakame::AgentManagers::ActorManager
- Includes:
- Wakame::AgentManager
- Defined in:
- lib/wakame/agent_managers/actor_manager.rb
Instance Attribute Summary collapse
-
#actors ⇒ Object
readonly
Returns the value of attribute actors.
Attributes included from Wakame::AgentManager
Instance Method Summary collapse
- #find_actor(path) ⇒ Object
- #init ⇒ Object
-
#initialize ⇒ ActorManager
constructor
A new instance of ActorManager.
- #register(actor, path = nil) ⇒ Object
- #terminate ⇒ Object
- #unregister(path) ⇒ Object
Methods included from Wakame::AgentManager
Constructor Details
#initialize ⇒ ActorManager
Returns a new instance of ActorManager.
34 35 36 |
# File 'lib/wakame/agent_managers/actor_manager.rb', line 34 def initialize() @actors = {} end |
Instance Attribute Details
#actors ⇒ Object (readonly)
Returns the value of attribute actors.
32 33 34 |
# File 'lib/wakame/agent_managers/actor_manager.rb', line 32 def actors @actors end |
Instance Method Details
#find_actor(path) ⇒ Object
58 59 60 |
# File 'lib/wakame/agent_managers/actor_manager.rb', line 58 def find_actor(path) @actors[path] end |
#init ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/wakame/agent_managers/actor_manager.rb', line 7 def init agent.add_subscriber("agent_actor.#{agent.agent_id}") { |data| begin request = eval(data) handle_request(request) rescue => e Wakame.log.error(e) publish_to('agent_event', Packets::ActorResponse.new(self, request[:token], Actor::STATUS_FAILED, {:message=>e., :exclass=>e.class.to_s}).marshal) end } register(Actor::ServiceMonitor.new, '/service_monitor') register(Actor::Daemon.new, '/daemon') register(Actor::System.new, '/system') register(Actor::MySQL.new, '/mysql') register(Actor::Deploy.new, '/deploy') register(Actor::Monitor.new, '/monitor') register(Actor::S3fs.new, '/s3fs') end |
#register(actor, path = nil) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/wakame/agent_managers/actor_manager.rb', line 38 def register(actor, path=nil) raise '' unless actor.kind_of?(Wakame::Actor) if path.nil? path = '/' + Util.to_const_path(actor.class.to_s) end if @actors.has_key?(path) Wakame.log.error("#{self.class}: Duplicate registration: #{path}") raise "Duplicate registration: #{path}" end actor.agent = self.agent @actors[path] = actor end |
#terminate ⇒ Object
29 30 |
# File 'lib/wakame/agent_managers/actor_manager.rb', line 29 def terminate end |
#unregister(path) ⇒ Object
54 55 56 |
# File 'lib/wakame/agent_managers/actor_manager.rb', line 54 def unregister(path) @actors.delete(path) end |