Search in sources :

Example 91 with JMXServiceURL

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);
}
Also used : JMXServiceURL(javax.management.remote.JMXServiceURL) BrokerViewMBean(org.apache.activemq.broker.jmx.BrokerViewMBean) Destination(javax.jms.Destination) MessageConsumer(javax.jms.MessageConsumer) DestinationInfo(org.apache.activemq.command.DestinationInfo) JMXConnector(javax.management.remote.JMXConnector) Connection(javax.jms.Connection) MBeanServerConnection(javax.management.MBeanServerConnection) MBeanServerConnection(javax.management.MBeanServerConnection) ObjectName(javax.management.ObjectName) Session(javax.jms.Session) ActiveMQMessage(org.apache.activemq.command.ActiveMQMessage)

Example 92 with JMXServiceURL

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);
}
Also used : HashMap(java.util.HashMap) CacheServiceMBean(org.apache.cassandra.service.CacheServiceMBean) GossiperMBean(org.apache.cassandra.gms.GossiperMBean) ActiveRepairServiceMBean(org.apache.cassandra.service.ActiveRepairServiceMBean) GCInspectorMXBean(org.apache.cassandra.service.GCInspectorMXBean) MemoryMXBean(java.lang.management.MemoryMXBean) StreamManagerMBean(org.apache.cassandra.streaming.StreamManagerMBean) StorageProxyMBean(org.apache.cassandra.service.StorageProxyMBean) AuditLogManagerMBean(org.apache.cassandra.audit.AuditLogManagerMBean) RolesCacheMBean(org.apache.cassandra.auth.RolesCacheMBean) JMXServiceURL(javax.management.remote.JMXServiceURL) MalformedObjectNameException(javax.management.MalformedObjectNameException) CompactionManagerMBean(org.apache.cassandra.db.compaction.CompactionManagerMBean) MessagingServiceMBean(org.apache.cassandra.net.MessagingServiceMBean) PermissionsCacheMBean(org.apache.cassandra.auth.PermissionsCacheMBean) NetworkPermissionsCacheMBean(org.apache.cassandra.auth.NetworkPermissionsCacheMBean) FailureDetectorMBean(org.apache.cassandra.gms.FailureDetectorMBean) NetworkPermissionsCacheMBean(org.apache.cassandra.auth.NetworkPermissionsCacheMBean) RuntimeMXBean(java.lang.management.RuntimeMXBean) ObjectName(javax.management.ObjectName) StorageServiceMBean(org.apache.cassandra.service.StorageServiceMBean) BatchlogManagerMBean(org.apache.cassandra.batchlog.BatchlogManagerMBean) HintsServiceMBean(org.apache.cassandra.hints.HintsServiceMBean)

Example 93 with JMXServiceURL

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());
}
Also used : JMXServiceURL(javax.management.remote.JMXServiceURL) JMXConnector(javax.management.remote.JMXConnector)

Example 94 with JMXServiceURL

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);
        }
    }
}
Also used : JMXServiceURL(javax.management.remote.JMXServiceURL) TimeoutException(java.util.concurrent.TimeoutException) DatabusException(com.linkedin.databus2.core.DatabusException) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) ParseException(org.apache.commons.cli.ParseException) NameAlreadyBoundException(javax.naming.NameAlreadyBoundException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 95 with JMXServiceURL

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();
    }
}
Also used : JMXServiceURL(javax.management.remote.JMXServiceURL) JMXConnector(javax.management.remote.JMXConnector) TypedProperties(org.jumpmind.properties.TypedProperties) MBeanServerConnection(javax.management.MBeanServerConnection)

Aggregations

JMXServiceURL (javax.management.remote.JMXServiceURL)280 JMXConnector (javax.management.remote.JMXConnector)150 MBeanServerConnection (javax.management.MBeanServerConnection)107 ObjectName (javax.management.ObjectName)90 IOException (java.io.IOException)78 HashMap (java.util.HashMap)75 MBeanServer (javax.management.MBeanServer)71 JMXConnectorServer (javax.management.remote.JMXConnectorServer)64 MalformedURLException (java.net.MalformedURLException)45 RemoteException (java.rmi.RemoteException)22 Test (org.junit.Test)22 Map (java.util.Map)16 UnknownHostException (java.net.UnknownHostException)14 Properties (java.util.Properties)14 Notification (javax.management.Notification)14 NotificationListener (javax.management.NotificationListener)14 MalformedObjectNameException (javax.management.MalformedObjectNameException)13 LocateRegistry (java.rmi.registry.LocateRegistry)12 Registry (java.rmi.registry.Registry)12 ArrayList (java.util.ArrayList)11