ZooKeeper
  1. ZooKeeper
  2. ZOOKEEPER-66

Add NullWatcher, a watcher that does nothing

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: java client
    • Labels:
      None

      Description

      I found that I was repeating this code all over the place. Here is a NullWatcher class, a Watcher that does nothing at all.

      1. nullwatcher.diff
        0.8 kB
        Anthony Urso

        Issue Links

          Activity

          Hide
          Anthony Urso added a comment -

          Patch attached.

          Show
          Anthony Urso added a comment - Patch attached.
          Hide
          Anthony Urso added a comment -

          Patch attached again.

          Show
          Anthony Urso added a comment - Patch attached again.
          Hide
          Flavio Junqueira added a comment -

          I'm not entirely convinced that this is a good idea. The watcher is important for the communication between ZooKeeper and the client, and I can understand if you want to use a null watcher in the case you're implementing a quick program for debugging or perhaps test purposes, but in such cases implementing the Watcher interface and declaring a process method that does nothing doesn't seem like a huge burden to me.

          I'm affraid that by adding a null watcher, we'll give the impression to users that implementing a Watcher is not that important.

          Show
          Flavio Junqueira added a comment - I'm not entirely convinced that this is a good idea. The watcher is important for the communication between ZooKeeper and the client, and I can understand if you want to use a null watcher in the case you're implementing a quick program for debugging or perhaps test purposes, but in such cases implementing the Watcher interface and declaring a process method that does nothing doesn't seem like a huge burden to me. I'm affraid that by adding a null watcher, we'll give the impression to users that implementing a Watcher is not that important.
          Hide
          Andrew Kornev added a comment -

          I concur with Flavio: application must implement a watcher. At the very least you'd want to know about the session events such as connect, disconnect, and especially session expiration and athentication failure. The latter two cannot be automatically recovered from and must be handled by the application in a certain way (a new ZooKeeper object must be instantiated).

          Show
          Andrew Kornev added a comment - I concur with Flavio: application must implement a watcher. At the very least you'd want to know about the session events such as connect, disconnect, and especially session expiration and athentication failure. The latter two cannot be automatically recovered from and must be handled by the application in a certain way (a new ZooKeeper object must be instantiated).
          Hide
          Patrick Hunt added a comment -

          Closing this issue.

          We don't want to encourage users to use null watchers. There are very limited cases where a null watcher might be useful - probably just during the initial "kicking the tires" phase of learning ZK.

          Implementing a production client requires the developer to implement a full watcher that is able to handle events and status changes (resetting watches if disconnected from the server for example).

          Show
          Patrick Hunt added a comment - Closing this issue. We don't want to encourage users to use null watchers. There are very limited cases where a null watcher might be useful - probably just during the initial "kicking the tires" phase of learning ZK. Implementing a production client requires the developer to implement a full watcher that is able to handle events and status changes (resetting watches if disconnected from the server for example).

            People

            • Assignee:
              Unassigned
              Reporter:
              Anthony Urso
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development