Java Code Examples for javax.management.MBeanServerConnection.getDefaultDomain()

The following are Jave code examples for showing how to use getDefaultDomain() of the javax.management.MBeanServerConnection class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: otter-G   File: JmxLoaderIntegration.java   View Source Code Vote up 6 votes
@Test
public void test_simple() {
    MBeanServer mBeanServer = exporter.getServer();

    try {
        ObjectName objectName = new ObjectName("bean:name=otterControllor");
        MBeanInfo nodeInfo = mBeanServer.getMBeanInfo(objectName);
        System.out.println(nodeInfo);
        Object result = mBeanServer.getAttribute(objectName, "HeapMemoryUsage");
        System.out.println(result);

        JMXServiceURL address = new JMXServiceURL("service:jmx:rmi://127.0.0.1/jndi/rmi://127.0.0.1:1099/mbean");
        Map environment = null;

        JMXConnector cntor = JMXConnectorFactory.connect(address, environment);
        MBeanServerConnection mbsc = cntor.getMBeanServerConnection();
        String domain = mbsc.getDefaultDomain();
        System.out.println(domain);

        result = mbsc.getAttribute(objectName, "HeapMemoryUsage");
        System.out.println(result);
    } catch (Exception e) {
        want.fail(e.getMessage());
    }
}
 
Example 2
Project: ditb   File: TestJMXListener.java   View Source Code Vote up 5 votes
@Test
public void testStart() throws Exception {
  JMXConnector connector = JMXConnectorFactory.connect(
    JMXListener.buildJMXServiceURL(connectorPort,connectorPort));

  MBeanServerConnection mb = connector.getMBeanServerConnection();
  String domain = mb.getDefaultDomain();
  Assert.assertTrue("default domain is not correct",
    !domain.isEmpty());
  connector.close();

}
 
Example 3
Project: rocketmq-flink-plugin   File: JMXGarbageCollectorNotificationClient.java   View Source Code Vote up 4 votes
public static void main(String[] args) throws Exception {

        String host = args[0];
        String port = args[1];
        String user = args[2];
        String pass = args[3];
        int pollSleep = 300;

        HashMap<String, Object> env = new HashMap<String, Object>();
        String[] creds = new String[2];
        creds[0] = user;
        creds[1] = pass;
        env.put(JMXConnector.CREDENTIALS, creds);

        String urlString = System.getProperty("jmx.service.url","service:jmx:remoting-jmx://" + host + ":" + port);
        System.err.println("URL : " + urlString);
        JMXServiceURL serviceURL = new JMXServiceURL(urlString);
        JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, env);
        try {
            MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();

            JMXGarbageCollectorNotification gcLogging = new JMXGarbageCollectorNotification(connection);

            do {
                while (gcLogging.hasNext(pollSleep, TimeUnit.SECONDS)) {
                    Notification notification = gcLogging.next();
                    processNotification(connection, notification);
                }
                System.out.printf("<timestamp>%s</timestamp>\n", DATE_FORMAT.format(Calendar.getInstance().getTime()));

                // make a call using the connection to check it is still active, otherwise we never notice.
                connection.getDefaultDomain();
            } while (true);

        }
        catch (Exception e) {
            e.printStackTrace();
        }
        finally {
            jmxConnector.close();
        }

    }