Created
May 21, 2013 13:48
-
-
Save gswallow/5619904 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 def step_down(host, seconds) | |
80 connection = connect(host) | |
81 if is_master?(connection) | |
82 admin = connection['admin'] | |
83 cmd = BSON::OrderedHash.new | |
84 cmd['replSetStepDown'] = seconds | |
85 begin | |
86 admin.command(cmd, :check_response => true) | |
87 rescue Mongo::OperationFailure => e | |
88 raise "Could not step down. Perhaps MongoDB isn't healthy? (server said: #{e})" | |
89 rescue Mongo::ConnectionFailure | |
90 # reconfiguring destroys exisiting connections; live with it. | |
91 return true | |
92 end | |
93 end | |
94 end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment