Class PendingWatcher

java.lang.Object
org.apache.hadoop.hbase.zookeeper.PendingWatcher
All Implemented Interfaces:
org.apache.zookeeper.Watcher

class PendingWatcher extends Object implements org.apache.zookeeper.Watcher
Placeholder of a watcher which might be triggered before the instance is not yet created.

ZooKeeper starts its event thread within its constructor (and that is an anti-pattern), and the watcher passed to the constructor might be called back by the event thread before you get the instance of ZooKeeper from the constructor. If your watcher calls methods of ZooKeeper, pass this placeholder to the constructor of the ZooKeeper, create your watcher using the instance of ZooKeeper, and then call the method PendingWatcher.prepare.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.apache.zookeeper.Watcher

    org.apache.zookeeper.Watcher.Event, org.apache.zookeeper.Watcher.WatcherType
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final InstancePending<org.apache.zookeeper.Watcher>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
    prepare(org.apache.zookeeper.Watcher watcher)
    Associates the substantial watcher of processing events.
    void
    process(org.apache.zookeeper.WatchedEvent event)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • process

      public void process(org.apache.zookeeper.WatchedEvent event)
      Specified by:
      process in interface org.apache.zookeeper.Watcher
    • prepare

      void prepare(org.apache.zookeeper.Watcher watcher)
      Associates the substantial watcher of processing events. This method should be called once, and watcher should be non-null. This method is expected to call as soon as possible because the event processing, being invoked by the ZooKeeper event thread, is uninterruptibly blocked until this method is called.