Class WatchManager
- java.lang.Object
-
- org.apache.zookeeper.server.watch.WatchManager
-
- All Implemented Interfaces:
IWatchManager
public class WatchManager extends Object implements 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 Constructor Description WatchManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddWatch(String path, Watcher watcher)Add watch to specific path.booleanaddWatch(String path, Watcher watcher, WatcherMode watcherMode)Add watch to specific path.booleancontainsWatcher(String path, Watcher watcher)Checks the specified watcher exists for the given path.booleancontainsWatcher(String path, Watcher watcher, WatcherMode watcherMode)Checks the specified watcher exists for the given path and mode.voiddumpWatches(PrintWriter pwriter, boolean byPath)String representation of watches.WatchesReportgetWatches()Returns a watch report.WatchesPathReportgetWatchesByPath()Returns a watch report by path.WatchesSummarygetWatchesSummary()Returns a watch summary.booleanremoveWatcher(String path, Watcher watcher)Removes the specified watcher for the given path.booleanremoveWatcher(String path, Watcher watcher, WatcherMode watcherMode)Removes the specified watcher for the given path and mode.voidremoveWatcher(Watcher watcher)The entry to remove the watcher when the cnxn is closed.voidshutdown()Clean up the watch manager.intsize()Get the size of watchers.StringtoString()WatcherOrBitSettriggerWatch(String path, Watcher.Event.EventType type, long zxid, List<ACL> acl)Distribute the watch event for the given path.WatcherOrBitSettriggerWatch(String path, Watcher.Event.EventType type, long zxid, List<ACL> acl, WatcherOrBitSet supress)Distribute the watch event for the given path, but ignore those suppressed ones.
-
-
-
Method Detail
-
size
public int size()
Description copied from interface:IWatchManagerGet the size of watchers.- Specified by:
sizein interfaceIWatchManager- Returns:
- the watchers number managed in this class.
-
addWatch
public boolean addWatch(String path, Watcher watcher)
Description copied from interface:IWatchManagerAdd watch to specific path.- Specified by:
addWatchin interfaceIWatchManager- Parameters:
path- znode pathwatcher- watcher object reference- Returns:
- true if the watcher added is not already present
-
addWatch
public boolean addWatch(String path, Watcher watcher, WatcherMode watcherMode)
Description copied from interface:IWatchManagerAdd watch to specific path.- Specified by:
addWatchin interfaceIWatchManager- Parameters:
path- znode pathwatcher- watcher object referencewatcherMode- the watcher mode to use- Returns:
- true if the watcher added is not already present
-
removeWatcher
public void removeWatcher(Watcher watcher)
Description copied from interface:IWatchManagerThe entry to remove the watcher when the cnxn is closed.- Specified by:
removeWatcherin interfaceIWatchManager- Parameters:
watcher- watcher object reference
-
triggerWatch
public WatcherOrBitSet triggerWatch(String path, Watcher.Event.EventType type, long zxid, List<ACL> acl)
Description copied from interface:IWatchManagerDistribute the watch event for the given path.- Specified by:
triggerWatchin interfaceIWatchManager- Parameters:
path- znode pathtype- the watch event typezxid- the zxid for the corresponding change that triggered this eventacl- ACL of the znode in path- Returns:
- the watchers have been notified
-
triggerWatch
public WatcherOrBitSet triggerWatch(String path, Watcher.Event.EventType type, long zxid, List<ACL> acl, WatcherOrBitSet supress)
Description copied from interface:IWatchManagerDistribute the watch event for the given path, but ignore those suppressed ones.- Specified by:
triggerWatchin interfaceIWatchManager- Parameters:
path- znode pathtype- the watch event typezxid- the zxid for the corresponding change that triggered this eventsupress- the suppressed watcher set- Returns:
- the watchers have been notified
-
dumpWatches
public void dumpWatches(PrintWriter pwriter, boolean byPath)
Description copied from interface:IWatchManagerString representation of watches. Warning, may be large!- Specified by:
dumpWatchesin interfaceIWatchManager- Parameters:
pwriter- the writer to dump the watchesbyPath- iff true output watches by paths, otw output watches by connection
-
containsWatcher
public boolean containsWatcher(String path, Watcher watcher)
Description copied from interface:IWatchManagerChecks the specified watcher exists for the given path.- Specified by:
containsWatcherin interfaceIWatchManager- Parameters:
path- znode pathwatcher- watcher object reference- Returns:
- true if the watcher exists, false otherwise
-
containsWatcher
public boolean containsWatcher(String path, Watcher watcher, WatcherMode watcherMode)
Description copied from interface:IWatchManagerChecks the specified watcher exists for the given path and mode.- Specified by:
containsWatcherin interfaceIWatchManager- Parameters:
path- znode pathwatcher- watcher object referencewatcherMode- watcher mode, null for any mode- Returns:
- true if the watcher exists, false otherwise
-
removeWatcher
public boolean removeWatcher(String path, Watcher watcher, WatcherMode watcherMode)
Description copied from interface:IWatchManagerRemoves the specified watcher for the given path and mode.- Specified by:
removeWatcherin interfaceIWatchManager- Parameters:
path- znode pathwatcher- watcher object referencewatcherMode- watcher mode, null to remove all modes- Returns:
- true if the watcher successfully removed, false otherwise
-
removeWatcher
public boolean removeWatcher(String path, Watcher watcher)
Description copied from interface:IWatchManagerRemoves the specified watcher for the given path.- Specified by:
removeWatcherin interfaceIWatchManager- Parameters:
path- znode pathwatcher- watcher object reference- Returns:
- true if the watcher successfully removed, false otherwise
-
getWatches
public WatchesReport getWatches()
Description copied from interface:IWatchManagerReturns a watch report.- Specified by:
getWatchesin interfaceIWatchManager- Returns:
- watch report
- See Also:
WatchesReport
-
getWatchesByPath
public WatchesPathReport getWatchesByPath()
Description copied from interface:IWatchManagerReturns a watch report by path.- Specified by:
getWatchesByPathin interfaceIWatchManager- Returns:
- watch report
- See Also:
WatchesPathReport
-
getWatchesSummary
public WatchesSummary getWatchesSummary()
Description copied from interface:IWatchManagerReturns a watch summary.- Specified by:
getWatchesSummaryin interfaceIWatchManager- Returns:
- watch summary
- See Also:
WatchesSummary
-
shutdown
public void shutdown()
Description copied from interface:IWatchManagerClean up the watch manager.- Specified by:
shutdownin interfaceIWatchManager
-
-