Class: MotherBrain::Gear::JMX::Action Private

Inherits:
Object
  • Object
show all
Defined in:
lib/mb/gears/jmx/action.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(port, object_name, &block) ⇒ Action

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Action.

Parameters:

  • port (Fixnum)

    the port to connect over

  • object_name (String)

    the name of the jmx object

Raises:



18
19
20
21
22
23
24
25
26
# File 'lib/mb/gears/jmx/action.rb', line 18

def initialize(port, object_name, &block)
  unless block_given? && block.arity == 1
    raise ArgumentError, "block with one argument required to run JMX actions"
  end

  @port        = port
  @object_name = object_name
  @block       = block
end

Instance Attribute Details

#blockObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
# File 'lib/mb/gears/jmx/action.rb', line 12

def block
  @block
end

#object_nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



11
12
13
# File 'lib/mb/gears/jmx/action.rb', line 11

def object_name
  @object_name
end

#portObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/mb/gears/jmx/action.rb', line 10

def port
  @port
end

Instance Method Details

#run(job, environment, nodes) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Run this action on the specified nodes.

Parameters:

  • job (MB::Job)

    a job to update with status

  • environment (String)

    the environment this command is being run on

  • nodes (Array<Ridley::Node>)

    the nodes to run this action on



36
37
38
39
40
41
42
# File 'lib/mb/gears/jmx/action.rb', line 36

def run(job, environment, nodes)
  nodes.each do |node|
    connection = ::JMX::MBean.connection(host: node.public_hostname, port: port)
    mbean      = ::JMX::MBean.find_by_name(object_name, connection: connection)
    block.call(mbean)
  end
end