Skip to content

Instantly share code, notes, and snippets.

@pkazi
Created October 22, 2018 09:20
Show Gist options
  • Select an option

  • Save pkazi/d55069aed90ed70ba5525d3d2b6e9ab4 to your computer and use it in GitHub Desktop.

Select an option

Save pkazi/d55069aed90ed70ba5525d3d2b6e9ab4 to your computer and use it in GitHub Desktop.

Revisions

  1. pkazi created this gist Oct 22, 2018.
    19 changes: 19 additions & 0 deletions getMesosZKData.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    from kazoo.client import KazooClient

    zk = KazooClient(hosts='leader.mesos:2181', read_only=True)
    zk.start()

    clusterId = ""
    # Here we can give znode path to retrieve its decoded data,
    # for ex to get cluster-id, use
    # data, stat = zk.get("/cluster-id")
    # clusterId = data.decode("utf-8")

    # Get cluster Id
    if zk.exists("/cluster-id"):
    data, stat = zk.get("/cluster-id")
    clusterId = data.decode("utf-8")

    zk.stop()

    print (clusterId)