Class: PGPool::CommandLauncher
- Inherits:
-
Object
- Object
- PGPool::CommandLauncher
show all
- Defined in:
- lib/pgpool/command_launcher.rb
Overview
class: CommandLauncher, a simple wrapper for PCP PGPool management CLI
Constant Summary
collapse
- DEFAULT_PREFIX =
'/usr/sbin'
- PCP_NODE_COUNT_EXE =
'pcp_node_count'
- PCP_NODE_INFO_EXE =
'pcp_node_info'
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(hostname, port, user, password, timeout, options = {}) ⇒ CommandLauncher
Returns a new instance of CommandLauncher.
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/pgpool/command_launcher.rb', line 30
def initialize(hostname, port, user, password, timeout, options = {})
options = { prefix: DEFAULT_PREFIX }.merge(options)
@hostname = hostname
@port = port
@user = user
@password = password
@timeout = timeout
@pcp_command_options = "#{@timeout} #{@hostname} #{@port} #{@user} #{@password}"
@pcp_node_count_command = "#{File.join(options[:prefix], PCP_NODE_COUNT_EXE)} #{@pcp_command_options}"
@pcp_node_info_command = "#{File.join(options[:prefix], PCP_NODE_INFO_EXE)} #{@pcp_command_options}"
self
end
|
Instance Attribute Details
#number_of_nodes ⇒ Object
Returns the value of attribute number_of_nodes.
28
29
30
|
# File 'lib/pgpool/command_launcher.rb', line 28
def number_of_nodes
@number_of_nodes
end
|
Instance Method Details
54
55
56
57
|
# File 'lib/pgpool/command_launcher.rb', line 54
def node_information(node_id)
fail("Invalid node id(#{node_id}) must be between 0 and #{number_of_nodes - 1}") unless valid_node_id?(node_id)
Response.new(node_id, launch("#{@pcp_node_info_command} #{node_id}"))
end
|
59
60
61
|
# File 'lib/pgpool/command_launcher.rb', line 59
def nodes_information
number_of_nodes.times.map { |node_id| node_information(node_id) }
end
|
#valid_node_id?(node_id) ⇒ Boolean
50
51
52
|
# File 'lib/pgpool/command_launcher.rb', line 50
def valid_node_id?(node_id)
node_id >= 0 && node_id < number_of_nodes
end
|