/** * Returns the address (URL) on which the RMI connector server runs or <code>null</code> if the * RMI connector server has not been started. This method is used primarily for testing purposes. * * @see JMXConnectorServer#getAddress() */ public JMXServiceURL getRMIAddress() { if (this.rmiConnector != null) { return this.rmiConnector.getAddress(); } else { return null; } }
@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"); } } };
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(); } }
/** * Returns the address (URL) on which the RMI connector server runs * or <code>null</code> if the RMI connector server has not been * started. This method is used primarily for testing purposes. * * @see JMXConnectorServer#getAddress() */ public JMXServiceURL getRMIAddress() { if (this.rmiConnector != null) { return this.rmiConnector.getAddress(); } else { return null; } }
/** * Returns the address (URL) on which the RMI connector server runs * or <code>null</code> if the RMI connector server has not been * started. This method is used primarily for testing purposes. * * @see JMXConnectorServer#getAddress() */ public JMXServiceURL getRMIAddress() { if (this.rmiConnector != null) { return this.rmiConnector.getAddress(); } else { return null; } }
/** * @param protocolName a name of protocol * @return the JMX service URL for the given protocol or null if the protocol doesn't exist */ public static JMXServiceURL getJMXServiceURL(final String protocolName) { JMXConnectorServer jmxConnectorServer = null; if(jmxConnectorServers == null) { return null; } jmxConnectorServer = jmxConnectorServers.get(protocolName); if (jmxConnectorServer == null) { return null; } return jmxConnectorServer.getAddress(); }
@Override public String getJmxConnectorServiceUrl() { // Return the address of the JMX Connector return this.connectorServer.getAddress().toString(); }
JMXConnectorServer connServer = null; 735 try { 736 connServer = 737 JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs); 738 connServer.start(); 739 } catch (IOException e) { 740 if (connServer == null) { 741 throw new AgentConfigurationError(CONNECTOR_SERVER_IO_ERROR, 742 e, url.toString()); 743 } else { 744 throw new AgentConfigurationError(CONNECTOR_SERVER_IO_ERROR, 745 e, connServer.getAddress().toString()); 746 } 747 }
@Override public void run() { try { JMXConnectorServer server = connectorServer; if (started.get() && server != null) { LOG.debug("Starting JMXConnectorServer..."); connectorStarting.set(true); try { server.start(); } finally { connectorStarting.set(false); } LOG.info("JMX consoles can connect to " + server.getAddress()); } } catch (IOException e) { LOG.warn("Failed to start jmx connector: " + e.getMessage()); LOG.debug("Reason for failed jms connector start", e); } } };
@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"); } } };
@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"); } } };
@Override public void registerMBean(Object mbean, ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { // Determine if running in own process if (this.connectorServer != null) { // Register the MBean locally this.connectorServer.getMBeanServer().registerMBean(mbean, name); // Notify managing parent process of the MBean JMXServiceURL serviceUrl = this.connectorServer.getAddress(); try { this.toParentPipe .writeObject(new MBeanRegistrationNotification( serviceUrl, name)); this.toParentPipe.flush(); } catch (IOException ex) { // Must be able to register with managing parent process throw new MBeanRegistrationException(ex); } } else { // Running local process, so register locally this.mbeanServer.registerMBean(mbean, name); // Keep track of names for unregistering this.registeredMbeanNames.add(name); } }
public void doStart() throws Exception { jmxServiceURL = new JMXServiceURL(protocol, host, port, urlPath); Map env = new HashMap(); if (applicationConfigName != null) { authenticator = new Authenticator(applicationConfigName, classLoader); env.put(JMXConnectorServer.AUTHENTICATOR, authenticator); } else { log.warn("Starting unauthenticating JMXConnector for " + jmxServiceURL); } server = JMXConnectorServerFactory.newJMXConnectorServer(jmxServiceURL, env, mbeanServer); NotificationFilterSupport filter = new NotificationFilterSupport(); filter.enableType(JMXConnectionNotification.OPENED); filter.enableType(JMXConnectionNotification.CLOSED); filter.enableType(JMXConnectionNotification.FAILED); server.addNotificationListener(authenticator, filter, null); server.start(); log.debug("Started JMXConnector " + server.getAddress()); }
/** * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart() */ @Override public void doStart() throws Exception { _connectorServer.start(); ShutdownThread.register(0, this); LOG.info("JMX Remote URL: {}", _connectorServer.getAddress().toString()); }
/** * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart() */ @Override public void doStart() throws Exception { _connectorServer.start(); ShutdownThread.register(0, this); LOG.info("JMX Remote URL: {}", _connectorServer.getAddress().toString()); }
/** * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart() */ @Override public void doStart() throws Exception { _connectorServer.start(); ShutdownThread.register(0, this); LOG.info("JMX Remote URL: {}", _connectorServer.getAddress().toString()); }
public JrdsMBeanInfo(String protocol, String host, int port) throws Exception { String path = "/"; if(protocol.equals("rmi")) { rmiRegistry = java.rmi.registry.LocateRegistry.createRegistry(port); path = "/jndi/rmi://" + host + ":" + port + "/jmxrmi"; } url = new JMXServiceURL(protocol, host, port, path); mbs = ManagementFactory.getPlatformMBeanServer(); cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs); cs.start(); JMXServiceURL addr = cs.getAddress(); cc = JMXConnectorFactory.connect(addr); } }
listener.setServer(server); final JMXServiceURL url = server.getAddress(); JMX_LOGGER.log(Level.INFO, JMX_STARTED_SERVICE, url);
private void closeConnectorServer() { if (_cs != null) { // Stopping the JMX ConnectorServer try { getEventLogger().message(ManagementConsoleMessages.SHUTTING_DOWN("JMX RMIConnectorServer", _cs.getAddress().getPort())); _cs.stop(); } catch (IOException e) { _log.error("Exception while closing the JMX ConnectorServer: ", e); } finally { _cs = null; } } }