Zookeeper.sync() behavior

2022-09-22 Thread Keith Turner
I have read some documentation about Zookeeper.sync() that makes me
think there is no need to wait on its callback before reading data,
but its not explicitly stated in what I have read. I am wondering if
the following code is a reasonable way to get the latest data for
'/a/b'?

  ZooKeeper zooKeeper = null;

  AsyncCallback.VoidCallback cb;
  CompletableFuture returnCode = new CompletableFuture<>();
  zooKeeper.sync("/a/b", (rc, path, ctx) -> returnCode.complete(rc), null);
  zooKeeper.getData("/a/b",false, null);
  if(returnCode.get() != 0) {
//handle problem with sync
  }

Thanks

Keith


Automatically obtaining zookeeper server version

2017-04-03 Thread Keith Turner
A bit ago I wrote a blog post[1] about building shaded jars to run
Fluo applications with Spark.  In this post I advocated for building
the shaded jars with the versions of Fluo, Accumuo and ZooKeeper on
the system.  For obtaining the ZooKeeper version, I suggested the
following bash command in the post.

ZOOKEEPER_SERVER=localhost
ZOOKEEPER_VERSION=`echo status | nc $ZOOKEEPER_SERVER 2181 | grep
version: | sed 's/.*version: \([0-9.]*\).*/\1/'`

I was looking at this post recently and wondering if there is a better
way to get this info for ZooKeeper.  Does anyone know a
better/different way to accomplish this?

Thanks

Keith

[1]: http://fluo.apache.org/blog/2016/12/22/spark-load/