Class: Wakame::AgentManagers::ActorManager

Inherits:
Object
  • Object
show all
Includes:
Wakame::AgentManager
Defined in:
lib/wakame/agent_managers/actor_manager.rb

Instance Attribute Summary collapse

Attributes included from Wakame::AgentManager

#agent

Instance Method Summary collapse

Methods included from Wakame::AgentManager

#reload, #start, #stop

Constructor Details

#initializeActorManager

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

#actorsObject (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

#initObject



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.message, :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

#terminateObject



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