Created
December 23, 2013 06:43
-
-
Save zhouyuan/8092641 to your computer and use it in GitHub Desktop.
change ring order
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
diff --git a/swift/proxy/server.py b/swift/proxy/server.py | |
index 1d5f968..a4cecba 100644 | |
--- a/swift/proxy/server.py | |
+++ b/swift/proxy/server.py | |
@@ -457,16 +457,32 @@ class Application(object): | |
handoff_nodes = node_iter | |
nodes_left = self.request_node_count(ring) | |
- for node in primary_nodes: | |
- if not self.error_limited(node): | |
- yield node | |
- if not self.error_limited(node): | |
- nodes_left -= 1 | |
- if nodes_left <= 0: | |
- return | |
+ | |
handoffs = 0 | |
- for node in handoff_nodes: | |
- if not self.error_limited(node): | |
+ for h_node in handoff_nodes: | |
+ for p_node in primary_nodes: | |
+ if not self.error_limited(p_node): | |
+ yield p_node | |
+ if not self.error_limited(p_node): | |
+ nodes_left -= 1 | |
+ if nodes_left <= 0: | |
+ return | |
+ else: | |
+ if not self.error_limited(h_node): | |
+ handoffs += 1 | |
+ if self.log_handoffs: | |
+ self.logger.increment('handoff_count') | |
+ self.logger.warning( | |
+ 'Handoff requested (%d)' % handoffs) | |
+ if handoffs == len(primary_nodes): | |
+ self.logger.increment('handoff_all_count') | |
+ yield h_node | |
+ h_node = handoff_nodes.next() | |
+ if not self.error_limited(h_node): | |
+ nodes_left -= 1 | |
+ if nodes_left <= 0: | |
+ return | |
+ if not self.error_limited(h_node): | |
handoffs += 1 | |
if self.log_handoffs: | |
self.logger.increment('handoff_count') | |
@@ -474,8 +490,8 @@ class Application(object): | |
'Handoff requested (%d)' % handoffs) | |
if handoffs == len(primary_nodes): | |
self.logger.increment('handoff_all_count') | |
- yield node | |
- if not self.error_limited(node): | |
+ yield h_node | |
+ if not self.error_limited(h_node): | |
nodes_left -= 1 | |
if nodes_left <= 0: | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment