@Test public void testStart() throws Exception { JMXConnector connector = JMXConnectorFactory.connect( JMXListener.buildJMXServiceURL(connectorPort,connectorPort)); MBeanServerConnection mb = connector.getMBeanServerConnection(); String domain = mb.getDefaultDomain(); Assert.assertTrue("default domain is not correct", !domain.isEmpty()); connector.close(); }
@Override public void start(CoprocessorEnvironment env) throws IOException { int rmiRegistryPort = -1; int rmiConnectorPort = -1; Configuration conf = env.getConfiguration(); if (env instanceof MasterCoprocessorEnvironment) { LOG.error("JMXListener should not be loaded in Master Environment!"); } else if (env instanceof RegionServerCoprocessorEnvironment) { rmiRegistryPort = conf.getInt("regionserver" + RMI_REGISTRY_PORT_CONF_KEY, defRMIRegistryPort); 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!"); } synchronized(JMXListener.class) { if (jmxCS != null) { LOG.info("JMXListener has been started at Registry port " + rmiRegistryPort); } else { startConnectorServer(rmiRegistryPort, rmiConnectorPort); } } }
JMXListener implements Coprocessor { @Override public void start(CoprocessorEnvironment env) throws IOException { int rmiRegistryPort = -1; int rmiConnectorPort = -1; Configuration conf = env.getConfiguration(); if (env instanceof MasterCoprocessorEnvironment) { LOG.error("JMXListener should not be loaded in Master Environment!"); } else if (env instanceof RegionServerCoprocessorEnvironment) { rmiRegistryPort = conf.getInt("regionserver" + RMI_REGISTRY_PORT_CONF_KEY, defRMIRegistryPort); 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!"); } synchronized(JMXListener.class) { if (jmxCS != null) { LOG.info("JMXListener has been started at Registry port " + rmiRegistryPort); } else { startConnectorServer(rmiRegistryPort, rmiConnectorPort); } } } }
JMXListener implements Coprocessor { @Override public void start(CoprocessorEnvironment env) throws IOException { int rmiRegistryPort = -1; int rmiConnectorPort = -1; Configuration conf = env.getConfiguration(); if (env instanceof MasterCoprocessorEnvironment) { LOG.error("JMXListener should not be loaded in Master Environment!"); } else if (env instanceof RegionServerCoprocessorEnvironment) { rmiRegistryPort = conf.getInt("regionserver" + RMI_REGISTRY_PORT_CONF_KEY, defRMIRegistryPort); 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!"); } synchronized(JMXListener.class) { if (jmxCS != null) { LOG.info("JMXListener has been started at Registry port " + rmiRegistryPort); } else { startConnectorServer(rmiRegistryPort, rmiConnectorPort); } } }  }
JMXListener implements Coprocessor { @Override public void start(CoprocessorEnvironment env) throws IOException { int rmiRegistryPort = -1; int rmiConnectorPort = -1; Configuration conf = env.getConfiguration(); if (env instanceof MasterCoprocessorEnvironment) { LOG.error("JMXListener should not be loaded in Master Environment!"); } else if (env instanceof RegionServerCoprocessorEnvironment) { rmiRegistryPort = conf.getInt("regionserver" + RMI_REGISTRY_PORT_CONF_KEY, defRMIRegistryPort); 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!"); } synchronized(JMXListener.class) { if (jmxCS != null) { LOG.info("JMXListener has been started at Registry port " + rmiRegistryPort); } else { startConnectorServer(rmiRegistryPort, rmiConnectorPort); } } }  static JMXServiceURL buildJMXServiceURL(int rmiRegistryPort,
      int rmiConnectorPort); void startConnectorServer(int rmiRegistryPort, int rmiConnectorPort); void stopConnectorServer(); @Override void start(CoprocessorEnvironment env); @Override void stop(CoprocessorEnvironment env); }
JMXListener implements Coprocessor { @Override public void start(CoprocessorEnvironment env) throws IOException { int rmiRegistryPort = -1; int rmiConnectorPort = -1; Configuration conf = env.getConfiguration(); if (env instanceof MasterCoprocessorEnvironment) { LOG.error("JMXListener should not be loaded in Master Environment!"); } else if (env instanceof RegionServerCoprocessorEnvironment) { rmiRegistryPort = conf.getInt("regionserver" + RMI_REGISTRY_PORT_CONF_KEY, defRMIRegistryPort); 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!"); } synchronized(JMXListener.class) { if (jmxCS != null) { LOG.info("JMXListener has been started at Registry port " + rmiRegistryPort); } else { startConnectorServer(rmiRegistryPort, rmiConnectorPort); } } }  static JMXServiceURL buildJMXServiceURL(int rmiRegistryPort,
      int rmiConnectorPort); void startConnectorServer(int rmiRegistryPort, int rmiConnectorPort); void stopConnectorServer(); @Override void start(CoprocessorEnvironment env); @Override void stop(CoprocessorEnvironment env); static final Log LOG; static final String RMI_REGISTRY_PORT_CONF_KEY; static final String RMI_CONNECTOR_PORT_CONF_KEY; static int defRMIRegistryPort; }