public class WatchManagerOptimized extends Object implements IWatchManager, IDeadWatcherListener
Constructor and Description |
---|
WatchManagerOptimized() |
Modifier and Type | Method and Description |
---|---|
boolean |
addWatch(String path,
Watcher watcher)
Add watch to specific path.
|
boolean |
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.
|
void |
dumpWatches(PrintWriter pwriter,
boolean byPath)
String representation of watches.
|
Map<Watcher,Set<String>> |
getWatcher2PathesMap()
May cause OOM if there are lots of watches, might better to forbid
it in this class.
|
WatchesReport |
getWatches()
Returns a watch report.
|
WatchesPathReport |
getWatchesByPath()
Iterate through ConcurrentHashMap is 'safe', it will reflect the state
of the map at the time iteration began, may miss update while iterating,
given this is used in the commands to get a general idea of the watches
state, we don't care about missing some update.
|
WatchesSummary |
getWatchesSummary()
Returns a watch summary.
|
void |
processDeadWatchers(Set<Integer> deadWatchers)
Entry for WatcherCleaner to remove dead watchers
|
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.
|
String |
toString() |
WatcherOrBitSet |
triggerWatch(String path,
Watcher.Event.EventType type)
Distribute the watch event for the given path.
|
WatcherOrBitSet |
triggerWatch(String path,
Watcher.Event.EventType type,
WatcherOrBitSet suppress)
Distribute the watch event for the given path, but ignore those
suppressed ones.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addWatch, getRecursiveWatchQty
public boolean addWatch(String path, Watcher watcher)
IWatchManager
addWatch
in interface IWatchManager
path
- znode pathwatcher
- watcher object referencepublic boolean containsWatcher(String path, Watcher watcher)
containsWatcher
in interface IWatchManager
path
- znode pathwatcher
- watcher object referencepublic boolean removeWatcher(String path, Watcher watcher)
IWatchManager
removeWatcher
in interface IWatchManager
path
- znode pathwatcher
- watcher object referencepublic void removeWatcher(Watcher watcher)
IWatchManager
removeWatcher
in interface IWatchManager
watcher
- watcher object referencepublic void processDeadWatchers(Set<Integer> deadWatchers)
processDeadWatchers
in interface IDeadWatcherListener
deadWatchers
- the watchers need to be removedpublic WatcherOrBitSet triggerWatch(String path, Watcher.Event.EventType type)
IWatchManager
triggerWatch
in interface IWatchManager
path
- znode pathtype
- the watch event typepublic WatcherOrBitSet triggerWatch(String path, Watcher.Event.EventType type, WatcherOrBitSet suppress)
IWatchManager
triggerWatch
in interface IWatchManager
path
- znode pathtype
- the watch event typesuppress
- the suppressed watcher setpublic int size()
IWatchManager
size
in interface IWatchManager
public void shutdown()
IWatchManager
shutdown
in interface IWatchManager
public WatchesSummary getWatchesSummary()
IWatchManager
getWatchesSummary
in interface IWatchManager
WatchesSummary
public WatchesReport getWatches()
IWatchManager
getWatches
in interface IWatchManager
WatchesReport
public WatchesPathReport getWatchesByPath()
getWatchesByPath
in interface IWatchManager
WatchesPathReport
public Map<Watcher,Set<String>> getWatcher2PathesMap()
public void dumpWatches(PrintWriter pwriter, boolean byPath)
IWatchManager
dumpWatches
in interface IWatchManager
pwriter
- the writer to dump the watchesbyPath
- iff true output watches by paths, otw output
watches by connectionCopyright © 2008–2021 The Apache Software Foundation. All rights reserved.