Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zk: Also try the znode used by Hortonworks #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions pybase/zk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
# quorum. It then asks ZK for the location of the MetaRegionServer,
# returning a tuple containing (host_name, port).
def LocateMaster(zkquorum, establish_connection_timeout=5, missing_znode_retries=5, zk=None):
znode_found = True

if zk is None:
# Using Kazoo for interfacing with ZK
Expand All @@ -50,13 +51,28 @@ def LocateMaster(zkquorum, establish_connection_timeout=5, missing_znode_retries
rsp, znodestat = zk.get(znode + "/meta-region-server")
except NoNodeError:
if missing_znode_retries == 0:
raise ZookeeperZNodeException(
"ZooKeeper does not contain meta-region-server node.")
logger.warn("ZooKeeper does not contain meta-region-server node. Retrying in 2 seconds. "
"(%s retries remaining)", missing_znode_retries)
sleep(2.0)
return LocateMaster(zkquorum, establish_connection_timeout=establish_connection_timeout,
missing_znode_retries=missing_znode_retries - 1, zk=zk)
znode_found = False
else:
logger.warn("ZooKeeper does not contain meta-region-server node. Retrying in 2 seconds. "
"(%s retries remaining)", missing_znode_retries)
sleep(2.0)
return LocateMaster(zkquorum, establish_connection_timeout=establish_connection_timeout,
missing_znode_retries=missing_znode_retries - 1, zk=zk)

# Hortonworks
if not znode_found:
try:
rsp, znodestat = zk.get("/hbase-unsecure/meta-region-server")
except NoNodeError:
if missing_znode_retries == 0:
raise ZookeeperZNodeException(
"ZooKeeper does not contain meta-region-server node.")
logger.warn("ZooKeeper does not contain meta-region-server node. Retrying in 2 seconds. "
"(%s retries remaining)", missing_znode_retries)
sleep(2.0)
return LocateMaster(zkquorum, establish_connection_timeout=establish_connection_timeout,
missing_znode_retries=missing_znode_retries - 1, zk=zk)

# We don't need to maintain a connection to ZK. If we need it again we'll
# recreate the connection. A possible future implementation can subscribe
# to ZK and listen for when RegionServers go down, then pre-emptively
Expand Down