Apply ZOOKEEPER-1870.patch.

https://issues.apache.org/jira/secure/attachment/12635000/ZOOKEEPER-1870.patch
add a class for getting hostname.