Class PathChildrenAnnouncer
java.lang.Object
org.apache.druid.curator.announcement.PathChildrenAnnouncer
- All Implemented Interfaces:
ServiceAnnouncer
The
PathChildrenAnnouncer class manages the announcement of a node, and watches all child
and sibling nodes under the specified path in a ZooKeeper ensemble. It monitors these nodes
to ensure their existence and manage their lifecycle collectively.
This class uses Apache Curator's PathChildrenCache recipe under the hood to track all znodes
under the specified node's parent. See NodeAnnouncer for an announcer that
uses the NodeCache recipe instead.
-
Constructor Summary
ConstructorsConstructorDescriptionPathChildrenAnnouncer(org.apache.curator.framework.CuratorFramework curator, ExecutorService exec) -
Method Summary
Modifier and TypeMethodDescriptionvoidOverload ofannounce(String, byte[], boolean), but removes parent node of path after announcement.voidAnnounces the provided bytes at the given path.voidstart()voidstop()voidunannounce(String path) Unannounces an announcement created at path.void
-
Constructor Details
-
PathChildrenAnnouncer
public PathChildrenAnnouncer(org.apache.curator.framework.CuratorFramework curator, ExecutorService exec)
-
-
Method Details
-
start
public void start()- Specified by:
startin interfaceServiceAnnouncer
-
stop
public void stop()- Specified by:
stopin interfaceServiceAnnouncer
-
announce
Overload ofannounce(String, byte[], boolean), but removes parent node of path after announcement.- Specified by:
announcein interfaceServiceAnnouncer
-
announce
Announces the provided bytes at the given path.Announcement using
PathChildrenAnnouncerwill create an ephemeral znode at the specified path, and uses its parent path to watch all the siblings and children znodes of your specified path. The watched nodes will always exist until it is unannounced, or untilstop()is called.- Specified by:
announcein interfaceServiceAnnouncer- Parameters:
path- The path to announce atbytes- The payload to announceremoveParentIfCreated- remove parent of "path" if we had created that parent during announcement
-
update
- Specified by:
updatein interfaceServiceAnnouncer
-
unannounce
Unannounces an announcement created at path. Note that if all announcements get removed, the Announcer will continue to have ZK watches on paths because clearing them out is a source of ugly race conditions. If you need to completely clear all the state of what is being watched and announced, stop() the Announcer.- Specified by:
unannouncein interfaceServiceAnnouncer- Parameters:
path- the path to unannounce
-