Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

cleanup

  • Loading branch information...
commit d3fbf69fd851ce8224f33eef119066da0ba36fa4 1 parent 889ff87
@ryanlecompte authored
View
6 lib/redis_failover/node_manager.rb
@@ -208,13 +208,10 @@ def handle_manual_failover(node)
# @param [Node] node the optional node to promote
# @note if no node is specified, a random slave will be used
def promote_new_master(node = nil)
- clients_lock = Mutex.new
presence_group = ZK::Group.new(@zk, CLIENT_PRESENCE_GROUP)
presence_group.create
-
ack_group = ZK::Group.new(@zk, CLIENT_FAILOVER_ACK_GROUP)
ack_group.create
-
clients = presence_group.member_names(:watch => true)
delete_path
@@ -223,6 +220,7 @@ def promote_new_master(node = nil)
# clients that appear, because we've already deleted the znode and
# they will automatically see the new master once we write out the
# new config.
+ clients_lock = Mutex.new
presence_group.on_membership_change do |old_members, current_members|
clients_lock.synchronize do
clients -= diff(clients, current_members)
@@ -237,7 +235,7 @@ def promote_new_master(node = nil)
end
end
logger.info('Waiting for ACK from clients to begin failover ...')
- if sleep_until(deadline, &condition)
+ if wait_until(deadline, &condition)
logger.info('Received failover ACK from all clients')
else
logger.info("Failed to receive failover ACK from all clients " +
View
4 lib/redis_failover/util.rb
@@ -141,12 +141,12 @@ def decode(data)
MultiJson.decode(data)
end
- # Sleeps until the deadline or the condition evaluates to true.
+ # Waits until the deadline or the condition evaluates to true.
#
# @param [Time] deadline the deadline time
# @param [Proc] condition the condition at which to stop sleeping
# @return [Boolean] true if condition met before deadline, false otherwise
- def sleep_until(deadline, &condition)
+ def wait_until(deadline, &condition)
remaining = deadline - Time.now
while remaining > 0
return true if condition.call
Please sign in to comment.
Something went wrong with that request. Please try again.