I want to get the member server list and their type(Leader or observer) in my java application. And also want to get the dead server.
Is their any way to do that? I read the document, but didn't find.
I want to get the member server list and their type(Leader or observer) in my java application. And also want to get the dead server.
Is their any way to do that? I read the document, but didn't find.
Zookeeper exposes this information over jmx.
It would be nice if there were a built-in answer for this without resorting to JMX. If you are on one of the zookeeper nodes, you can read the zoo.cfg file to get the list of servers (dead and alive ones) and then "stat" each one individually to see if it's alive and what its status is (note the "Mode" attribute on a successful response). E.g.:
$ echo stat | nc 127.0.0.1 2181
Zookeeper version: 3.4.5--1, built on 06/10/2013 17:26 GMT
Clients:
/127.0.0.1:54752[1](queued=0,recved=215524,sent=215524)
/127.0.0.1:59298[0](queued=0,recved=1,sent=0)
Latency min/avg/max: 0/0/6
Received: 5596
Sent: 5596
Connections: 2
Outstanding: 0
Zxid: 0x10000010f
Mode: leader
Node count: 54
Note that "stat" does not show you the other members of the zookeeper ensemble--it only shows you the connected clients.
echo srvr | nc 127.0.0.1 2181
–
Middleman Zookeeper exposes this information over jmx.
It can also be query sending "stat" command using direct connection to port 2181.
For an example of how to do that from python see: https://github.com/apache/zookeeper/blob/765cedb5c65526384011ea958e59938fc7493168/src/contrib/huebrowser/zkui/src/zkui/stats.py
© 2022 - 2024 — McMap. All rights reserved.