Merge lp:~verterok/txstatsd/consistenthashing-py3k into lp:txstatsd

Proposed by Guillermo Gonzalez
Status: Merged
Approved by: Sidnei da Silva
Approved revision: 107
Merged at revision: 107
Proposed branch: lp:~verterok/txstatsd/consistenthashing-py3k
Merge into: lp:txstatsd
Diff against target: 36 lines (+4/-4)
2 files modified
txstatsd/client.py (+2/-2)
txstatsd/hashing.py (+2/-2)
To merge this branch: bzr merge lp:~verterok/txstatsd/consistenthashing-py3k
Reviewer Review Type Date Requested Status
Sidnei da Silva Approve
Review via email: mp+164023@code.launchpad.net

Commit message

add py3k support for the consistenthashing client

Description of the change

This branch adds py3k support for the consistenthashing client code.

To post a comment you must log in.
Revision history for this message
Sidnei da Silva (sidnei) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'txstatsd/client.py'
2--- txstatsd/client.py 2013-01-08 14:54:00 +0000
3+++ txstatsd/client.py 2013-05-15 18:59:30 +0000
4@@ -38,7 +38,7 @@
5 # for sys.stdout.encoding at the module-level of twisted.python.log. See:
6 # http://twistedmatrix.com/trac/ticket/6244 for more details.
7 pass
8-
9+
10 from txstatsd.hashing import ConsistentHashRing
11
12
13@@ -111,7 +111,7 @@
14
15 def write(self, data):
16 """Hash based on the metric name, then send to the right client."""
17- metric_name, rest = data.split(":", 1)
18+ metric_name, rest = str(data).split(":", 1)
19 client = self.ring.get_node(metric_name)
20 client.write(data)
21
22
23=== modified file 'txstatsd/hashing.py'
24--- txstatsd/hashing.py 2012-06-28 17:29:26 +0000
25+++ txstatsd/hashing.py 2013-05-15 18:59:30 +0000
26@@ -33,8 +33,8 @@
27 self.add_node(node)
28
29 def compute_ring_position(self, key):
30- big_hash = md5(str(key)).hexdigest()
31- small_hash = long(big_hash[:8], 16)
32+ big_hash = md5(key.encode('utf-8')).hexdigest()
33+ small_hash = int(big_hash[:8], 16)
34 return small_hash
35
36 def add_node(self, node):

Subscribers

People subscribed via source and target branches