Created
April 29, 2015 23:49
-
-
Save vjanelle/3b9b199b03c629bd012e to your computer and use it in GitHub Desktop.
kafka broker id from host ip address
This file contains hidden or 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
#!/usr/bin/python | |
import socket | |
# The general premise behind this is that kafka needs a unique broker id, and well, the ip address | |
# of the system has to be unique. They're both 32bit numbers, so why not? | |
broker_id = int(socket.inet_aton(socket.gethostbyname(socket.gethostname())).encode('hex'),16) | |
print "kafka_brokerid=%s" % str(broker_id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment