I've updated based on the last round of feedback regarding ZK operation:

This is what I think the API should look like for event based applications
without any insane requirements.

You write code like:

        NodeListener listener = new NodeListener() {

                public void onData( String path, Stat stat, byte[] data ) {
                    System.out.printf( "event: onData path: %s, version: %s,
data: %s\n", path, stat.getVersion(), new String( data ) );


                public void onKeeperException( KeeperException e ) {
                    System.out.printf( "event: onKeeperException: \n" );

                public void onFailure() {
                    System.out.printf( "event: onFailure\n" );

                public void onConnect() {
                    System.out.printf( "event: onConnect\n" );


        NodeWatcher nWatcher = new NodeWatcher( "server45.example.com:2181,
server46.example.com:2181,server47.example.com:2181", listener );
        nWatcher.watch( "/foo" );


.... and then you will receive events back from ZK when the files are

I believe it handles all race and fail conditions of ZK which was the hard
part since some of these are subtle or not really documented.

I'd be willing to contrib this if others found it useful.

I think we're going to use it as our main interface to ZK since it solves
all the issues I care about.


Founder/CEO Spinn3r.com
Location: San Francisco, CA
AIM/YIM: sfburtonator
Skype: burtonator
Work: http://spinn3r.com

Reply via email to