Class WatchManager
java.lang.Object
org.apache.zookeeper.server.watch.WatchManager
- All Implemented Interfaces:
IWatchManager
This class manages watches. It allows watches to be associated with a string
and removes watchers and their watches in addition to managing triggers.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Add watch to specific path.boolean
addWatch
(String path, Watcher watcher, WatcherMode watcherMode) Add watch to specific path.boolean
containsWatcher
(String path, Watcher watcher) Checks the specified watcher exists for the given path.void
dumpWatches
(PrintWriter pwriter, boolean byPath) String representation of watches.int
Return the current number of recursive watchersReturns a watch report.Returns a watch report by path.Returns a watch summary.boolean
removeWatcher
(String path, Watcher watcher) Removes the specified watcher for the given path.void
removeWatcher
(Watcher watcher) The entry to remove the watcher when the cnxn is closed.void
shutdown()
Clean up the watch manager.int
size()
Get the size of watchers.toString()
triggerWatch
(String path, Watcher.Event.EventType type, List<ACL> acl) Distribute the watch event for the given path.triggerWatch
(String path, Watcher.Event.EventType type, List<ACL> acl, WatcherOrBitSet supress) Distribute the watch event for the given path, but ignore those suppressed ones.
-
Constructor Details
-
WatchManager
public WatchManager()
-
-
Method Details
-
size
public int size()Description copied from interface:IWatchManager
Get the size of watchers.- Specified by:
size
in interfaceIWatchManager
- Returns:
- the watchers number managed in this class.
-
addWatch
Description copied from interface:IWatchManager
Add watch to specific path.- Specified by:
addWatch
in interfaceIWatchManager
- Parameters:
path
- znode pathwatcher
- watcher object reference- Returns:
- true if the watcher added is not already present
-
addWatch
Description copied from interface:IWatchManager
Add watch to specific path.- Specified by:
addWatch
in interfaceIWatchManager
- Parameters:
path
- znode pathwatcher
- watcher object referencewatcherMode
- the watcher mode to use- Returns:
- true if the watcher added is not already present
-
removeWatcher
Description copied from interface:IWatchManager
The entry to remove the watcher when the cnxn is closed.- Specified by:
removeWatcher
in interfaceIWatchManager
- Parameters:
watcher
- watcher object reference
-
triggerWatch
Description copied from interface:IWatchManager
Distribute the watch event for the given path.- Specified by:
triggerWatch
in interfaceIWatchManager
- Parameters:
path
- znode pathtype
- the watch event typeacl
- ACL of the znode in path- Returns:
- the watchers have been notified
-
triggerWatch
public WatcherOrBitSet triggerWatch(String path, Watcher.Event.EventType type, List<ACL> acl, WatcherOrBitSet supress) Description copied from interface:IWatchManager
Distribute the watch event for the given path, but ignore those suppressed ones.- Specified by:
triggerWatch
in interfaceIWatchManager
- Parameters:
path
- znode pathtype
- the watch event typesupress
- the suppressed watcher set- Returns:
- the watchers have been notified
-
toString
-
dumpWatches
Description copied from interface:IWatchManager
String representation of watches. Warning, may be large!- Specified by:
dumpWatches
in interfaceIWatchManager
- Parameters:
pwriter
- the writer to dump the watchesbyPath
- iff true output watches by paths, otw output watches by connection
-
containsWatcher
Description copied from interface:IWatchManager
Checks the specified watcher exists for the given path.- Specified by:
containsWatcher
in interfaceIWatchManager
- Parameters:
path
- znode pathwatcher
- watcher object reference- Returns:
- true if the watcher exists, false otherwise
-
removeWatcher
Description copied from interface:IWatchManager
Removes the specified watcher for the given path.- Specified by:
removeWatcher
in interfaceIWatchManager
- Parameters:
path
- znode pathwatcher
- watcher object reference- Returns:
- true if the watcher successfully removed, false otherwise
-
getWatches
Description copied from interface:IWatchManager
Returns a watch report.- Specified by:
getWatches
in interfaceIWatchManager
- Returns:
- watch report
- See Also:
-
getWatchesByPath
Description copied from interface:IWatchManager
Returns a watch report by path.- Specified by:
getWatchesByPath
in interfaceIWatchManager
- Returns:
- watch report
- See Also:
-
getWatchesSummary
Description copied from interface:IWatchManager
Returns a watch summary.- Specified by:
getWatchesSummary
in interfaceIWatchManager
- Returns:
- watch summary
- See Also:
-
shutdown
public void shutdown()Description copied from interface:IWatchManager
Clean up the watch manager.- Specified by:
shutdown
in interfaceIWatchManager
-
getRecursiveWatchQty
public int getRecursiveWatchQty()Description copied from interface:IWatchManager
Return the current number of recursive watchers- Specified by:
getRecursiveWatchQty
in interfaceIWatchManager
- Returns:
- qty
-