Hi Stevo Slavic, Yes, its very nice observation. I think this has to be corrected.
Could you raise a JIRA ticket and add these details in that for further discussion. Regards, Rakesh -----Original Message----- From: Stevo Slavić [mailto:[email protected]] Sent: 02 September 2014 03:08 To: [email protected] Subject: ServerCnxnFactory startup order and registering ZooKeeperServer JMX MBean Hello ZooKeeper community, When running ZK (3.4.6) related tests in parallel in same JVM, multiple servers although assigned a different local port clash when trying to register JMX MBean for server (see [1]) - the two get assigned same MBean name. Registering JMX MBean for ZooKeeperServer it seems cannot be disabled, not even for tests. Looking into ZooKeeperServerBean constructor, and ZooKeeperServer.getClientPort one can see that the MBean name will clash only when server connection factory is not bound to server, before startup method of server connection factory gets called. This is exactly what happens in startup methods of both NIOServerCnxnFactory and NettyServerCnxnFactory, because of IMO wrong order that the methods are being called. Instead of current [2] IMO it should be [3] or at least [4]. Is my understanding wrong? If not, is this a (known) bug? Kind regards, Stevo Slavic [1] example build output fragment with failing ZK server JMX MBean registration javax.management.InstanceAlreadyExistsException: org.apache.ZooKeeperService:name0=StandaloneServer_port-1 at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324) at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522) at org.apache.zookeeper.jmx.MBeanRegistry.register(MBeanRegistry.java:96) at org.apache.zookeeper.server.ZooKeeperServer.registerJMX(ZooKeeperServer.java:377) at org.apache.zookeeper.server.ZooKeeperServer.startup(ZooKeeperServer.java:410) at org.apache.zookeeper.server.NIOServerCnxnFactory.startup(NIOServerCnxnFactory.java:123) [2] @Override public void startup(ZooKeeperServer zks) throws IOException, InterruptedException { start(); zks.startdata(); zks.startup(); setZooKeeperServer(zks); } [3] @Override public void startup(ZooKeeperServer zks) throws IOException, InterruptedException { start(); setZooKeeperServer(zks); zks.startdata(); zks.startup(); } [4] @Override public void startup(ZooKeeperServer zks) throws IOException, InterruptedException { start(); zks.startdata(); setZooKeeperServer(zks); zks.startup(); }
