Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanlecompte committed Oct 8, 2012
1 parent 1a8378e commit e2fec76
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions lib/redis_failover/node_manager.rb
Expand Up @@ -177,11 +177,10 @@ def handle_syncing(node, snapshots)
if node.syncing_with_master? && node.prohibits_stale_reads?
logger.info("Node #{node} not ready yet, still syncing with master.")
force_unavailable_slave(node)
return
else
# otherwise, we can use this node
handle_available(node, snapshots)
end

# otherwise, we can use this node
handle_available(node, snapshots)
end

# Handles a manual failover request to the given node.
Expand Down Expand Up @@ -213,18 +212,18 @@ def promote_new_master(snapshots, node = nil)
# make a specific node or selected candidate the new master
candidate = node || failover_strategy_candidate(snapshots)

unless candidate
if candidate.nil?
logger.error('Failed to promote a new master, no candidate available.')
return
else
@slaves.delete(candidate)
@unavailable.delete(candidate)
redirect_slaves_to(candidate)
candidate.make_master!
@master = candidate
write_current_redis_nodes
@master_promotion_attempts = 0
logger.info("Successfully promoted #{candidate} to master.")
end

@slaves.delete(candidate)
redirect_slaves_to(candidate)
candidate.make_master!
@master = candidate
write_current_redis_nodes
@master_promotion_attempts = 0
logger.info("Successfully promoted #{candidate} to master.")
end

# Discovers the current master and slave nodes.
Expand Down

0 comments on commit e2fec76

Please sign in to comment.