minor: formatting fix for repl_set_manager.rb
This commit is contained in:
parent
7d5ab886ed
commit
90e35d3137
|
@ -248,40 +248,40 @@ class ReplSetManager
|
||||||
raise ex
|
raise ex
|
||||||
end
|
end
|
||||||
if status['members'].all? { |m| m['health'] == 1 &&
|
if status['members'].all? { |m| m['health'] == 1 &&
|
||||||
[1, 2, 7].include?(m['state']) } &&
|
[1, 2, 7].include?(m['state']) } &&
|
||||||
status['members'].any? { |m| m['state'] == 1 }
|
status['members'].any? { |m| m['state'] == 1 }
|
||||||
|
|
||||||
connections = []
|
connections = []
|
||||||
states = []
|
states = []
|
||||||
status['members'].each do |member|
|
status['members'].each do |member|
|
||||||
begin
|
begin
|
||||||
host, port = member['name'].split(':')
|
host, port = member['name'].split(':')
|
||||||
port = port.to_i
|
port = port.to_i
|
||||||
conn = Mongo::Connection.new(host, port, :slave_ok => true)
|
conn = Mongo::Connection.new(host, port, :slave_ok => true)
|
||||||
connections << conn
|
connections << conn
|
||||||
state = conn['admin'].command({:ismaster => 1})
|
state = conn['admin'].command({:ismaster => 1})
|
||||||
states << state
|
states << state
|
||||||
rescue Mongo::ConnectionFailure
|
rescue Mongo::ConnectionFailure
|
||||||
connections.each {|c| c.close }
|
connections.each {|c| c.close }
|
||||||
con.close
|
con.close
|
||||||
raise Mongo::OperationFailure
|
raise Mongo::OperationFailure
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if states.any? {|s| s['ismaster']}
|
if states.any? {|s| s['ismaster']}
|
||||||
print "all members up!\n\n"
|
print "all members up!\n\n"
|
||||||
connections.each {|c| c.close }
|
connections.each {|c| c.close }
|
||||||
con.close
|
con.close
|
||||||
return status
|
return status
|
||||||
else
|
else
|
||||||
con.close
|
con.close
|
||||||
raise Mongo::OperationFailure
|
raise Mongo::OperationFailure
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
con.close
|
con.close
|
||||||
raise Mongo::OperationFailure
|
raise Mongo::OperationFailure
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue