Java Code Examples for javax.management.JMX
The following examples show how to use
javax.management.JMX.
These examples are extracted from open source projects.
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 Project: openjdk-jdk8u-backup Author: AdoptOpenJDK File: TestUtils.java License: 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 #2
Source Project: openjdk-8 Author: bpupadhyaya File: ExceptionDiagnosisTest.java License: 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 #3
Source Project: dragonwell8_jdk Author: alibaba File: ExceptionDiagnosisTest.java License: 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 #4
Source Project: jdk8u_jdk Author: JetBrains File: JMXProxyFallbackTest.java License: 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 #5
Source Project: TencentKona-8 Author: Tencent File: JMXProxyFallbackTest.java License: 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 #6
Source Project: openjdk-8-source Author: keerath File: JMXProxyFallbackTest.java License: 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 Project: scheduling Author: ow2-proactive File: SchedulerRuntimeDataMBeanTest.java License: 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 #8
Source Project: java-technology-stack Author: codeEngraver File: MBeanClientInterceptor.java License: 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 #9
Source Project: jdk8u60 Author: chenghanpeng File: TestUtils.java License: 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 Project: jdk8u-jdk Author: frohoff File: JMXProxyFallbackTest.java License: 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 Project: jdk8u60 Author: chenghanpeng File: ExceptionDiagnosisTest.java License: 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 Project: spring-analysis-note Author: Vip-Augus File: JmxUtils.java License: MIT License | 5 votes |
/** * Return the Java 6 MXBean interface exists for the given class, if any * (that is, an interface whose name ends with "MXBean" and/or * carries an appropriate MXBean annotation). * @param clazz the class to check * @return whether there is an MXBean interface for the given class */ @Nullable public static Class<?> getMXBeanInterface(@Nullable Class<?> clazz) { if (clazz == null || clazz.getSuperclass() == null) { return null; } Class<?>[] implementedInterfaces = clazz.getInterfaces(); for (Class<?> iface : implementedInterfaces) { if (JMX.isMXBeanInterface(iface)) { return iface; } } return getMXBeanInterface(clazz.getSuperclass()); }
Example #13
Source Project: stratio-cassandra Author: Stratio File: NodeProbe.java License: Apache License 2.0 | 5 votes |
public EndpointSnitchInfoMBean getEndpointSnitchInfoProxy() { try { return JMX.newMBeanProxy(mbeanServerConn, new ObjectName("org.apache.cassandra.db:type=EndpointSnitchInfo"), EndpointSnitchInfoMBean.class); } catch (MalformedObjectNameException e) { throw new RuntimeException(e); } }
Example #14
Source Project: dragonwell8_jdk Author: alibaba File: ScanManager.java License: 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 #15
Source Project: openjdk-jdk8u Author: AdoptOpenJDK File: ScanManager.java License: 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 #16
Source Project: cassandra-reaper Author: thelastpickle File: ColumnFamilyStoreMBeanIterator.java License: Apache License 2.0 | 5 votes |
@Override public Map.Entry<String, ColumnFamilyStoreMBean> next() { ObjectName objectName = resIter.next(); String keyspaceName = objectName.getKeyProperty("keyspace"); ColumnFamilyStoreMBean cfsProxy = JMX.newMBeanProxy(mbeanServerConn, objectName, ColumnFamilyStoreMBean.class); return new AbstractMap.SimpleImmutableEntry<>(keyspaceName, cfsProxy); }
Example #17
Source Project: openjdk-jdk8u Author: AdoptOpenJDK File: RandomMXBeanTest.java License: 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 #18
Source Project: streamsx.topology Author: IBMStreams File: Resetter.java License: Apache License 2.0 | 5 votes |
@Override public void setup(MBeanServerConnection mbs, OperatorContext context) throws InstanceNotFoundException, Exception { seq.increment(); ObjectName consistentWildcard = ObjectName.getInstance("com.ibm.streams.control:type=consistent,index=*"); Set<ObjectName> regions = mbs.queryNames(consistentWildcard, null); if (regions.isEmpty()) { fail.setValue(1); trace.severe("No consistent regions!"); return; } for (ObjectName name : regions) { ConsistentRegionMXBean crbean = JMX.newMXBeanProxy(mbs, name, ConsistentRegionMXBean.class, true); if (trace.isLoggable(Level.FINE)) trace.fine("Discovered consistent region: " + crbean.getName()); String metricName = "nResets." + crbean.getName(); Metric resetCount; try { resetCount = context.getMetrics().createCustomMetric(metricName, "Requested resets for region", Metric.Kind.COUNTER); } catch (IllegalArgumentException e) { resetCount = context.getMetrics().getCustomMetric(metricName); } resetCounts.add(resetCount); scheduleReset(crbean, resetCount); seq.increment(); } }
Example #19
Source Project: jdk8u_jdk Author: JetBrains File: MXBeanInteropTest1.java License: 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 #20
Source Project: dragonwell8_jdk Author: alibaba File: RandomMXBeanTest.java License: 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 Project: openjdk-jdk8u Author: AdoptOpenJDK File: MXBeanInteropTest1.java License: 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 ; }
Example #22
Source Project: javasimon Author: virgo47 File: MonitoringClient.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Entry point to this monitoring client. * * @param args host:port part of the JMX connector server * @throws java.io.IOException thrown in case of some I/O exception * @throws javax.management.MalformedObjectNameException thrown when the name of the JMX object is incorrect */ public static void main(String[] args) throws IOException, MalformedObjectNameException { final JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + args[0] + "/jmxrmi"); // final Map<String, String[]> env = new HashMap<String, String[]>(); // env.put(JMXConnector.CREDENTIALS, new String[]{login, pass}); JMXConnector jmxc = JMXConnectorFactory.connect(url, null); MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); SimonManagerMXBean simonManagerMXBean = JMX.newMXBeanProxy(mbsc, new ObjectName("org.javasimon.jmx.example:type=Simon"), SimonManagerMXBean.class); System.out.println("List of retrieved Simons:"); for (String n : simonManagerMXBean.getSimonNames()) { System.out.println(" " + n); } System.out.println("List of stopwatch Simons:"); for (SimonInfo si : simonManagerMXBean.getSimonInfos()) { if (si.getType().equals(SimonInfo.STOPWATCH)) { System.out.println(" " + si.getName()); } } simonManagerMXBean.printSimonTree(); jmxc.close(); }
Example #23
Source Project: dragonwell8_jdk Author: alibaba File: MXBeanInteropTest1.java License: GNU General Public License v2.0 | 5 votes |
private final int doMemoryMXBeanTest(MBeanServerConnection mbsc) { int errorCount = 0 ; System.out.println("---- MemoryMXBean") ; try { ObjectName memoryName = new ObjectName(ManagementFactory.MEMORY_MXBEAN_NAME) ; MBeanInfo mbInfo = mbsc.getMBeanInfo(memoryName); errorCount += checkNonEmpty(mbInfo); System.out.println("getMBeanInfo\t\t" + mbInfo); MemoryMXBean memory = null ; memory = JMX.newMXBeanProxy(mbsc, memoryName, MemoryMXBean.class, true) ; System.out.println("getMemoryHeapUsage\t\t" + memory.getHeapMemoryUsage()); System.out.println("getNonHeapMemoryHeapUsage\t\t" + memory.getNonHeapMemoryUsage()); System.out.println("getObjectPendingFinalizationCount\t\t" + memory.getObjectPendingFinalizationCount()); System.out.println("isVerbose\t\t" + memory.isVerbose()); System.out.println("---- OK\n") ; } catch (Exception e) { Utils.printThrowable(e, true) ; errorCount++ ; System.out.println("---- ERROR\n") ; } return errorCount ; }
Example #24
Source Project: openjdk-8-source Author: keerath File: ScanManager.java License: 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 #25
Source Project: hottub Author: dsrg-uoft File: ScanManager.java License: 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 #26
Source Project: jdk8u-jdk Author: lambdalab-mirror File: MXBeanInteropTest1.java License: 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 Project: stratio-cassandra Author: Stratio File: NodeProbe.java License: Apache License 2.0 | 5 votes |
private List<Entry<String, ColumnFamilyStoreMBean>> getCFSMBeans(MBeanServerConnection mbeanServerConn, String type) throws MalformedObjectNameException, IOException { ObjectName query = new ObjectName("org.apache.cassandra.db:type=" + type +",*"); Set<ObjectName> cfObjects = mbeanServerConn.queryNames(query, null); List<Entry<String, ColumnFamilyStoreMBean>> mbeans = new ArrayList<Entry<String, ColumnFamilyStoreMBean>>(cfObjects.size()); for(ObjectName n : cfObjects) { String keyspaceName = n.getKeyProperty("keyspace"); ColumnFamilyStoreMBean cfsProxy = JMX.newMBeanProxy(mbeanServerConn, n, ColumnFamilyStoreMBean.class); mbeans.add(new AbstractMap.SimpleImmutableEntry<String, ColumnFamilyStoreMBean>(keyspaceName, cfsProxy)); } return mbeans; }
Example #28
Source Project: stratio-cassandra Author: Stratio File: NodeProbe.java License: Apache License 2.0 | 5 votes |
public Map.Entry<String, JMXEnabledThreadPoolExecutorMBean> next() { ObjectName objectName = resIter.next(); String poolName = objectName.getKeyProperty("type"); JMXEnabledThreadPoolExecutorMBean threadPoolProxy = JMX.newMBeanProxy(mbeanServerConn, objectName, JMXEnabledThreadPoolExecutorMBean.class); return new AbstractMap.SimpleImmutableEntry<String, JMXEnabledThreadPoolExecutorMBean>(poolName, threadPoolProxy); }
Example #29
Source Project: cassandra-mesos-deprecated Author: mesosphere File: ProdJmxConnect.java License: 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 #30
Source Project: gemfirexd-oss Author: gemxd File: JmxOperationInvoker.java License: 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); } }