本文整理汇总了Java中javax.management.MBeanServerConnection.getDefaultDomain方法的典型用法代码示例。如果您正苦于以下问题:Java MBeanServerConnection.getDefaultDomain方法的具体用法?Java MBeanServerConnection.getDefaultDomain怎么用?Java MBeanServerConnection.getDefaultDomain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.management.MBeanServerConnection
的用法示例。
在下文中一共展示了MBeanServerConnection.getDefaultDomain方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_simple
import javax.management.MBeanServerConnection; //导入方法依赖的package包/类
@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());
}
}
示例2: testStart
import javax.management.MBeanServerConnection; //导入方法依赖的package包/类
@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();
}
示例3: main
import javax.management.MBeanServerConnection; //导入方法依赖的package包/类
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();
}
}
开发者ID:breakEval13,项目名称:rocketmq-flink-plugin,代码行数:44,代码来源:JMXGarbageCollectorNotificationClient.java