Class: Wakame::Master
- Inherits:
-
Object
- Object
- Wakame::Master
- Includes:
- AMQPClient, QueueDeclare
- Defined in:
- lib/wakame/master.rb
Instance Attribute Summary collapse
-
#agent_monitor ⇒ Object
readonly
Returns the value of attribute agent_monitor.
-
#command_queue ⇒ Object
readonly
Returns the value of attribute command_queue.
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#service_cluster ⇒ Object
readonly
Returns the value of attribute service_cluster.
-
#started_at ⇒ Object
readonly
Returns the value of attribute started_at.
Attributes included from AMQPClient
#amqp_client, #mq, #queue_subscribers
Instance Method Summary collapse
-
#actor_request(agent_id, path, *args) ⇒ Object
def send_agent_command(command, agent_id=nil) raise TypeError unless command.is_a? Packets::RequestBase EM.next_tick { if agent_id publish_to(‘agent_command’, “agent_id.#agent_id”, Marshal.dump(command)) else publish_to(‘agent_command’, ‘*’, Marshal.dump(command)) end } end.
- #attr ⇒ Object
- #cleanup ⇒ Object
-
#initialize(opts = {}) ⇒ Master
constructor
A new instance of Master.
- #master_local_agent_id ⇒ Object
Methods included from QueueDeclare
Methods included from AMQPClient
#add_subscriber, #amq, #close, #connect, #connected?, #define_queue, included, #publish_to
Constructor Details
#initialize(opts = {}) ⇒ Master
Returns a new instance of Master.
232 233 234 235 236 237 238 239 |
# File 'lib/wakame/master.rb', line 232 def initialize(opts={}) pre_setup connect(opts) { post_setup } Wakame.log.info("Started master process : WAKAME_ROOT=#{Wakame.config.root_path} WAKAME_ENV=#{Wakame.config.environment}") end |
Instance Attribute Details
#agent_monitor ⇒ Object (readonly)
Returns the value of attribute agent_monitor.
230 231 232 |
# File 'lib/wakame/master.rb', line 230 def agent_monitor @agent_monitor end |
#command_queue ⇒ Object (readonly)
Returns the value of attribute command_queue.
230 231 232 |
# File 'lib/wakame/master.rb', line 230 def command_queue @command_queue end |
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
230 231 232 |
# File 'lib/wakame/master.rb', line 230 def configuration @configuration end |
#service_cluster ⇒ Object (readonly)
Returns the value of attribute service_cluster.
230 231 232 |
# File 'lib/wakame/master.rb', line 230 def service_cluster @service_cluster end |
#started_at ⇒ Object (readonly)
Returns the value of attribute started_at.
230 231 232 |
# File 'lib/wakame/master.rb', line 230 def started_at @started_at end |
Instance Method Details
#actor_request(agent_id, path, *args) ⇒ Object
def send_agent_command(command, agent_id=nil)
raise TypeError unless command.is_a? Packets::RequestBase
EM.next_tick {
if agent_id
publish_to('agent_command', "agent_id.#{agent_id}", Marshal.dump(command))
else
publish_to('agent_command', '*', Marshal.dump(command))
end
}
end
253 254 255 256 |
# File 'lib/wakame/master.rb', line 253 def actor_request(agent_id, path, *args) request = Wakame::Packets::ActorRequest.new(agent_id, Util.gen_id, path, *args) ActorRequest.new(self, request) end |
#attr ⇒ Object
259 260 261 |
# File 'lib/wakame/master.rb', line 259 def attr agent_monitor.master_local.attr end |
#cleanup ⇒ Object
264 265 266 |
# File 'lib/wakame/master.rb', line 264 def cleanup @command_queue.shutdown end |
#master_local_agent_id ⇒ Object
268 269 270 |
# File 'lib/wakame/master.rb', line 268 def master_local_agent_id @master_local_agent_id end |