use of javax.management.remote.JMXServiceURL in project activemq-artemis by apache.
the class AdvisoryJmxTest method testCreateDeleteDestinations.
public void testCreateDeleteDestinations() throws Exception {
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1199/jmxrmi");
JMXConnector connector = JMXConnectorFactory.connect(url, null);
connector.connect();
MBeanServerConnection connection = connector.getMBeanServerConnection();
ObjectName name = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost");
BrokerViewMBean brokerMbean = MBeanServerInvocationHandler.newProxyInstance(connection, name, BrokerViewMBean.class, true);
Connection conn = createConnection();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = sess.createConsumer(sess.createTopic("ActiveMQ.Advisory.Queue"));
conn.start();
Destination dest = sess.createQueue("test");
brokerMbean.addQueue("test");
ActiveMQMessage msg = (ActiveMQMessage) consumer.receive(1000);
assertNotNull(msg);
assertTrue(msg.getDataStructure() instanceof DestinationInfo);
assertEquals(((DestinationInfo) msg.getDataStructure()).getDestination(), dest);
assertEquals(((DestinationInfo) msg.getDataStructure()).getOperationType(), 0);
brokerMbean.removeQueue("test");
msg = (ActiveMQMessage) consumer.receive(1000);
assertNotNull(msg);
assertTrue(msg.getDataStructure() instanceof DestinationInfo);
assertEquals(((DestinationInfo) msg.getDataStructure()).getDestination(), dest);
assertEquals(((DestinationInfo) msg.getDataStructure()).getOperationType(), 1);
brokerMbean.addQueue("test");
msg = (ActiveMQMessage) consumer.receive(1000);
assertNotNull(msg);
assertTrue(msg.getDataStructure() instanceof DestinationInfo);
assertEquals(((DestinationInfo) msg.getDataStructure()).getDestination(), dest);
assertEquals(((DestinationInfo) msg.getDataStructure()).getOperationType(), 0);
assertEquals(((DestinationInfo) msg.getDataStructure()).getOperationType(), 0);
}
use of javax.management.remote.JMXServiceURL in project cassandra by apache.
the class ColumnFamilyStoreMBeanIterator method connect.
/**
* Create a connection to the JMX agent and setup the M[X]Bean proxies.
*
* @throws IOException on connection failures
*/
protected void connect() throws IOException {
JMXServiceURL jmxUrl = new JMXServiceURL(String.format(fmtUrl, host, port));
Map<String, Object> env = new HashMap<String, Object>();
if (username != null) {
String[] creds = { username, password };
env.put(JMXConnector.CREDENTIALS, creds);
}
env.put("com.sun.jndi.rmi.factory.socket", getRMIClientSocketFactory());
jmxc = JMXConnectorFactory.connect(jmxUrl, env);
mbeanServerConn = jmxc.getMBeanServerConnection();
try {
ObjectName name = new ObjectName(ssObjName);
ssProxy = JMX.newMBeanProxy(mbeanServerConn, name, StorageServiceMBean.class);
name = new ObjectName(MessagingService.MBEAN_NAME);
msProxy = JMX.newMBeanProxy(mbeanServerConn, name, MessagingServiceMBean.class);
name = new ObjectName(StreamManagerMBean.OBJECT_NAME);
streamProxy = JMX.newMBeanProxy(mbeanServerConn, name, StreamManagerMBean.class);
name = new ObjectName(CompactionManager.MBEAN_OBJECT_NAME);
compactionProxy = JMX.newMBeanProxy(mbeanServerConn, name, CompactionManagerMBean.class);
name = new ObjectName(FailureDetector.MBEAN_NAME);
fdProxy = JMX.newMBeanProxy(mbeanServerConn, name, FailureDetectorMBean.class);
name = new ObjectName(CacheService.MBEAN_NAME);
cacheService = JMX.newMBeanProxy(mbeanServerConn, name, CacheServiceMBean.class);
name = new ObjectName(StorageProxy.MBEAN_NAME);
spProxy = JMX.newMBeanProxy(mbeanServerConn, name, StorageProxyMBean.class);
name = new ObjectName(HintsService.MBEAN_NAME);
hsProxy = JMX.newMBeanProxy(mbeanServerConn, name, HintsServiceMBean.class);
name = new ObjectName(GCInspector.MBEAN_NAME);
gcProxy = JMX.newMBeanProxy(mbeanServerConn, name, GCInspectorMXBean.class);
name = new ObjectName(Gossiper.MBEAN_NAME);
gossProxy = JMX.newMBeanProxy(mbeanServerConn, name, GossiperMBean.class);
name = new ObjectName(BatchlogManager.MBEAN_NAME);
bmProxy = JMX.newMBeanProxy(mbeanServerConn, name, BatchlogManagerMBean.class);
name = new ObjectName(ActiveRepairServiceMBean.MBEAN_NAME);
arsProxy = JMX.newMBeanProxy(mbeanServerConn, name, ActiveRepairServiceMBean.class);
name = new ObjectName(AuditLogManager.MBEAN_NAME);
almProxy = JMX.newMBeanProxy(mbeanServerConn, name, AuditLogManagerMBean.class);
name = new ObjectName(AuthCache.MBEAN_NAME_BASE + PasswordAuthenticator.CredentialsCacheMBean.CACHE_NAME);
ccProxy = JMX.newMBeanProxy(mbeanServerConn, name, PasswordAuthenticator.CredentialsCacheMBean.class);
name = new ObjectName(AuthCache.MBEAN_NAME_BASE + AuthorizationProxy.JmxPermissionsCacheMBean.CACHE_NAME);
jpcProxy = JMX.newMBeanProxy(mbeanServerConn, name, AuthorizationProxy.JmxPermissionsCacheMBean.class);
name = new ObjectName(AuthCache.MBEAN_NAME_BASE + NetworkPermissionsCache.CACHE_NAME);
npcProxy = JMX.newMBeanProxy(mbeanServerConn, name, NetworkPermissionsCacheMBean.class);
name = new ObjectName(AuthCache.MBEAN_NAME_BASE + PermissionsCache.CACHE_NAME);
pcProxy = JMX.newMBeanProxy(mbeanServerConn, name, PermissionsCacheMBean.class);
name = new ObjectName(AuthCache.MBEAN_NAME_BASE + RolesCache.CACHE_NAME);
rcProxy = JMX.newMBeanProxy(mbeanServerConn, name, RolesCacheMBean.class);
} catch (MalformedObjectNameException e) {
throw new RuntimeException("Invalid ObjectName? Please report this as a bug.", e);
}
memProxy = ManagementFactory.newPlatformMXBeanProxy(mbeanServerConn, ManagementFactory.MEMORY_MXBEAN_NAME, MemoryMXBean.class);
runtimeProxy = ManagementFactory.newPlatformMXBeanProxy(mbeanServerConn, ManagementFactory.RUNTIME_MXBEAN_NAME, RuntimeMXBean.class);
}
use of javax.management.remote.JMXServiceURL in project neo4j by neo4j.
the class JmxDump method connectTo.
public static JmxDump connectTo(String jmxAddress) throws IOException {
JMXServiceURL url = new JMXServiceURL(jmxAddress);
JMXConnector connect = JMXConnectorFactory.connect(url);
return new JmxDump(connect.getMBeanServerConnection());
}
use of javax.management.remote.JMXServiceURL in project databus by linkedin.
the class JmxShutdownThread method initializeContainerJmx.
protected void initializeContainerJmx() {
if (_containerStaticConfig.getJmx().isRmiEnabled()) {
try {
JMXServiceURL jmxServiceUrl = new JMXServiceURL("service:jmx:rmi://" + _containerStaticConfig.getJmx().getJmxServiceHost() + ":" + _containerStaticConfig.getJmx().getJmxServicePort() + "/jndi/rmi://" + _containerStaticConfig.getJmx().getRmiRegistryHost() + ":" + _containerStaticConfig.getJmx().getRmiRegistryPort() + "/jmxrmi" + _containerStaticConfig.getJmx().getJmxServicePort());
_jmxConnServer = JMXConnectorServerFactory.newJMXConnectorServer(jmxServiceUrl, null, getMbeanServer());
} catch (Exception e) {
LOG.warn("Unable to instantiate JMX server", e);
}
}
}
use of javax.management.remote.JMXServiceURL in project symmetric-ds by JumpMind.
the class JmxCommand method execute.
protected <T> T execute(IJmxTemplate<T> template) throws Exception {
String host = "localhost";
String url = "service:jmx:rmi:///jndi/rmi://" + host + ":" + System.getProperty("jmx.agent.port", "31418") + "/jmxrmi";
JMXServiceURL serviceUrl = new JMXServiceURL(url);
JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceUrl, null);
TypedProperties properties = getTypedProperties();
String engineName = properties.get(ParameterConstants.ENGINE_NAME, "unknown");
try {
MBeanServerConnection mbeanConn = jmxConnector.getMBeanServerConnection();
return template.execute(engineName, mbeanConn);
} finally {
jmxConnector.close();
}
}
Aggregations