Object
# File lib/chef/expander/node.rb, line 34 def self.from_hash(node_info) new(node_info[:guid], node_info[:hostname_f], node_info[:pid]) end
# File lib/chef/expander/node.rb, line 42 def self.guid return @guid if @guid @guid = UUIDTools::UUID.random_create.to_s end
# File lib/chef/expander/node.rb, line 47 def self.hostname_f @hostname ||= Open3.popen3("hostname -f") {|stdin, stdout, stderr| stdout.read }.strip end
# File lib/chef/expander/node.rb, line 158 def ==(other) other.respond_to?(:guid) && other.respond_to?(:hostname_f) && other.respond_to?(:pid) && (other.guid == guid) && (other.hostname_f == hostname_f) && (other.pid == pid) end
# File lib/chef/expander/node.rb, line 67 def attach_to_queue(queue, colloquial_name, &message_handler) queue.subscribe(:ack => true) do |headers, payload| log.debug { "received message on #{colloquial_name} queue: #{payload}" } message_handler.call(payload) headers.ack end end
# File lib/chef/expander/node.rb, line 131 def broadcast_control_exchange @broadcast_control_exchange ||= begin log.debug { "declaring broadcast control exchange opscode-platfrom-control--broadcast" } MQ.fanout(broadcast_control_exchange_name, :nowait => false) end end
# File lib/chef/expander/node.rb, line 146 def broadcast_control_exchange_name BROADCAST_CONTROL_EXCHANGE_NAME end
The broadcast control queue is for 1 to N messaging, i.e., messages that go to every node
# File lib/chef/expander/node.rb, line 121 def broadcast_control_queue @broadcast_control_queue ||= begin log.debug { "declaring broadcast control queue #{broadcast_control_queue_name}"} q = MQ.queue(broadcast_control_queue_name) log.debug { "binding broadcast control queue to broadcast control exchange"} q.bind(broadcast_control_exchange) q end end
# File lib/chef/expander/node.rb, line 142 def broadcast_control_queue_name @broadcast_control_queue_name ||= "#{identifier}--broadcast" end
# File lib/chef/expander/node.rb, line 96 def broadcast_message(message) log.debug { "publishing broadcast message #{message}" } broadcast_control_exchange.publish(message) end
# File lib/chef/expander/node.rb, line 86 def direct_message(message) log.debug { "publishing direct message to node #{identifier}: #{message}" } exclusive_control_queue.publish(message) end
# File lib/chef/expander/node.rb, line 163 def eql?(other) (other.class == self.class) && (other.hash == hash) end
The exclusive control queue is for point-to-point messaging, i.e., messages directly addressed to this node
# File lib/chef/expander/node.rb, line 103 def exclusive_control_queue @exclusive_control_queue ||= begin log.debug { "declaring exclusive control queue #{exclusive_control_queue_name}" } MQ.queue(exclusive_control_queue_name) end end
# File lib/chef/expander/node.rb, line 150 def exclusive_control_queue_name @exclusive_control_queue_name ||= "#{identifier}--exclusive-control" end
# File lib/chef/expander/node.rb, line 167 def hash identifier.hash end
# File lib/chef/expander/node.rb, line 154 def identifier "#{hostname_f}--#{pid}--#{guid}" end
# File lib/chef/expander/node.rb, line 61 def start(&message_handler) attach_to_queue(exclusive_control_queue, "exclusive control", &message_handler) attach_to_queue(shared_control_queue, "shared_control", &message_handler) attach_to_queue(broadcast_control_queue, "broadcast control", &message_handler) end
# File lib/chef/expander/node.rb, line 75 def stop log.debug { "unsubscribing from broadcast control queue"} broadcast_control_queue.unsubscribe(:nowait => false) log.debug { "unsubscribing from shared control queue" } shared_control_queue.unsubscribe(:nowait => false) log.debug { "unsubscribing from exclusive control queue" } exclusive_control_queue.unsubscribe(:nowait => false) end
Generated with the Darkfish Rdoc Generator 2.