如果在使用策展人的领导者选举时,takeLeadership()永远不会返回会发生什么

时间:2015-10-23 02:03:52

标签: apache-zookeeper distributed-system apache-curator

LeaderSelectorListener listener = new LeaderSelectorListenerAdapter()
    {
        public void takeLeadership(CuratorFramework client) throws Exception
        {
            while (true) {
               try {
                 // ... business logic
               } catch (Exception e) {  // catch any exeption here
                 // do nothing
               }
             }
        }
    }
LeaderSelector selector = new LeaderSelector(client, path, listener);
selector.autoRequeue();
selector.start();

如代码所示,我捕获了业务代码中的任何异常,因此即使zookeeper断开连接,业务代码仍将执行,对吧?

0 个答案:

没有答案