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

Use srvr, not stat for zxid #99

Merged
merged 2 commits into from
Jan 9, 2019
Merged
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
28 changes: 9 additions & 19 deletions zk_shell/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -1698,26 +1698,16 @@ def fetch(endpoint, states, znodes, ephemerals, datasize, sessions, zxids, idx):
ephemerals[idx] = int(eph_count)
datasize[idx] = int(dsize)
sessions[idx] = int(session_count)
zxids[idx] = -1

def fetch_zxid(endpoint):
zxid = -1
try:
stat = self._zk.cmd(hosts_to_endpoints(endpoint), "stat")
for line in stat.split("\n"):
if "Zxid:" in line:
zxid = int(line.split(None)[1], 0)
except:
pass
return zxid

# the stat cmd is a bit flaky, so try a few times
zxid = -1
for i in range(0, stat_retries):
zxid = fetch_zxid(endpoint)
if zxid != -1:
break

zxids[idx]= zxid
try:
srvr = self._zk.cmd(hosts_to_endpoints(endpoint), "srvr")
for line in srvr.split("\n"):
if "Zxid:" in line:
zxids[idx] = int(line.split(None)[1], 0)
break
except:
pass

workers = []
for idx, endpoint in enumerate(endpoints, 1):
Expand Down