@Test(groups = "short") public void should_make_JMX_connection() throws Exception { InetSocketAddress addr1 = ccm().jmxAddressOfNode(1); InetSocketAddress addr2 = ccm().jmxAddressOfNode(2); InetSocketAddress addr3 = ccm().jmxAddressOfNode(3); assertThat(addr1.getPort()).isNotEqualTo(addr2.getPort()); assertThat(addr1.getPort()).isNotEqualTo(addr3.getPort()); assertThat(addr2.getPort()).isNotEqualTo(addr3.getPort()); JMXServiceURL url = new JMXServiceURL( String.format( "service:jmx:rmi:///jndi/rmi://%s:%d/jmxrmi", addr2.getAddress().getHostAddress(), addr2.getPort())); JMXConnector jmxc = JMXConnectorFactory.connect(url, null); assertThat(jmxc.getConnectionId().isEmpty()).isFalse(); }
private String getConnectionId() { try { return connector.getConnectionId(); } catch (IOException x) { return null; } }
private String getConnectionId() { String id = null; try { id = connector.getConnectionId(); } catch(IOException e) { } return id; }
@Override public String getConnectorId() throws IOException { return connector.getConnectionId(); }
/** * @inheritDoc */ public String getConnectorId() throws IOException { return connector.getConnectionId(); }
@Override public String getConnectionId() throws IOException { return m_connectorProxy.getConnectionId(); }
@Override public String getConnectionId() throws IOException { return m_connectorProxy.getConnectionId(); }
@Override public String getConnectionId() throws IOException { return m_connectorProxy.getConnectionId(); }
/** * Returns a boolean describing if the connection is still alive. */ public boolean isAlive() { if (connector == null) { return false; } try { connector.getConnectionId(); } catch (IOException e) { // the connection is closed or broken return false; } return true; }
public String getConnectionId() throws IOException { return delegate.getConnectionId(); }
public synchronized void closeConnection() { if (connector != null) { try { LOG.debug("Closing a connection to a broker (" + connector.getConnectionId() + ")"); connector.close(); } catch (IOException e) { // Ignore the exception, since it most likly won't matter // anymore } } }
/** * Initializes a network connection to the configured JMX server and registers a connection * notification listener to to receive notifications of connection loss */ private void initNetworkConnection() throws IOException { if (mConnector != null) { try { mConnector.close(); } catch (Exception e) { // ignore, as this is best effort } } JMXServiceURL url = new JMXServiceURL(mJmxEndpoint.getServerURL()); String[] creds = {mJmxEndpoint.getUser(), mJmxEndpoint.getPassword()}; Map<String, String[]> map = Collections.singletonMap(JMXConnector.CREDENTIALS, creds); mConnector = JMXConnectorFactory.connect(url, map); mConnector.addConnectionNotificationListener(getConnectionNotificationListener(), null, null); mConnectionId = mConnector.getConnectionId(); setServerConnection(mConnector.getMBeanServerConnection()); }
logNotificationListener = new LogNotificationListener(); mbServer.addNotificationListener(this.monitoringLog, logNotificationListener, null, null); this.logger.info("Connected to JMX Server, ID: " + jmx.getConnectionId());
logNotificationListener = new LogNotificationListener(); mbServer.addNotificationListener(this.monitoringLog, logNotificationListener, null, null); this.logger.info("Connected to JMX Server, ID: {}", jmx.getConnectionId());
@Test(groups = "short") public void should_make_JMX_connection() throws Exception { InetSocketAddress addr1 = ccm().jmxAddressOfNode(1); InetSocketAddress addr2 = ccm().jmxAddressOfNode(2); InetSocketAddress addr3 = ccm().jmxAddressOfNode(3); assertThat(addr1.getPort()).isNotEqualTo(addr2.getPort()); assertThat(addr1.getPort()).isNotEqualTo(addr3.getPort()); assertThat(addr2.getPort()).isNotEqualTo(addr3.getPort()); JMXServiceURL url = new JMXServiceURL( String.format( "service:jmx:rmi:///jndi/rmi://%s:%d/jmxrmi", addr2.getAddress().getHostAddress(), addr2.getPort())); JMXConnector jmxc = JMXConnectorFactory.connect(url, null); assertThat(jmxc.getConnectionId().isEmpty()).isFalse(); }
logNotificationListener = new LogNotificationListener(); mbServer.addNotificationListener(this.monitoringLog, logNotificationListener, null, null); this.log.info("Connected to JMX Server, ID: " + jmx.getConnectionId());
logNotificationListener = new LogNotificationListener(); mbServer.addNotificationListener(this.monitoringLog, logNotificationListener, null, null); this.log.info("Connected to JMX Server, ID: " + jmx.getConnectionId());