Fix for repl set manager
This commit is contained in:
parent
1095a39299
commit
196a84ebd0
|
@ -147,7 +147,7 @@ class ReplSetManager
|
||||||
def ensure_up
|
def ensure_up
|
||||||
print "** Ensuring members are up..."
|
print "** Ensuring members are up..."
|
||||||
|
|
||||||
attempt(Mongo::OperationFailure) do
|
attempt do
|
||||||
con = get_connection
|
con = get_connection
|
||||||
status = con['admin'].command({'replSetGetStatus' => 1})
|
status = con['admin'].command({'replSetGetStatus' => 1})
|
||||||
print "."
|
print "."
|
||||||
|
@ -179,7 +179,7 @@ class ReplSetManager
|
||||||
def initiate
|
def initiate
|
||||||
con = get_connection
|
con = get_connection
|
||||||
|
|
||||||
attempt(Mongo::OperationFailure) do
|
attempt do
|
||||||
con['admin'].command({'replSetInitiate' => @config})
|
con['admin'].command({'replSetInitiate' => @config})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -208,7 +208,7 @@ class ReplSetManager
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_connection(node=nil)
|
def get_connection(node=nil)
|
||||||
con = attempt(Mongo::ConnectionFailure) do
|
con = attempt do
|
||||||
if !node
|
if !node
|
||||||
node = @mongods.keys.detect {|key| !@mongods[key]['arbiterOnly'] && @mongods[key]['up'] }
|
node = @mongods.keys.detect {|key| !@mongods[key]['arbiterOnly'] && @mongods[key]['up'] }
|
||||||
end
|
end
|
||||||
|
@ -222,14 +222,14 @@ class ReplSetManager
|
||||||
File.join(@path, name)
|
File.join(@path, name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def attempt(exception)
|
def attempt
|
||||||
raise "No block given!" unless block_given?
|
raise "No block given!" unless block_given?
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
while count < @retries do
|
while count < @retries do
|
||||||
begin
|
begin
|
||||||
return yield
|
return yield
|
||||||
rescue exception, Mongo::ConnectionFailure
|
rescue Mongo::OperationFailure, Mongo::ConnectionFailure
|
||||||
sleep(1)
|
sleep(1)
|
||||||
count += 1
|
count += 1
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue