Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thefourtheye/faf3c1de1f13b1c023e99d45f34aa2d7 to your computer and use it in GitHub Desktop.
Save thefourtheye/faf3c1de1f13b1c023e99d45f34aa2d7 to your computer and use it in GitHub Desktop.
I am using Apache Curator Recipes v2.10.0, with Scala 2.11.8. I want to be notified whenever there is a change (addition, deletion, and updation) in the Node I am watching. Following is the code I have,
curatorClient = CuratorFrameworkFactory.newClient("proper Connection String"),
new ExponentialBackoffRetry(1000, 3))
curatorClient.start()
treeCache = new TreeCache(curatorClient, "/a")
treeCache.start()
treeCache.getListenable.addListener(new TreeCacheListener {
override def childEvent(client: CuratorFramework, event: TreeCacheEvent): Unit = {
event.getType match {
case TreeCacheEvent.Type.NODE_ADDED => ERROR("TreeNode added: "
+ ZKPaths.getNodeFromPath(event.getData.getPath) + ", value: "
+ new String(event.getData.getData))
case TreeCacheEvent.Type.NODE_UPDATED => ERROR("TreeNode Updated: "
+ ZKPaths.getNodeFromPath(event.getData.getPath) + ", value: "
+ new String(event.getData.getData))
case TreeCacheEvent.Type.NODE_REMOVED => ERROR("TreeNode Removed: "
+ ZKPaths.getNodeFromPath(event.getData.getPath) + ", value: "
+ new String(event.getData.getData));
case ex: TreeCacheEvent.Type => ERROR(s"Received Event [$ex]")
}
}
})
Now, the only message I get from this is
Received Event [INITIALIZED]
Nothing else. I tried adding nodes to /a through zkCli and also through the program (I use util-zk library for inserting). What am I missing?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment