In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
1.watcher mode 1 (listens for changes to the current node)
String address = "mini1:2181,mini2:2181,mini3:2181"; RetryPolicy retryPolicy = new ExponentialBackoffRetry (1000, 10); CuratorFramework client = CuratorFrameworkFactory.newClient (address, new ExponentialBackoffRetry (1000, 3)); client.start () / / create node watcher listening final NodeCache cache = new NodeCache (client, "/ super", false); cache.start (true) Cache.getListenable () .addListener (new NodeCacheListener () {public void nodeChanged () throws Exception {System.out.println (cache.getCurrentData () .getPath ()); System.out.println (cache.getCurrentData () .getStat () })
2.watcher mode 2 (listening for changes in the child nodes of the current node)
String address = "mini1:2181,mini2:2181,mini3:2181"; RetryPolicy retryPolicy = new ExponentialBackoffRetry (1000, 10); CuratorFramework client = CuratorFrameworkFactory.newClient (address, new ExponentialBackoffRetry (1000, 3)); client.start () / / create child node watcher listening PathChildrenCache cache = new PathChildrenCache (client, "/ super", true); cache.start (StartMode.POST_INITIALIZED_EVENT) Cache.getListenable () .addListener (new PathChildrenCacheListener () {public void childEvent (CuratorFramework cf, PathChildrenCacheEvent event) throws Exception {System.out.println (event.getType ());}}); Thread.sleep (Long.MAX_VALUE)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.