Class: Wakame::Master

Inherits:
Object
  • Object
show all
Includes:
AMQPClient, QueueDeclare
Defined in:
lib/wakame/master.rb

Instance Attribute Summary collapse

Attributes included from AMQPClient

#amqp_client, #mq, #queue_subscribers

Instance Method Summary collapse

Methods included from QueueDeclare

included

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_monitorObject (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_queueObject (readonly)

Returns the value of attribute command_queue.



230
231
232
# File 'lib/wakame/master.rb', line 230

def command_queue
  @command_queue
end

#configurationObject (readonly)

Returns the value of attribute configuration.



230
231
232
# File 'lib/wakame/master.rb', line 230

def configuration
  @configuration
end

#service_clusterObject (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_atObject (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

#attrObject



259
260
261
# File 'lib/wakame/master.rb', line 259

def attr
  agent_monitor.master_local.attr
end

#cleanupObject



264
265
266
# File 'lib/wakame/master.rb', line 264

def cleanup
  @command_queue.shutdown
end

#master_local_agent_idObject



268
269
270
# File 'lib/wakame/master.rb', line 268

def master_local_agent_id
  @master_local_agent_id
end