# Uses of Interface
org.apache.zookeeper.Watcher

Packages that use Watcher
Package
Description
org.apache.zookeeper
org.apache.zookeeper.admin
org.apache.zookeeper.inspector.manager
org.apache.zookeeper.retry
org.apache.zookeeper.server
ZooKeeper server theory of operation
org.apache.zookeeper.server.controller
org.apache.zookeeper.server.watch
org.apache.zookeeper.test.system

## Uses of Watcher in org.apache.zookeeper

Methods in org.apache.zookeeper that return types with arguments of type Watcher
Modifier and Type
Method
Description
`protected abstract Map<String, Set<Watcher>>`
ZooKeeper.WatchRegistration.`getWatches(int rc)`
`Set<Watcher>`
ClientWatchManager.`materialize(Watcher.Event.KeeperState state, Watcher.Event.EventType type, String path)`
Return a set of watchers that should be notified of the event.
`Map<Watcher.Event.EventType, Set<Watcher>>`
WatchDeregistration.`unregister(int rc)`
Unregistering watcher that was added on path.
Methods in org.apache.zookeeper with parameters of type Watcher
Modifier and Type
Method
Description
`void`
ZooKeeper.`addWatch(String basePath, Watcher watcher, AddWatchMode mode)`
Add a watch to the given znode using the given mode.
`void`
ZooKeeper.`addWatch(String basePath, Watcher watcher, AddWatchMode mode, AsyncCallback.VoidCallback cb, Object ctx)`
Async version of `ZooKeeper.addWatch(String, Watcher, AddWatchMode)` (see it for details)
`Stat`
ZooKeeper.`exists(String path, Watcher watcher)`
Return the stat of the node of the given path.
`void`
ZooKeeper.`exists(String path, Watcher watcher, AsyncCallback.StatCallback cb, Object ctx)`
The asynchronous version of exists.
`List<String>`
ZooKeeper.`getChildren(String path, Watcher watcher)`
Return the list of the children of the node of the given path.
`void`
ZooKeeper.`getChildren(String path, Watcher watcher, AsyncCallback.Children2Callback cb, Object ctx)`
The asynchronous version of getChildren.
`void`
ZooKeeper.`getChildren(String path, Watcher watcher, AsyncCallback.ChildrenCallback cb, Object ctx)`
The asynchronous version of getChildren.
`List<String>`
ZooKeeper.`getChildren(String path, Watcher watcher, Stat stat)`
For the given znode path return the stat and children list.
`void`
ZooKeeper.`getConfig(Watcher watcher, AsyncCallback.DataCallback cb, Object ctx)`
The asynchronous version of getConfig.
`byte[]`
ZooKeeper.`getConfig(Watcher watcher, Stat stat)`
Return the last committed configuration (as known to the server to which the client is connected) and the stat of the configuration.
`void`
ZooKeeper.`getData(String path, Watcher watcher, AsyncCallback.DataCallback cb, Object ctx)`
The asynchronous version of getData.
`byte[]`
ZooKeeper.`getData(String path, Watcher watcher, Stat stat)`
Return the data and the stat of the node of the given path.
`void`
ZooKeeper.`register(Watcher watcher)`
Specify the default watcher for the connection (overrides the one specified during construction).
`void`
ZooKeeper.`removeWatches(String path, Watcher watcher, Watcher.WatcherType watcherType, boolean local)`
For the given znode path, removes the specified watcher of given watcherType.
`void`
ZooKeeper.`removeWatches(String path, Watcher watcher, Watcher.WatcherType watcherType, boolean local, AsyncCallback.VoidCallback cb, Object ctx)`
The asynchronous version of removeWatches.
Constructors in org.apache.zookeeper with parameters of type Watcher
Modifier
Constructor
Description
``
`ClientCnxn(String chrootPath, HostProvider hostProvider, int sessionTimeout, ZKClientConfig clientConfig, Watcher defaultWatcher, org.apache.zookeeper.ClientCnxnSocket clientCnxnSocket, boolean canBeReadOnly)`
Creates a connection object.
``
`ClientCnxn(String chrootPath, HostProvider hostProvider, int sessionTimeout, ZKClientConfig clientConfig, Watcher defaultWatcher, org.apache.zookeeper.ClientCnxnSocket clientCnxnSocket, long sessionId, byte[] sessionPasswd, boolean canBeReadOnly)`
Creates a connection object.
``
`WatchDeregistration(String clientPath, Watcher watcher, Watcher.WatcherType watcherType, boolean local, org.apache.zookeeper.ZKWatchManager zkManager)`
``
`WatchRegistration(Watcher watcher, String clientPath)`
``
`ZooKeeper(String connectString, int sessionTimeout, Watcher watcher)`
To create a ZooKeeper client object, the application needs to pass a connection string containing a comma separated list of host:port pairs, each corresponding to a ZooKeeper server.
``
`ZooKeeper(String connectString, int sessionTimeout, Watcher watcher, boolean canBeReadOnly)`
To create a ZooKeeper client object, the application needs to pass a connection string containing a comma separated list of host:port pairs, each corresponding to a ZooKeeper server.
``
`ZooKeeper(String connectString, int sessionTimeout, Watcher watcher, boolean canBeReadOnly, HostProvider aHostProvider)`
To create a ZooKeeper client object, the application needs to pass a connection string containing a comma separated list of host:port pairs, each corresponding to a ZooKeeper server.
``
`ZooKeeper(String connectString, int sessionTimeout, Watcher watcher, boolean canBeReadOnly, HostProvider hostProvider, ZKClientConfig clientConfig)`
To create a ZooKeeper client object, the application needs to pass a connection string containing a comma separated list of host:port pairs, each corresponding to a ZooKeeper server.
``
`ZooKeeper(String connectString, int sessionTimeout, Watcher watcher, boolean canBeReadOnly, ZKClientConfig conf)`
To create a ZooKeeper client object, the application needs to pass a connection string containing a comma separated list of host:port pairs, each corresponding to a ZooKeeper server.
``
`ZooKeeper(String connectString, int sessionTimeout, Watcher watcher, long sessionId, byte[] sessionPasswd)`
To create a ZooKeeper client object, the application needs to pass a connection string containing a comma separated list of host:port pairs, each corresponding to a ZooKeeper server.
``
`ZooKeeper(String connectString, int sessionTimeout, Watcher watcher, long sessionId, byte[] sessionPasswd, boolean canBeReadOnly)`
To create a ZooKeeper client object, the application needs to pass a connection string containing a comma separated list of host:port pairs, each corresponding to a ZooKeeper server.
``
`ZooKeeper(String connectString, int sessionTimeout, Watcher watcher, long sessionId, byte[] sessionPasswd, boolean canBeReadOnly, HostProvider aHostProvider)`
To create a ZooKeeper client object, the application needs to pass a connection string containing a comma separated list of host:port pairs, each corresponding to a ZooKeeper server.
``
`ZooKeeper(String connectString, int sessionTimeout, Watcher watcher, long sessionId, byte[] sessionPasswd, boolean canBeReadOnly, HostProvider hostProvider, ZKClientConfig clientConfig)`
To create a ZooKeeper client object, the application needs to pass a connection string containing a comma separated list of host:port pairs, each corresponding to a ZooKeeper server.
``
`ZooKeeper(String connectString, int sessionTimeout, Watcher watcher, ZKClientConfig conf)`
To create a ZooKeeper client object, the application needs to pass a connection string containing a comma separated list of host:port pairs, each corresponding to a ZooKeeper server.

