use of javax.management.remote.JMXConnector in project jcollectd by collectd.
the class RemoteMBeanSender method setMBeanServerConnection.
public void setMBeanServerConnection(JMXServiceURL url) throws IOException {
JMXConnector connector = JMXConnectorFactory.connect(url);
setMBeanServerConnection(connector.getMBeanServerConnection());
}
use of javax.management.remote.JMXConnector in project druid by alibaba.
the class StatViewServlet method initJmxConn.
/**
* 初始化jmx连接
*
* @throws IOException
*/
private void initJmxConn() throws IOException {
if (jmxUrl != null) {
JMXServiceURL url = new JMXServiceURL(jmxUrl);
Map<String, String[]> env = null;
if (jmxUsername != null) {
env = new HashMap<String, String[]>();
String[] credentials = new String[] { jmxUsername, jmxPassword };
env.put(JMXConnector.CREDENTIALS, credentials);
}
JMXConnector jmxc = JMXConnectorFactory.connect(url, env);
conn = jmxc.getMBeanServerConnection();
}
}
use of javax.management.remote.JMXConnector in project druid by alibaba.
the class DruidStat method getDataSourceIds.
@SuppressWarnings("all")
public static List<Integer> getDataSourceIds(Option option) throws Exception {
String address = loadManagementAgentAndGetAddress(option.getPid());
JMXServiceURL jmxUrl = new JMXServiceURL(address);
JMXConnector jmxc = JMXConnectorFactory.connect(jmxUrl);
MBeanServerConnection jmxConn = jmxc.getMBeanServerConnection();
List<Map<String, Object>> content = (List<Map<String, Object>>) invokeService(jmxConn, Option.DATA_SOURCE);
TabledDataPrinter.printDataSourceData(content, option);
List<Integer> result = new ArrayList<Integer>();
for (Map<String, Object> dsStat : content) {
Integer id = (Integer) dsStat.get("Identity");
result.add(id);
}
return result;
}
use of javax.management.remote.JMXConnector in project jmxtrans by jmxtrans.
the class JMXConnectionTest method connectorIsClosed.
@Test
public void connectorIsClosed() throws IOException {
MBeanServerConnection mBeanServerConnection = mock(MBeanServerConnection.class);
JMXConnector jmxConnector = mock(JMXConnector.class);
JMXConnection jmxConnection = new JMXConnection(jmxConnector, mBeanServerConnection);
jmxConnection.close();
verify(jmxConnector).close();
}
use of javax.management.remote.JMXConnector in project jmxtrans by jmxtrans.
the class MBeanServerConnectionFactoryTest method connectionIsCreatedForRemoteServer.
@Test
public void connectionIsCreatedForRemoteServer() throws IOException {
JmxConnectionProvider server = mock(JmxConnectionProvider.class);
JMXConnector jmxConnector = mock(JMXConnector.class);
MBeanServerConnection mBeanServerConnection = mock(MBeanServerConnection.class);
when(server.isLocal()).thenReturn(false);
when(server.getServerConnection()).thenReturn(jmxConnector);
when(jmxConnector.getMBeanServerConnection()).thenReturn(mBeanServerConnection);
JMXConnection jmxConnection = factory.makeObject(server);
assertThat(jmxConnection.getMBeanServerConnection()).isSameAs(mBeanServerConnection);
}
Aggregations