0

I simply start up a zookeeper server (3.4.6) with using the org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ServerConfig) method, then I try to shut it down. During shutdown I get this:

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)
...

I have unfortunately no idea what the error Failed to unregister MBean InMemoryDataTree means. I did not find anything with search engines apart from logs from some project builds. I could read the code, but it would take obviously a lot of time to understand that.

Do I have to change something in my startup process to get rid of this, or is this completely normal?

Gábor Lipták
  • 9,646
  • 2
  • 59
  • 113

1 Answers1

1

The logs indicate that it is a warning, and from looking into the source and comments, can largely be ignored. In my experience I do not recall seeing those particular messages, but kept running into run time exceptions/errors that kept subsequent unit tests from running and caused my gradle build to exit the test task without generating the report.

I have no idea how you were trying to shut down ZookeeperServerMain, but my work around was to extend ZookeeperServerMain so I could access its protected shutdown method.

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();
  }
}
pilotg2
  • 144
  • 5