## Uses of Watcher in org.apache.zookeeper.admin

Constructors in org.apache.zookeeper.admin with parameters of type Watcher
Modifier
Constructor
Description
``
`ZooKeeperAdmin(String connectString, int sessionTimeout, Watcher watcher)`
Create a ZooKeeperAdmin object which is used to perform dynamic reconfiguration operations.
``
`ZooKeeperAdmin(String connectString, int sessionTimeout, Watcher watcher, boolean canBeReadOnly)`
Create a ZooKeeperAdmin object which is used to perform dynamic reconfiguration operations.
``
`ZooKeeperAdmin(String connectString, int sessionTimeout, Watcher watcher, boolean canBeReadOnly, ZKClientConfig conf)`
Create a ZooKeeperAdmin object which is used to perform dynamic reconfiguration operations.
``
`ZooKeeperAdmin(String connectString, int sessionTimeout, Watcher watcher, ZKClientConfig conf)`
Create a ZooKeeperAdmin object which is used to perform dynamic reconfiguration operations.

## Uses of Watcher in org.apache.zookeeper.inspector.manager

Classes in org.apache.zookeeper.inspector.manager that implement Watcher
Modifier and Type
Class
Description
`class`
`ZooInspectorManagerImpl.NodeWatcher`
A Watcher which will re-add itself every time an event is fired

## Uses of Watcher in org.apache.zookeeper.retry

Methods in org.apache.zookeeper.retry with parameters of type Watcher
Modifier and Type
Method
Description
`Stat`
ZooKeeperRetry.`exists(String path, Watcher watcher)`
`List<String>`
ZooKeeperRetry.`getChildren(String path, Watcher watcher)`
`byte[]`
ZooKeeperRetry.`getData(String path, Watcher watcher, Stat stat)`
Constructors in org.apache.zookeeper.retry with parameters of type Watcher
Modifier
Constructor
Description
``
`ZooKeeperRetry(String connectString, int sessionTimeout, Watcher watcher)`
``
`ZooKeeperRetry(String connectString, int sessionTimeout, Watcher watcher, long sessionId, byte[] sessionPasswd)`

## Uses of Watcher in org.apache.zookeeper.server

Subinterfaces of Watcher in org.apache.zookeeper.server
Modifier and Type
Interface
Description
`interface`
`ServerWatcher`
Classes in org.apache.zookeeper.server that implement Watcher
Modifier and Type
Class
Description
`class`
`DumbWatcher`
A empty watcher implementation used in bench and unit test.
`class`
`NettyServerCnxn`
`class`
`NIOServerCnxn`
This class handles communication with clients using NIO.
`class`
`ServerCnxn`
Interface to a Server connection - represents a connection from a client to the server.
Methods in org.apache.zookeeper.server with parameters of type Watcher
Modifier and Type
Method
Description
`void`
DataTree.`addWatch(String basePath, Watcher watcher, int mode)`
`void`
ZKDatabase.`addWatch(String basePath, Watcher watcher, int mode)`
Add a watch
`boolean`
DataTree.`containsWatcher(String path, Watcher.WatcherType type, Watcher watcher)`
`boolean`
ZKDatabase.`containsWatcher(String path, Watcher.WatcherType type, Watcher watcher)`
Check whether the given watcher exists in datatree
`List<String>`
DataTree.`getChildren(String path, Stat stat, Watcher watcher)`
`List<String>`
ZKDatabase.`getChildren(String path, Stat stat, Watcher watcher)`
get children list for this path
`byte[]`
DataTree.`getData(String path, Stat stat, Watcher watcher)`
`byte[]`
ZKDatabase.`getData(String path, Stat stat, Watcher watcher)`
get data and stat for a path
`void`
DataTree.`removeCnxn(Watcher watcher)`
`boolean`
DataTree.`removeWatch(String path, Watcher.WatcherType type, Watcher watcher)`
`boolean`
ZKDatabase.`removeWatch(String path, Watcher.WatcherType type, Watcher watcher)`
Remove watch from the datatree
`void`
DataTree.`setWatches(long relativeZxid, List<String> dataWatches, List<String> existWatches, List<String> childWatches, List<String> persistentWatches, List<String> persistentRecursiveWatches, Watcher watcher)`
`void`
ZKDatabase.`setWatches(long relativeZxid, List<String> dataWatches, List<String> existWatches, List<String> childWatches, List<String> persistentWatches, List<String> persistentRecursiveWatches, Watcher watcher)`
set watches on the datatree
`Stat`
DataTree.`statNode(String path, Watcher watcher)`

