twitter/commons — pull request #21 by leothekim (2012-03-26 20:50:49+00:00)
Title: Add support for Stat population in ZooKeeperNode

I added two new methods, createWithStat, that take a Function, T> argument. The goal is to have access to the Stat object that's populated by zooKeeperClient.getData(path, watcher, stat) without breaking compatibility with existing users of the Stat method.

Motivation for this is that, though this class is pretty useful for its caching and watch handling, I need to be able to track data versions so different threads don't overwrite each other accidentally.

There were a couple hoops to jump through to get this to work cleanly, primarily the creation of a helper interface to make it seamless to switch between Function and Function deserializers. This probably could have been solved with an instanceof, but.. meh.

Any suggestions or thoughts about how this is useful/useless are obviously welcome.

leo