@Override public void run() { try { serverToStart.start(); } catch (IOException ex) { throw new JmxException("Could not start JMX connector server after delay", ex); } } };
@Override public void run() { try { serverToStart.start(); } catch (IOException ex) { throw new JmxException("Could not start JMX connector server after delay", ex); } } };
/** * Starts a JMX connector that allows (un)registering MBeans with the MBean server and RMI invocations. * * @param port jmx port to use * @throws IOException */ private void startJmxService(int port) throws IOException { String serviceUrl = "service:jmx:rmi://localhost:" + port + "/jndi/rmi://localhost:" + port + "/jmxrmi"; JMXServiceURL url; try { url = new JMXServiceURL(serviceUrl); } catch (MalformedURLException e) { throw new IllegalArgumentException("Malformed service url created " + serviceUrl, e); } connector = JMXConnectorServerFactory.newJMXConnectorServer(url, null, ManagementFactory.getPlatformMBeanServer()); connector.start(); }
@Override public void run() { // ensure we use MDC logging with the broker name, so people can see the logs if MDC was in use if (brokerName != null) { MDC.put("activemq.broker", brokerName); } try { JMXConnectorServer server = connectorServer; if (started.get() && server != null) { LOG.debug("Starting JMXConnectorServer..."); try { // need to remove MDC as we must not inherit MDC in child threads causing leaks MDC.remove("activemq.broker"); server.start(); } finally { if (brokerName != null) { MDC.put("activemq.broker", brokerName); } connectorStarted.countDown(); } LOG.info("JMX consoles can connect to {}", server.getAddress()); } } catch (IOException e) { LOG.warn("Failed to start JMX connector {}. Will restart management to re-create JMX connector, trying to remedy this issue.", e.getMessage()); LOG.debug("Reason for failed JMX connector start", e); } finally { MDC.remove("activemq.broker"); } } };
this.connectorServer.start();
JMX_CS.start();
this.connectorServer.start();
cs.start(); await() .until(() -> cs.isActive());
public static void setUp() throws IOException { MBeanServer mbs = MBeanRegistry.getInstance().getPlatformMBeanServer(); JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://127.0.0.1"); cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs); cs.start(); JMXServiceURL addr = cs.getAddress(); cc = JMXConnectorFactory.connect(addr); }
protected void assertJmxEquals(String attributeName, Object attributeValue) throws Exception { JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(new JMXServiceURL("service:jmx:rmi://"), null, ManagementFactory.getPlatformMBeanServer()); cs.start(); JMXConnector cc = null; try { cc = JMXConnectorFactory.connect(cs.getAddress()); MBeanServerConnection mbsc = cc.getMBeanServerConnection(); ObjectName objectName = JmxUtils.createObjectName(JmxUtils.getPackageName(failureDetector.getClass()), failureDetector.getClass() .getSimpleName()); Object availableNodes = mbsc.getAttribute(objectName, attributeName); assertEquals(attributeValue, availableNodes); } finally { if(cc != null) cc.close(); cs.stop(); } }
this.rmiConnector.start(); } catch (VirtualMachineError err) { SystemFailure.initiateFailure(err);
@Override public void onSetUp() throws Exception { runTests = false; Assume.group(TestGroup.JMXMP); runTests = true; super.onSetUp(); this.connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(getServiceUrl(), null, getServer()); try { this.connectorServer.start(); } catch (BindException ex) { System.out.println("Skipping remote JMX tests because binding to local port [" + SERVICE_PORT + "] failed: " + ex.getMessage()); runTests = false; } }
registerFileUploaderMBean(); jmxConnectorServer.start(); if (logger.isDebugEnabled()) { logger.debug("Finished starting jmx manager agent.");
@Test public void testTestValidConnection() throws Exception { Assume.group(TestGroup.JMXMP); JMXConnectorServer connectorServer = getConnectorServer(); connectorServer.start(); try { MBeanServerConnectionFactoryBean bean = new MBeanServerConnectionFactoryBean(); bean.setServiceUrl(serviceUrl); bean.afterPropertiesSet(); try { MBeanServerConnection connection = bean.getObject(); assertNotNull("Connection should not be null", connection); // perform simple MBean count test assertEquals("MBean count should be the same", getServer().getMBeanCount(), connection.getMBeanCount()); } finally { bean.destroy(); } } finally { connectorServer.stop(); } }
@Test public void testTestWithLazyConnection() throws Exception { Assume.group(TestGroup.JMXMP); MBeanServerConnectionFactoryBean bean = new MBeanServerConnectionFactoryBean(); bean.setServiceUrl(serviceUrl); bean.setConnectOnStartup(false); bean.afterPropertiesSet(); MBeanServerConnection connection = bean.getObject(); assertTrue(AopUtils.isAopProxy(connection)); JMXConnectorServer connector = null; try { connector = getConnectorServer(); connector.start(); assertEquals("Incorrect MBean count", getServer().getMBeanCount(), connection.getMBeanCount()); } finally { bean.destroy(); if (connector != null) { connector.stop(); } } }
/** * Programmatically starts a JMX server. * * @param port * port server should listen on. * @param allowConnections * allows restriction of connections to those from "localhost" * only. */ public static void startLocalJMXServer(final int port, final AllowConnections allowConnections) throws IOException, MalformedURLException, RemoteException { final RMISocketFactory serverSocketFactory = allowConnections == AllowConnections.ALL ? RMISocketFactory.getDefaultSocketFactory() : new LocalhostRMIServerSocketFactory(); LocateRegistry.createRegistry(port, RMISocketFactory.getDefaultSocketFactory(), serverSocketFactory); final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); final JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + port + "/jmxrmi"); final JMXConnectorServer rmiServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs); rmiServer.start(); }
JMXServiceURL url = new JMXServiceURL(serverURL); connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbserver); connectorServer.start(); shutdownHookThread = new Thread() { @Override
/** * Start monitoring. * * @throws IOException exception */ public void start() throws IOException { if (!isRunning()) { jmxServer.start(); DataCollectManager.getInstance().init(agentConfig); DataCollectManager.getInstance().start(); isRunning = true; } }
public void run() { try { connectorServer.start(); } catch (IOException ex) { LOG.log(Level.SEVERE, "START_CONNECTOR_FAILURE_MSG", new Object[]{ex}); } } };