javax.management.JMX Java Examples
The following examples show how to use
javax.management.JMX.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JMXProxyFallbackTest.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private static void testPrivate(Class<?> iface) throws Exception { try { System.out.println("Creating a proxy for private M(X)Bean " + iface.getName() + " ..."); MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName on = new ObjectName("test:type=Proxy"); JMX.newMBeanProxy(mbs, on, iface); success("Created a proxy for private M(X)Bean - " + iface.getName()); } catch (Exception e) { Throwable t = e; while (t != null && !(t instanceof NotCompliantMBeanException)) { t = t.getCause(); } if (t != null) { fail("Proxy not created"); } else { throw e; } } }
Example #2
Source File: TestUtils.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Transfroms a proxy implementing T in a proxy implementing T plus * NotificationEmitter * **/ public static <T> T makeNotificationEmitter(T proxy, Class<T> mbeanInterface) { if (proxy instanceof NotificationEmitter) return proxy; if (proxy == null) return null; if (!(proxy instanceof Proxy)) throw new IllegalArgumentException("not a "+Proxy.class.getName()); final Proxy p = (Proxy) proxy; final InvocationHandler handler = Proxy.getInvocationHandler(proxy); if (!(handler instanceof MBeanServerInvocationHandler)) throw new IllegalArgumentException("not a JMX Proxy"); final MBeanServerInvocationHandler h = (MBeanServerInvocationHandler)handler; final ObjectName name = h.getObjectName(); final MBeanServerConnection mbs = h.getMBeanServerConnection(); final boolean isMXBean = h.isMXBean(); final T newProxy; if (isMXBean) newProxy = JMX.newMXBeanProxy(mbs,name,mbeanInterface,true); else newProxy = JMX.newMBeanProxy(mbs,name,mbeanInterface,true); return newProxy; }
Example #3
Source File: MBeanClientInterceptor.java From java-technology-stack with MIT License | 6 votes |
/** * Ensures that an {@code MBeanServerConnection} is configured and attempts * to detect a local connection if one is not supplied. */ public void prepare() { synchronized (this.preparationMonitor) { if (this.server != null) { this.serverToUse = this.server; } else { this.serverToUse = null; this.serverToUse = this.connector.connect(this.serviceUrl, this.environment, this.agentId); } this.invocationHandler = null; if (this.useStrictCasing) { Assert.state(this.objectName != null, "No ObjectName set"); // Use the JDK's own MBeanServerInvocationHandler, in particular for native MXBean support. this.invocationHandler = new MBeanServerInvocationHandler(this.serverToUse, this.objectName, (this.managementInterface != null && JMX.isMXBeanInterface(this.managementInterface))); } else { // Non-strict casing can only be achieved through custom invocation handling. // Only partial MXBean support available! retrieveMBeanInfo(this.serverToUse); } } }
Example #4
Source File: SchedulerRuntimeDataMBeanTest.java From scheduling with GNU Affero General Public License v3.0 | 6 votes |
private void testAsUser() throws Exception { final SchedulerAuthenticationInterface auth = schedulerHelper.getSchedulerAuth(); final HashMap<String, Object> env = new HashMap<>(1); env.put(JMXConnector.CREDENTIALS, new Object[] { TestUsers.USER.username, TestUsers.USER.password }); JMXConnector userJmxConnector = JMXConnectorFactory.connect(new JMXServiceURL(auth.getJMXConnectorURL(JMXTransportProtocol.RMI)), env); try { MBeanServerConnection connection = userJmxConnector.getMBeanServerConnection(); final ObjectName beanName = new ObjectName(SchedulerJMXHelper.RUNTIMEDATA_MBEAN_NAME); RuntimeDataMBean bean = JMX.newMXBeanProxy(connection, beanName, RuntimeDataMBean.class); checkDataConsistent(bean); } finally { userJmxConnector.close(); } }
Example #5
Source File: ExceptionDiagnosisTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private static void testCaseProb() throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName name = new ObjectName("a:b=c"); mbs.registerMBean(new CaseProbImpl(), name); CaseProbMXBean proxy = JMX.newMXBeanProxy(mbs, name, CaseProbMXBean.class); try { CaseProb prob = proxy.getCaseProb(); fail("No exception from proxy method getCaseProb"); } catch (IllegalArgumentException e) { String messageChain = messageChain(e); if (messageChain.contains("URLPath")) { System.out.println("Message chain contains URLPath as required: " + messageChain); } else { fail("Exception chain for CaseProb does not mention property" + " URLPath differing only in case"); System.out.println("Full stack trace:"); e.printStackTrace(System.out); } } }
Example #6
Source File: JMXProxyFallbackTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static void testPrivate(Class<?> iface) throws Exception { try { System.out.println("Creating a proxy for private M(X)Bean " + iface.getName() + " ..."); MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName on = new ObjectName("test:type=Proxy"); JMX.newMBeanProxy(mbs, on, iface); success("Created a proxy for private M(X)Bean - " + iface.getName()); } catch (Exception e) { Throwable t = e; while (t != null && !(t instanceof NotCompliantMBeanException)) { t = t.getCause(); } if (t != null) { fail("Proxy not created"); } else { throw e; } } }
Example #7
Source File: ExceptionDiagnosisTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private static void testCaseProb() throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName name = new ObjectName("a:b=c"); mbs.registerMBean(new CaseProbImpl(), name); CaseProbMXBean proxy = JMX.newMXBeanProxy(mbs, name, CaseProbMXBean.class); try { CaseProb prob = proxy.getCaseProb(); fail("No exception from proxy method getCaseProb"); } catch (IllegalArgumentException e) { String messageChain = messageChain(e); if (messageChain.contains("URLPath")) { System.out.println("Message chain contains URLPath as required: " + messageChain); } else { fail("Exception chain for CaseProb does not mention property" + " URLPath differing only in case"); System.out.println("Full stack trace:"); e.printStackTrace(System.out); } } }
Example #8
Source File: JMXProxyFallbackTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private static void testPrivate(Class<?> iface) throws Exception { try { System.out.println("Creating a proxy for private M(X)Bean " + iface.getName() + " ..."); MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName on = new ObjectName("test:type=Proxy"); JMX.newMBeanProxy(mbs, on, iface); success("Created a proxy for private M(X)Bean - " + iface.getName()); } catch (Exception e) { Throwable t = e; while (t != null && !(t instanceof NotCompliantMBeanException)) { t = t.getCause(); } if (t != null) { fail("Proxy not created"); } else { throw e; } } }
Example #9
Source File: TestUtils.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Transfroms a proxy implementing T in a proxy implementing T plus * NotificationEmitter * **/ public static <T> T makeNotificationEmitter(T proxy, Class<T> mbeanInterface) { if (proxy instanceof NotificationEmitter) return proxy; if (proxy == null) return null; if (!(proxy instanceof Proxy)) throw new IllegalArgumentException("not a "+Proxy.class.getName()); final Proxy p = (Proxy) proxy; final InvocationHandler handler = Proxy.getInvocationHandler(proxy); if (!(handler instanceof MBeanServerInvocationHandler)) throw new IllegalArgumentException("not a JMX Proxy"); final MBeanServerInvocationHandler h = (MBeanServerInvocationHandler)handler; final ObjectName name = h.getObjectName(); final MBeanServerConnection mbs = h.getMBeanServerConnection(); final boolean isMXBean = h.isMXBean(); final T newProxy; if (isMXBean) newProxy = JMX.newMXBeanProxy(mbs,name,mbeanInterface,true); else newProxy = JMX.newMBeanProxy(mbs,name,mbeanInterface,true); return newProxy; }
Example #10
Source File: JMXProxyFallbackTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
private static void testPrivate(Class<?> iface) throws Exception { try { System.out.println("Creating a proxy for private M(X)Bean " + iface.getName() + " ..."); MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName on = new ObjectName("test:type=Proxy"); JMX.newMBeanProxy(mbs, on, iface); success("Created a proxy for private M(X)Bean - " + iface.getName()); } catch (Exception e) { Throwable t = e; while (t != null && !(t instanceof NotCompliantMBeanException)) { t = t.getCause(); } if (t != null) { fail("Proxy not created"); } else { throw e; } } }
Example #11
Source File: ExceptionDiagnosisTest.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private static void testCaseProb() throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName name = new ObjectName("a:b=c"); mbs.registerMBean(new CaseProbImpl(), name); CaseProbMXBean proxy = JMX.newMXBeanProxy(mbs, name, CaseProbMXBean.class); try { CaseProb prob = proxy.getCaseProb(); fail("No exception from proxy method getCaseProb"); } catch (IllegalArgumentException e) { String messageChain = messageChain(e); if (messageChain.contains("URLPath")) { System.out.println("Message chain contains URLPath as required: " + messageChain); } else { fail("Exception chain for CaseProb does not mention property" + " URLPath differing only in case"); System.out.println("Full stack trace:"); e.printStackTrace(System.out); } } }
Example #12
Source File: JMXProxyTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static void testCompliant(Class<?> iface, boolean isMx) throws Exception { try { System.out.println("Creating a proxy for compliant " + (isMx ? "MXBean" : "MBean") + " " + iface.getName() + " ..."); MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName on = new ObjectName("test:type=Proxy"); if (isMx) { JMX.newMXBeanProxy(mbs, on, iface); } else { JMX.newMBeanProxy(mbs, on, iface); } success("Created a proxy for compliant " + (isMx ? "MXBean" : "MBean") + " - " + iface.getName()); } catch (Exception e) { Throwable t = e; while (t != null && !(t instanceof NotCompliantMBeanException)) { t = t.getCause(); } if (t != null) { fail("Proxy not created"); } else { throw e; } } }
Example #13
Source File: RandomMXBeanTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName name = new ObjectName("a:b=c"); StupidMXBean stupid = new StupidImpl(); mbs.registerMBean(stupid, name); ObjectName referName = new ObjectName("a:c=d"); mbs.registerMBean(new ReferImpl(stupid), referName); System.out.println(mbs.getMBeanInfo(name)); StupidMXBean stupid2 = (StupidMXBean) Proxy.newProxyInstance(StupidMXBean.class.getClassLoader(), new Class<?>[] {StupidMXBean.class}, new WrapInvocationHandler(stupid)); ObjectName stupidName2 = new ObjectName("a:d=e"); mbs.registerMBean(stupid2, stupidName2); Field zero = StupidMXBean.class.getField("ZERO"); System.out.println("Zero field = " + zero.get(null)); test(mbs, MerlinMXBean.class); test(mbs, TigerMXBean.class); StupidMXBean proxy = JMX.newMXBeanProxy(mbs, name, StupidMXBean.class); System.out.println("Zero = " + proxy.getZero()); System.out.println("One = " + proxy.identity(1)); ReferMXBean referProxy = JMX.newMXBeanProxy(mbs, referName, ReferMXBean.class); StupidMXBean stupidProxy2 = referProxy.getStupid(); System.out.println("Same proxy: " + (proxy == stupidProxy2)); Method[] methods = StupidMXBean.class.getMethods(); for (Method method : methods) { if (method.getParameterTypes().length == 0) method.invoke(proxy, new Object[0]); } }
Example #14
Source File: JmxOperationInvoker.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public <T> T getMBeanProxy(final ObjectName objectName, final Class<T> mbeanInterface) { if (DistributedSystemMXBean.class.equals(mbeanInterface) && ManagementConstants.OBJECTNAME__DISTRIBUTEDSYSTEM_MXBEAN.equals(objectName.toString())) { return mbeanInterface.cast(getDistributedSystemMXBean()); } else if (JMX.isMXBeanInterface(mbeanInterface)) { return JMX.newMXBeanProxy(getMBeanServerConnection(), objectName, mbeanInterface); } else { return JMX.newMBeanProxy(getMBeanServerConnection(), objectName, mbeanInterface); } }
Example #15
Source File: MXBeanTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static void testMXBean(MBeanServer mbs, ObjectName on) throws Exception { MBeanInfo mbi = mbs.getMBeanInfo(on); MBeanAttributeInfo[] attrs = mbi.getAttributes(); int nattrs = attrs.length; if (mbi.getAttributes().length != 1) failure("wrong number of attributes: " + attrs); else { MBeanAttributeInfo mbai = attrs[0]; if (mbai.getName().equals("Ints") && mbai.isReadable() && !mbai.isWritable() && mbai.getDescriptor().getFieldValue("openType") .equals(new ArrayType<int[]>(SimpleType.INTEGER, true)) && attrs[0].getType().equals("[I")) success("MBeanAttributeInfo"); else failure("MBeanAttributeInfo: " + mbai); } int[] ints = (int[]) mbs.getAttribute(on, "Ints"); if (equal(ints, new int[] {1, 2, 3}, null)) success("getAttribute"); else failure("getAttribute: " + Arrays.toString(ints)); ExplicitMXBean proxy = JMX.newMXBeanProxy(mbs, on, ExplicitMXBean.class); int[] pints = proxy.getInts(); if (equal(pints, new int[] {1, 2, 3}, null)) success("getAttribute through proxy"); else failure("getAttribute through proxy: " + Arrays.toString(pints)); }
Example #16
Source File: ProdJmxConnect.java From cassandra-mesos-deprecated with Apache License 2.0 | 5 votes |
@NotNull private <T> T newProxy(final String name, final Class<T> type) { lock.lock(); try { connect(); return JMX.newMBeanProxy(mbeanServerConn, new ObjectName(name), type); } catch (final Exception e) { throw new JmxRuntimeException("Failed to create proxy for " + name, e); } finally { lock.unlock(); } }
Example #17
Source File: MXBeanInteropTest1.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private final int doMemoryManagerMXBeanTest(MBeanServerConnection mbsc) { int errorCount = 0 ; System.out.println("---- MemoryManagerMXBean") ; try { ObjectName filterName = new ObjectName(ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE + ",*"); Set<ObjectName> onSet = mbsc.queryNames(filterName, null); for (Iterator<ObjectName> iter = onSet.iterator(); iter.hasNext(); ) { ObjectName memoryManagerName = iter.next() ; System.out.println("-------- " + memoryManagerName) ; MBeanInfo mbInfo = mbsc.getMBeanInfo(memoryManagerName); System.out.println("getMBeanInfo\t\t" + mbInfo); errorCount += checkNonEmpty(mbInfo); MemoryManagerMXBean memoryManager = null; memoryManager = JMX.newMXBeanProxy(mbsc, memoryManagerName, MemoryManagerMXBean.class) ; System.out.println("getMemoryPoolNames\t\t" + Arrays.deepToString(memoryManager.getMemoryPoolNames())); System.out.println("getName\t\t" + memoryManager.getName()); System.out.println("isValid\t\t" + memoryManager.isValid()); } System.out.println("---- OK\n") ; } catch (Exception e) { Utils.printThrowable(e, true) ; errorCount++ ; System.out.println("---- ERROR\n") ; } return errorCount ; }
Example #18
Source File: JMXProxyTest.java From hottub with GNU General Public License v2.0 | 5 votes |
private static void testCompliant(Class<?> iface, boolean isMx) throws Exception { try { System.out.println("Creating a proxy for compliant " + (isMx ? "MXBean" : "MBean") + " " + iface.getName() + " ..."); MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName on = new ObjectName("test:type=Proxy"); if (isMx) { JMX.newMXBeanProxy(mbs, on, iface); } else { JMX.newMBeanProxy(mbs, on, iface); } success("Created a proxy for compliant " + (isMx ? "MXBean" : "MBean") + " - " + iface.getName()); } catch (Exception e) { Throwable t = e; while (t != null && !(t instanceof NotCompliantMBeanException)) { t = t.getCause(); } if (t != null) { fail("Proxy not created"); } else { throw e; } } }
Example #19
Source File: RandomMXBeanTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName name = new ObjectName("a:b=c"); StupidMXBean stupid = new StupidImpl(); mbs.registerMBean(stupid, name); ObjectName referName = new ObjectName("a:c=d"); mbs.registerMBean(new ReferImpl(stupid), referName); System.out.println(mbs.getMBeanInfo(name)); StupidMXBean stupid2 = (StupidMXBean) Proxy.newProxyInstance(StupidMXBean.class.getClassLoader(), new Class<?>[] {StupidMXBean.class}, new WrapInvocationHandler(stupid)); ObjectName stupidName2 = new ObjectName("a:d=e"); mbs.registerMBean(stupid2, stupidName2); Field zero = StupidMXBean.class.getField("ZERO"); System.out.println("Zero field = " + zero.get(null)); test(mbs, MerlinMXBean.class); test(mbs, TigerMXBean.class); StupidMXBean proxy = JMX.newMXBeanProxy(mbs, name, StupidMXBean.class); System.out.println("Zero = " + proxy.getZero()); System.out.println("One = " + proxy.identity(1)); ReferMXBean referProxy = JMX.newMXBeanProxy(mbs, referName, ReferMXBean.class); StupidMXBean stupidProxy2 = referProxy.getStupid(); System.out.println("Same proxy: " + (proxy == stupidProxy2)); Method[] methods = StupidMXBean.class.getMethods(); for (Method method : methods) { if (method.getParameterTypes().length == 0) method.invoke(proxy, new Object[0]); } }
Example #20
Source File: RandomMXBeanTest.java From hottub with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName name = new ObjectName("a:b=c"); StupidMXBean stupid = new StupidImpl(); mbs.registerMBean(stupid, name); ObjectName referName = new ObjectName("a:c=d"); mbs.registerMBean(new ReferImpl(stupid), referName); System.out.println(mbs.getMBeanInfo(name)); StupidMXBean stupid2 = (StupidMXBean) Proxy.newProxyInstance(StupidMXBean.class.getClassLoader(), new Class<?>[] {StupidMXBean.class}, new WrapInvocationHandler(stupid)); ObjectName stupidName2 = new ObjectName("a:d=e"); mbs.registerMBean(stupid2, stupidName2); Field zero = StupidMXBean.class.getField("ZERO"); System.out.println("Zero field = " + zero.get(null)); test(mbs, MerlinMXBean.class); test(mbs, TigerMXBean.class); StupidMXBean proxy = JMX.newMXBeanProxy(mbs, name, StupidMXBean.class); System.out.println("Zero = " + proxy.getZero()); System.out.println("One = " + proxy.identity(1)); ReferMXBean referProxy = JMX.newMXBeanProxy(mbs, referName, ReferMXBean.class); StupidMXBean stupidProxy2 = referProxy.getStupid(); System.out.println("Same proxy: " + (proxy == stupidProxy2)); Method[] methods = StupidMXBean.class.getMethods(); for (Method method : methods) { if (method.getParameterTypes().length == 0) method.invoke(proxy, new Object[0]); } }
Example #21
Source File: MXBeanInteropTest1.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private final int doClassLoadingMXBeanTest(MBeanServerConnection mbsc) { int errorCount = 0 ; System.out.println("---- ClassLoadingMXBean") ; try { ObjectName classLoadingName = new ObjectName(ManagementFactory.CLASS_LOADING_MXBEAN_NAME) ; MBeanInfo mbInfo = mbsc.getMBeanInfo(classLoadingName); errorCount += checkNonEmpty(mbInfo); System.out.println("getMBeanInfo\t\t" + mbInfo); ClassLoadingMXBean classLoading = null; classLoading = JMX.newMXBeanProxy(mbsc, classLoadingName, ClassLoadingMXBean.class) ; System.out.println("getLoadedClassCount\t\t" + classLoading.getLoadedClassCount()); System.out.println("getTotalLoadedClassCount\t\t" + classLoading.getTotalLoadedClassCount()); System.out.println("getUnloadedClassCount\t\t" + classLoading.getUnloadedClassCount()); System.out.println("isVerbose\t\t" + classLoading.isVerbose()); System.out.println("---- OK\n") ; } catch (Exception e) { Utils.printThrowable(e, true) ; errorCount++ ; System.out.println("---- ERROR\n") ; } return errorCount ; }
Example #22
Source File: RandomMXBeanTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName name = new ObjectName("a:b=c"); StupidMXBean stupid = new StupidImpl(); mbs.registerMBean(stupid, name); ObjectName referName = new ObjectName("a:c=d"); mbs.registerMBean(new ReferImpl(stupid), referName); System.out.println(mbs.getMBeanInfo(name)); StupidMXBean stupid2 = (StupidMXBean) Proxy.newProxyInstance(StupidMXBean.class.getClassLoader(), new Class<?>[] {StupidMXBean.class}, new WrapInvocationHandler(stupid)); ObjectName stupidName2 = new ObjectName("a:d=e"); mbs.registerMBean(stupid2, stupidName2); Field zero = StupidMXBean.class.getField("ZERO"); System.out.println("Zero field = " + zero.get(null)); test(mbs, MerlinMXBean.class); test(mbs, TigerMXBean.class); StupidMXBean proxy = JMX.newMXBeanProxy(mbs, name, StupidMXBean.class); System.out.println("Zero = " + proxy.getZero()); System.out.println("One = " + proxy.identity(1)); ReferMXBean referProxy = JMX.newMXBeanProxy(mbs, referName, ReferMXBean.class); StupidMXBean stupidProxy2 = referProxy.getStupid(); System.out.println("Same proxy: " + (proxy == stupidProxy2)); Method[] methods = StupidMXBean.class.getMethods(); for (Method method : methods) { if (method.getParameterTypes().length == 0) method.invoke(proxy, new Object[0]); } }
Example #23
Source File: MXBeanTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static void testMXBean(MBeanServer mbs, ObjectName on) throws Exception { MBeanInfo mbi = mbs.getMBeanInfo(on); MBeanAttributeInfo[] attrs = mbi.getAttributes(); int nattrs = attrs.length; if (mbi.getAttributes().length != 1) failure("wrong number of attributes: " + attrs); else { MBeanAttributeInfo mbai = attrs[0]; if (mbai.getName().equals("Ints") && mbai.isReadable() && !mbai.isWritable() && mbai.getDescriptor().getFieldValue("openType") .equals(new ArrayType<int[]>(SimpleType.INTEGER, true)) && attrs[0].getType().equals("[I")) success("MBeanAttributeInfo"); else failure("MBeanAttributeInfo: " + mbai); } int[] ints = (int[]) mbs.getAttribute(on, "Ints"); if (equal(ints, new int[] {1, 2, 3}, null)) success("getAttribute"); else failure("getAttribute: " + Arrays.toString(ints)); ExplicitMXBean proxy = JMX.newMXBeanProxy(mbs, on, ExplicitMXBean.class); int[] pints = proxy.getInts(); if (equal(pints, new int[] {1, 2, 3}, null)) success("getAttribute through proxy"); else failure("getAttribute through proxy: " + Arrays.toString(pints)); }
Example #24
Source File: MXBeanInteropTest1.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private final int doOperatingSystemMXBeanTest(MBeanServerConnection mbsc) { int errorCount = 0 ; System.out.println("---- OperatingSystemMXBean") ; try { ObjectName operationName = new ObjectName(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME) ; MBeanInfo mbInfo = mbsc.getMBeanInfo(operationName); errorCount += checkNonEmpty(mbInfo); System.out.println("getMBeanInfo\t\t" + mbInfo); OperatingSystemMXBean operation = null ; operation = JMX.newMXBeanProxy(mbsc, operationName, OperatingSystemMXBean.class) ; System.out.println("getArch\t\t" + operation.getArch()); System.out.println("getAvailableProcessors\t\t" + operation.getAvailableProcessors()); System.out.println("getName\t\t" + operation.getName()); System.out.println("getVersion\t\t" + operation.getVersion()); System.out.println("---- OK\n") ; } catch (Exception e) { Utils.printThrowable(e, true) ; errorCount++ ; System.out.println("---- ERROR\n") ; } return errorCount ; }
Example #25
Source File: MXBeanInteropTest1.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private final int doCompilationMXBeanTest(MBeanServerConnection mbsc) { int errorCount = 0 ; System.out.println("---- CompilationMXBean") ; try { ObjectName compilationName = new ObjectName(ManagementFactory.COMPILATION_MXBEAN_NAME); if ( mbsc.isRegistered(compilationName) ) { MBeanInfo mbInfo = mbsc.getMBeanInfo(compilationName); errorCount += checkNonEmpty(mbInfo); System.out.println("getMBeanInfo\t\t" + mbInfo); CompilationMXBean compilation = null ; compilation = JMX.newMXBeanProxy(mbsc, compilationName, CompilationMXBean.class) ; System.out.println("getName\t\t" + compilation.getName()); boolean supported = compilation.isCompilationTimeMonitoringSupported() ; System.out.println("isCompilationTimeMonitoringSupported\t\t" + supported); if ( supported ) { System.out.println("getTotalCompilationTime\t\t" + compilation.getTotalCompilationTime()); } } System.out.println("---- OK\n") ; } catch (Exception e) { Utils.printThrowable(e, true) ; errorCount++ ; System.out.println("---- ERROR\n") ; } return errorCount ; }
Example #26
Source File: MXBeanInteropTest1.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private final int doMemoryManagerMXBeanTest(MBeanServerConnection mbsc) { int errorCount = 0 ; System.out.println("---- MemoryManagerMXBean") ; try { ObjectName filterName = new ObjectName(ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE + ",*"); Set<ObjectName> onSet = mbsc.queryNames(filterName, null); for (Iterator<ObjectName> iter = onSet.iterator(); iter.hasNext(); ) { ObjectName memoryManagerName = iter.next() ; System.out.println("-------- " + memoryManagerName) ; MBeanInfo mbInfo = mbsc.getMBeanInfo(memoryManagerName); System.out.println("getMBeanInfo\t\t" + mbInfo); errorCount += checkNonEmpty(mbInfo); MemoryManagerMXBean memoryManager = null; memoryManager = JMX.newMXBeanProxy(mbsc, memoryManagerName, MemoryManagerMXBean.class) ; System.out.println("getMemoryPoolNames\t\t" + Arrays.deepToString(memoryManager.getMemoryPoolNames())); System.out.println("getName\t\t" + memoryManager.getName()); System.out.println("isValid\t\t" + memoryManager.isValid()); } System.out.println("---- OK\n") ; } catch (Exception e) { Utils.printThrowable(e, true) ; errorCount++ ; System.out.println("---- ERROR\n") ; } return errorCount ; }
Example #27
Source File: MXBeanInteropTest1.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private final int doCompilationMXBeanTest(MBeanServerConnection mbsc) { int errorCount = 0 ; System.out.println("---- CompilationMXBean") ; try { ObjectName compilationName = new ObjectName(ManagementFactory.COMPILATION_MXBEAN_NAME); if ( mbsc.isRegistered(compilationName) ) { MBeanInfo mbInfo = mbsc.getMBeanInfo(compilationName); errorCount += checkNonEmpty(mbInfo); System.out.println("getMBeanInfo\t\t" + mbInfo); CompilationMXBean compilation = null ; compilation = JMX.newMXBeanProxy(mbsc, compilationName, CompilationMXBean.class) ; System.out.println("getName\t\t" + compilation.getName()); boolean supported = compilation.isCompilationTimeMonitoringSupported() ; System.out.println("isCompilationTimeMonitoringSupported\t\t" + supported); if ( supported ) { System.out.println("getTotalCompilationTime\t\t" + compilation.getTotalCompilationTime()); } } System.out.println("---- OK\n") ; } catch (Exception e) { Utils.printThrowable(e, true) ; errorCount++ ; System.out.println("---- ERROR\n") ; } return errorCount ; }
Example #28
Source File: ScanManager.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public ScanDirConfigMXBean createOtherConfigurationMBean(String name, String filename) throws JMException { final ScanDirConfig profile = new ScanDirConfig(filename); final ObjectName profName = makeScanDirConfigName(name); final ObjectInstance moi = mbeanServer.registerMBean(profile,profName); final ScanDirConfigMXBean proxy = JMX.newMXBeanProxy(mbeanServer,profName, ScanDirConfigMXBean.class,true); configmap.put(moi.getObjectName(),proxy); return proxy; }
Example #29
Source File: ScanManager.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public ScanDirConfigMXBean createOtherConfigurationMBean(String name, String filename) throws JMException { final ScanDirConfig profile = new ScanDirConfig(filename); final ObjectName profName = makeScanDirConfigName(name); final ObjectInstance moi = mbeanServer.registerMBean(profile,profName); final ScanDirConfigMXBean proxy = JMX.newMXBeanProxy(mbeanServer,profName, ScanDirConfigMXBean.class,true); configmap.put(moi.getObjectName(),proxy); return proxy; }
Example #30
Source File: MXBeanInteropTest1.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private final int doGarbageCollectorMXBeanTest(MBeanServerConnection mbsc) { int errorCount = 0 ; System.out.println("---- GarbageCollectorMXBean") ; try { ObjectName filterName = new ObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",*"); Set<ObjectName> onSet = mbsc.queryNames(filterName, null); for (Iterator<ObjectName> iter = onSet.iterator(); iter.hasNext(); ) { ObjectName garbageName = iter.next() ; System.out.println("-------- " + garbageName) ; MBeanInfo mbInfo = mbsc.getMBeanInfo(garbageName); errorCount += checkNonEmpty(mbInfo); System.out.println("getMBeanInfo\t\t" + mbInfo); GarbageCollectorMXBean garbage = null ; garbage = JMX.newMXBeanProxy(mbsc, garbageName, GarbageCollectorMXBean.class) ; System.out.println("getCollectionCount\t\t" + garbage.getCollectionCount()); System.out.println("getCollectionTime\t\t" + garbage.getCollectionTime()); } System.out.println("---- OK\n") ; } catch (Exception e) { Utils.printThrowable(e, true) ; errorCount++ ; System.out.println("---- ERROR\n") ; } return errorCount ; }