簡體   English   中英

嵌入式ZooKeeper服務器關閉期間的警告

[英]Warning during embedded ZooKeeper Server shutdown

我只是使用org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ServerConfig)方法啟動了zookeeper服務器(3.4.6),然后嘗試將其關閉。 在關機期間,我得到這個:

11:43:11,176 WARN {main} [org.apache.zookeeper.jmx.MBeanRegistry] Failed to unregister MBean InMemoryDataTree
11:43:11,176 WARN {main} [org.apache.zookeeper.jmx.MBeanRegistry] Error during unregister
javax.management.InstanceNotFoundException: org.apache.ZooKeeperService:name0=StandaloneServer_port-1,name1=InMemoryDataTree
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1095)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.exclusiveUnregisterMBean(DefaultMBeanServerInterceptor.java:427)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.unregisterMBean(DefaultMBeanServerInterceptor.java:415)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.unregisterMBean(JmxMBeanServer.java:546)
    at org.apache.zookeeper.jmx.MBeanRegistry.unregister(MBeanRegistry.java:115)
    at org.apache.zookeeper.jmx.MBeanRegistry.unregister(MBeanRegistry.java:132)
    at org.apache.zookeeper.server.ZooKeeperServer.unregisterJMX(ZooKeeperServer.java:465)
    at org.apache.zookeeper.server.ZooKeeperServer.shutdown(ZooKeeperServer.java:458)
    at org.apache.zookeeper.server.NIOServerCnxnFactory.shutdown(NIOServerCnxnFactory.java:271)
    at org.apache.zookeeper.server.ZooKeeperServerMain.shutdown(ZooKeeperServerMain.java:132)
...

不幸的是,我不知道錯誤“ 注銷MBean InMemoryDataTree失敗”的含義。 除了某些項目構建的日志外,我沒有在搜索引擎中找到任何東西。 我可以閱讀代碼,但是顯然要花很多時間才能理解。

我是否必須在啟動過程中進行某些更改以消除此問題,或者這完全正常嗎?

日志表明這是一個警告,從源頭和注釋中查看,基本上可以忽略。 以我的經驗,我不會回想起那些特殊的消息,而是一直遇到運行時異常/錯誤,這些異常/錯誤使后續的單元測試無法運行,並導致gradle構建退出測試任務而沒有生成報告。

我不知道您如何嘗試關閉ZookeeperServerMain,但是我的解決方法是擴展ZookeeperServerMain,以便可以訪問其受保護的關閉方法。

public class MyZookeeperServerMain extends ZookeeperServerMain{
    ...
    public void openZoo() {
    /**/
    Properties startupProperties = createProperties(DEFAULT_LOG_DIR, 2181);

    QuorumPeerConfig quorumConfiguration = new QuorumPeerConfig();
    try {
        quorumConfiguration.parseProperties(startupProperties);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    zooKeeperServer = new MyZookeeperServerMain();
    final ServerConfig configuration = new ServerConfig();
    configuration.readFrom(quorumConfiguration);

    zooEntrance = new Thread() {
        public void run() {
            try {
                zooKeeperServer.runFromConfig(configuration);
            }
            catch (IOException e) {
                LOG.error("ZooKeeper Failed", e);
            }
            catch(Exception ie)
            {
                LOG.debug("shutting down zookeeper", ie);
            }
            catch(Error e)
            {
                System.out.println("error stopping zooKeeper: " + e);
            }
        }
    };
    zooEntrance.start();
  }

  public void closeZoo() {
    zooKeeperServer.shutdown();
  }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM