curator-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sakthipriyan Vairamani <sakthiprofessio...@gmail.com>
Subject TreeCache not working
Date Thu, 31 Mar 2016 17:29:46 GMT
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?

Mime
View raw message