## Uses of Watcher in org.apache.zookeeper.server.controller

Classes in org.apache.zookeeper.server.controller that implement Watcher
Modifier and Type
Class
Description
`class`
`ControllableConnection`
Extension of NIOServerCnxn which can inject changes per controller commands.

## Uses of Watcher in org.apache.zookeeper.server.watch

Methods in org.apache.zookeeper.server.watch that return types with arguments of type Watcher
Modifier and Type
Method
Description
`Map<Watcher, Set<String>>`
WatchManagerOptimized.`getWatcher2PathesMap()`
May cause OOM if there are lots of watches, might better to forbid it in this class.
Methods in org.apache.zookeeper.server.watch with parameters of type Watcher
Modifier and Type
Method
Description
`boolean`
IWatchManager.`addWatch(String path, Watcher watcher)`
Add watch to specific path.
`default boolean`
IWatchManager.`addWatch(String path, Watcher watcher, WatcherMode watcherMode)`
Add watch to specific path.
`boolean`
WatchManager.`addWatch(String path, Watcher watcher)`
`boolean`
WatchManager.`addWatch(String path, Watcher watcher, WatcherMode watcherMode)`
`boolean`
WatchManagerOptimized.`addWatch(String path, Watcher watcher)`
`boolean`
WatcherOrBitSet.`contains(Watcher watcher)`
`boolean`
IWatchManager.`containsWatcher(String path, Watcher watcher)`
Checks the specified watcher exists for the given path.
`default boolean`
IWatchManager.`containsWatcher(String path, Watcher watcher, WatcherMode watcherMode)`
Checks the specified watcher exists for the given path and mode.
`boolean`
WatchManager.`containsWatcher(String path, Watcher watcher)`
`boolean`
WatchManager.`containsWatcher(String path, Watcher watcher, WatcherMode watcherMode)`
`boolean`
WatchManagerOptimized.`containsWatcher(String path, Watcher watcher)`
Used in the OpCode.checkWatches, which is a read operation, since read and write requests are exclusively processed, we don't need to hold lock here.
`boolean`
IWatchManager.`removeWatcher(String path, Watcher watcher)`
Removes the specified watcher for the given path.
`default boolean`
IWatchManager.`removeWatcher(String path, Watcher watcher, WatcherMode watcherMode)`
Removes the specified watcher for the given path and mode.
`void`
IWatchManager.`removeWatcher(Watcher watcher)`
The entry to remove the watcher when the cnxn is closed.
`boolean`
WatchManager.`removeWatcher(String path, Watcher watcher)`
`boolean`
WatchManager.`removeWatcher(String path, Watcher watcher, WatcherMode watcherMode)`
`void`
WatchManager.`removeWatcher(Watcher watcher)`
`boolean`
WatchManagerOptimized.`removeWatcher(String path, Watcher watcher)`
`void`
WatchManagerOptimized.`removeWatcher(Watcher watcher)`
Constructor parameters in org.apache.zookeeper.server.watch with type arguments of type Watcher
Modifier
Constructor
Description
``
`WatcherOrBitSet(Set<Watcher> watchers)`

## Uses of Watcher in org.apache.zookeeper.test.system

Classes in org.apache.zookeeper.test.system that implement Watcher
Modifier and Type
Class
Description
`class`
`InstanceContainer`
This class starts up,
`class`
`InstanceManager`
This class doles out assignments to InstanceContainers that are registered to a ZooKeeper znode.
`class`
`SimpleClient`
The client that gets spawned for the SimpleSysTest
`class`
`SimpleSysTest`
This does a basic system test.