README.txt 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. ZooKeeper REST implementation using Jersey JAX-RS.
  2. --------------------------------------------------
  3. This is an implementation of version 2 of the ZooKeeper REST spec.
  4. Note: This interface is currently experimental, may change at any time,
  5. etc... In general you should be using the Java/C client bindings to access
  6. the ZooKeeper server.
  7. This REST ZooKeeper gateway is useful because most of the languages
  8. have built-in support for working with HTTP based protocols.
  9. See SPEC.txt for details on the REST binding.
  10. Quickstart:
  11. -----------
  12. 1) start a zookeeper server on localhost port 2181
  13. 2) run "ant run"
  14. 3) use a REST client to access the data (see below for more details)
  15. curl http://localhost:9998/znodes/v1/
  16. or use the provided src/python scripts
  17. zk_dump_tree.py
  18. Tests:
  19. ----------
  20. 1) the full testsuite can be run via "ant test" target
  21. 2) the python client library also contains a test suite
  22. Examples Using CURL
  23. -------------------
  24. First review the spec SPEC.txt in this directory.
  25. #get the root node data
  26. curl http://localhost:9998/znodes/v1/
  27. #get children of the root node
  28. curl http://localhost:9998/znodes/v1/?view=children
  29. #get "/cluster1/leader" as xml (default is json)
  30. curl -H'Accept: application/xml' http://localhost:9998/znodes/v1/cluster1/leader
  31. #get the data as text
  32. curl -w "\n%{http_code}\n" "http://localhost:9998/znodes/v1/cluster1/leader?dataformat=utf8"
  33. #set a node (data.txt contains the ascii text you want to set on the node)
  34. curl -T data.txt -w "\n%{http_code}\n" "http://localhost:9998/znodes/v1/cluster1/leader?dataformat=utf8"
  35. #create a node
  36. curl -d "data1" -H'Content-Type: application/octet-stream' -w "\n%{http_code}\n" "http://localhost:9998/znodes/v1/?op=create&name=cluster2&dataformat=utf8"
  37. curl -d "data2" -H'Content-Type: application/octet-stream' -w "\n%{http_code}\n" "http://localhost:9998/znodes/v1/cluster2?op=create&name=leader&dataformat=utf8"
  38. #create a new session
  39. curl -d "" -H'Content-Type: application/octet-stream' -w "\n%{http_code}\n" "http://localhost:9998/sessions/v1/?op=create&expire=10"
  40. #session heartbeat
  41. curl -X "PUT" -H'Content-Type: application/octet-stream' -w "\n%{http_code}\n" "http://localhost:9998/sessions/v1/02dfdcc8-8667-4e53-a6f8-ca5c2b495a72"
  42. #delete a session
  43. curl -X "DELETE" -H'Content-Type: application/octet-stream' -w "\n%{http_code}\n" "http://localhost:9998/sessions/v1/02dfdcc8-8667-4e53-a6f8-ca5c2b495a72"