@Override
  public void start(CoprocessorEnvironment env) throws IOException {
    int rmiRegistryPort = -1;
    int rmiConnectorPort = -1;
    Configuration conf = env.getConfiguration();

    if (env instanceof MasterCoprocessorEnvironment) {
      // running on Master
      rmiRegistryPort =
        conf.getInt("master" + RMI_REGISTRY_PORT_CONF_KEY, defMasterRMIRegistryPort);
      rmiConnectorPort = conf.getInt("master" + RMI_CONNECTOR_PORT_CONF_KEY, rmiRegistryPort);
      LOG.info("Master rmiRegistryPort:" + rmiRegistryPort + ",Master rmiConnectorPort:"
        + rmiConnectorPort);
    } else if (env instanceof RegionServerCoprocessorEnvironment) {
      // running on RegionServer
      rmiRegistryPort =
        conf.getInt("regionserver" + RMI_REGISTRY_PORT_CONF_KEY, defRegionserverRMIRegistryPort);
      rmiConnectorPort = conf.getInt("regionserver" + RMI_CONNECTOR_PORT_CONF_KEY, rmiRegistryPort);
      LOG.info("RegionServer rmiRegistryPort:" + rmiRegistryPort + ",RegionServer rmiConnectorPort:"
        + rmiConnectorPort);

    } else if (env instanceof RegionCoprocessorEnvironment) {
      LOG.error("JMXListener should not be loaded in Region Environment!");
      return;
    }

    synchronized (JMXListener.class) {
      if (JMX_CS != null) {
        LOG.info("JMXListener has been started at Registry port " + rmiRegistryPort);
      } else {
        startConnectorServer(rmiRegistryPort, rmiConnectorPort);
      }
    }
  }
workaround for HBASE-11146 master and regionserver are in 1 JVM in standalone mode only 1 JMX
instance is allowed, otherwise there is port conflict even if we only load regionserver
coprocessor on master
hbase-server/src/main/java/org/apache/hadoop/hbase/JMXListener.java