Class NodeAnnouncer
java.lang.Object
org.apache.druid.curator.announcement.NodeAnnouncer
- All Implemented Interfaces:
ServiceAnnouncer
The
NodeAnnouncer class is responsible for announcing a single node
in a ZooKeeper ensemble. It creates an ephemeral node at a specified path
and monitors its existence to ensure that it remains active until it is
explicitly unannounced or the object is closed.
This class uses Apache Curator's NodeCache recipe under the hood to track a single
node, along with all of its parent's status. See PathChildrenAnnouncer for an announcer that
uses the PathChildrenCache recipe instead.
-
Constructor Summary
ConstructorsConstructorDescriptionNodeAnnouncer(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
-
NodeAnnouncer
-
-
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
NodeAnnouncerwill create an ephemeral znode at the specified path, and listens for changes on your znode. Your znode will 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
-