apache-zookeeperapache-curator

Curator Framework - read data and stats in one request


In my application I use Curator Framework to perform operations in Zookeeper.

I want to read data with timestamp of creation (ctime) and timestamp of modification (mtime) from path. I try to do it, but I don't see any method to get data with stats.

The only working method I found is to do two separate requests.

First:

final Stat stat = curator.checkExists().forPath("myPath");
final long ctime = stat.getCtime();
final long mtime = stat.getMtime();

and second:

final byte[] data = curator.getData().forPath("myPath");

Is there any other way to perform such read operation in one request?


Solution

  • Do it this way:

    Stat stat = new Stat();
    byte[] data = client.getData().storingStatIn(stat).forPath("myPath");