javax.management.MBeanServerConnection#isRegistered ( )源码实例Demo

下面列出了javax.management.MBeanServerConnection#isRegistered ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dragonwell8_jdk   文件: MXBeanInteropTest1.java
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 ;
}
 
源代码2 项目: gemfirexd-oss   文件: MBeanTest.java
/**
 * Get the ObjectName for the application
 * created ManagementMBean. The MBean will be
 * created if it is not already registered.
 * @throws Exception
 */
protected ObjectName getApplicationManagementMBean() throws Exception
{
    /* prepare the Management mbean, which is (so far) the only MBean that
     * can be created/registered from a JMX client, and without knowing the
     * system identifier */
    final ObjectName mgmtObjName 
            = new ObjectName("com.pivotal.gemfirexd.internal", "type", "Management");
    // create/register the MBean. If the same MBean has already been
    // registered with the MBeanServer, that MBean will be referenced.
    //ObjectInstance mgmtObj = 
    final MBeanServerConnection serverConn = getMBeanServerConnection();
    
    if (!serverConn.isRegistered(mgmtObjName))
    {       
        AccessController.doPrivileged(
            new PrivilegedExceptionAction<Object>() {
                public Object run() throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, ReflectionException, MBeanException, IOException {
                    serverConn.createMBean(
                            "com.pivotal.gemfirexd.internal.mbeans.Management", 
                            mgmtObjName);
                    return null;
               }   
            }
        );
    }
    
    return mgmtObjName;
}
 
源代码3 项目: TencentKona-8   文件: AMXGlassfish.java
/**
Ensure that AMX is loaded and ready to use.  This method returns only when all
AMX subsystems have been loaded.
It can be called more than once without ill effect, subsequent calls are ignored.
@param conn connection to the MBeanServer
@return the ObjectName of the domain-root MBean
 */
public ObjectName bootAMX(final MBeanServerConnection conn)
    throws IOException
{
    final ObjectName domainRoot = domainRoot();

    if ( !conn.isRegistered( domainRoot ) )
    {
        // wait for the BootAMXMBean to be available (loads at startup)
        final BootAMXCallback callback = new BootAMXCallback(conn);
        listenForBootAMX(conn, callback);
        callback.await(); // block until the MBean appears

        invokeBootAMX(conn);

        final WaitForDomainRootListenerCallback drCallback = new WaitForDomainRootListenerCallback(conn);
        listenForDomainRoot(conn, drCallback);
        drCallback.await();

        invokeWaitAMXReady(conn, domainRoot);
    }
    else
    {
        invokeWaitAMXReady(conn, domainRoot );
    }
    return domainRoot;
}
 
源代码4 项目: TencentKona-8   文件: MBeanListener.java
private boolean isRegistered( final MBeanServerConnection conn, final ObjectName objectName )
{
    try
    {
        return conn.isRegistered(objectName);
    }
    catch (final Exception e)
    {
        throw new RuntimeException(e);
    }
}
 
源代码5 项目: jdk8u60   文件: AMXGlassfish.java
/**
Ensure that AMX is loaded and ready to use.  This method returns only when all
AMX subsystems have been loaded.
It can be called more than once without ill effect, subsequent calls are ignored.
@param conn connection to the MBeanServer
@return the ObjectName of the domain-root MBean
 */
public ObjectName bootAMX(final MBeanServerConnection conn)
    throws IOException
{
    final ObjectName domainRoot = domainRoot();

    if ( !conn.isRegistered( domainRoot ) )
    {
        // wait for the BootAMXMBean to be available (loads at startup)
        final BootAMXCallback callback = new BootAMXCallback(conn);
        listenForBootAMX(conn, callback);
        callback.await(); // block until the MBean appears

        invokeBootAMX(conn);

        final WaitForDomainRootListenerCallback drCallback = new WaitForDomainRootListenerCallback(conn);
        listenForDomainRoot(conn, drCallback);
        drCallback.await();

        invokeWaitAMXReady(conn, domainRoot);
    }
    else
    {
        invokeWaitAMXReady(conn, domainRoot );
    }
    return domainRoot;
}
 
源代码6 项目: jdk8u60   文件: MBeanListener.java
private boolean isRegistered( final MBeanServerConnection conn, final ObjectName objectName )
{
    try
    {
        return conn.isRegistered(objectName);
    }
    catch (final Exception e)
    {
        throw new RuntimeException(e);
    }
}
 
源代码7 项目: openjdk-8-source   文件: MBeanListener.java
private boolean isRegistered( final MBeanServerConnection conn, final ObjectName objectName )
{
    try
    {
        return conn.isRegistered(objectName);
    }
    catch (final Exception e)
    {
        throw new RuntimeException(e);
    }
}
 
源代码8 项目: openjdk-jdk8u   文件: AMXGlassfish.java
/**
Ensure that AMX is loaded and ready to use.  This method returns only when all
AMX subsystems have been loaded.
It can be called more than once without ill effect, subsequent calls are ignored.
@param conn connection to the MBeanServer
@return the ObjectName of the domain-root MBean
 */
public ObjectName bootAMX(final MBeanServerConnection conn)
    throws IOException
{
    final ObjectName domainRoot = domainRoot();

    if ( !conn.isRegistered( domainRoot ) )
    {
        // wait for the BootAMXMBean to be available (loads at startup)
        final BootAMXCallback callback = new BootAMXCallback(conn);
        listenForBootAMX(conn, callback);
        callback.await(); // block until the MBean appears

        invokeBootAMX(conn);

        final WaitForDomainRootListenerCallback drCallback = new WaitForDomainRootListenerCallback(conn);
        listenForDomainRoot(conn, drCallback);
        drCallback.await();

        invokeWaitAMXReady(conn, domainRoot);
    }
    else
    {
        invokeWaitAMXReady(conn, domainRoot );
    }
    return domainRoot;
}
 
源代码9 项目: openjdk-jdk8u   文件: MBeanListener.java
private boolean isRegistered( final MBeanServerConnection conn, final ObjectName objectName )
{
    try
    {
        return conn.isRegistered(objectName);
    }
    catch (final Exception e)
    {
        throw new RuntimeException(e);
    }
}
 
源代码10 项目: openjdk-jdk8u-backup   文件: MXBeanInteropTest1.java
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 ;
}
 
源代码11 项目: openjdk-jdk8u-backup   文件: AMXGlassfish.java
/**
Ensure that AMX is loaded and ready to use.  This method returns only when all
AMX subsystems have been loaded.
It can be called more than once without ill effect, subsequent calls are ignored.
@param conn connection to the MBeanServer
@return the ObjectName of the domain-root MBean
 */
public ObjectName bootAMX(final MBeanServerConnection conn)
    throws IOException
{
    final ObjectName domainRoot = domainRoot();

    if ( !conn.isRegistered( domainRoot ) )
    {
        // wait for the BootAMXMBean to be available (loads at startup)
        final BootAMXCallback callback = new BootAMXCallback(conn);
        listenForBootAMX(conn, callback);
        callback.await(); // block until the MBean appears

        invokeBootAMX(conn);

        final WaitForDomainRootListenerCallback drCallback = new WaitForDomainRootListenerCallback(conn);
        listenForDomainRoot(conn, drCallback);
        drCallback.await();

        invokeWaitAMXReady(conn, domainRoot);
    }
    else
    {
        invokeWaitAMXReady(conn, domainRoot );
    }
    return domainRoot;
}
 
源代码12 项目: openjdk-jdk8u-backup   文件: MBeanListener.java
private boolean isRegistered( final MBeanServerConnection conn, final ObjectName objectName )
{
    try
    {
        return conn.isRegistered(objectName);
    }
    catch (final Exception e)
    {
        throw new RuntimeException(e);
    }
}
 
源代码13 项目: openjdk-8   文件: MBeanListener.java
private boolean isRegistered( final MBeanServerConnection conn, final ObjectName objectName )
{
    try
    {
        return conn.isRegistered(objectName);
    }
    catch (final Exception e)
    {
        throw new RuntimeException(e);
    }
}
 
源代码14 项目: openjdk-jdk9   文件: AMXGlassfish.java
/**
Ensure that AMX is loaded and ready to use.  This method returns only when all
AMX subsystems have been loaded.
It can be called more than once without ill effect, subsequent calls are ignored.
@param conn connection to the MBeanServer
@return the ObjectName of the domain-root MBean
 */
public ObjectName bootAMX(final MBeanServerConnection conn)
    throws IOException
{
    final ObjectName domainRoot = domainRoot();

    if ( !conn.isRegistered( domainRoot ) )
    {
        // wait for the BootAMXMBean to be available (loads at startup)
        final BootAMXCallback callback = new BootAMXCallback(conn);
        listenForBootAMX(conn, callback);
        callback.await(); // block until the MBean appears

        invokeBootAMX(conn);

        final WaitForDomainRootListenerCallback drCallback = new WaitForDomainRootListenerCallback(conn);
        listenForDomainRoot(conn, drCallback);
        drCallback.await();

        invokeWaitAMXReady(conn, domainRoot);
    }
    else
    {
        invokeWaitAMXReady(conn, domainRoot );
    }
    return domainRoot;
}
 
源代码15 项目: openjdk-jdk9   文件: MBeanListener.java
private boolean isRegistered( final MBeanServerConnection conn, final ObjectName objectName )
{
    try
    {
        return conn.isRegistered(objectName);
    }
    catch (final Exception e)
    {
        throw new RuntimeException(e);
    }
}
 
源代码16 项目: jdk8u_jdk   文件: MXBeanInteropTest1.java
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 ;
}
 
源代码17 项目: hottub   文件: AMXGlassfish.java
/**
Ensure that AMX is loaded and ready to use.  This method returns only when all
AMX subsystems have been loaded.
It can be called more than once without ill effect, subsequent calls are ignored.
@param conn connection to the MBeanServer
@return the ObjectName of the domain-root MBean
 */
public ObjectName bootAMX(final MBeanServerConnection conn)
    throws IOException
{
    final ObjectName domainRoot = domainRoot();

    if ( !conn.isRegistered( domainRoot ) )
    {
        // wait for the BootAMXMBean to be available (loads at startup)
        final BootAMXCallback callback = new BootAMXCallback(conn);
        listenForBootAMX(conn, callback);
        callback.await(); // block until the MBean appears

        invokeBootAMX(conn);

        final WaitForDomainRootListenerCallback drCallback = new WaitForDomainRootListenerCallback(conn);
        listenForDomainRoot(conn, drCallback);
        drCallback.await();

        invokeWaitAMXReady(conn, domainRoot);
    }
    else
    {
        invokeWaitAMXReady(conn, domainRoot );
    }
    return domainRoot;
}
 
源代码18 项目: hottub   文件: MBeanListener.java
private boolean isRegistered( final MBeanServerConnection conn, final ObjectName objectName )
{
    try
    {
        return conn.isRegistered(objectName);
    }
    catch (final Exception e)
    {
        throw new RuntimeException(e);
    }
}
 
源代码19 项目: openjdk-8-source   文件: AMXGlassfish.java
/**
Ensure that AMX is loaded and ready to use.  This method returns only when all
AMX subsystems have been loaded.
It can be called more than once without ill effect, subsequent calls are ignored.
@param conn connection to the MBeanServer
@return the ObjectName of the domain-root MBean
 */
public ObjectName bootAMX(final MBeanServerConnection conn)
    throws IOException
{
    final ObjectName domainRoot = domainRoot();

    if ( !conn.isRegistered( domainRoot ) )
    {
        // wait for the BootAMXMBean to be available (loads at startup)
        final BootAMXCallback callback = new BootAMXCallback(conn);
        listenForBootAMX(conn, callback);
        callback.await(); // block until the MBean appears

        invokeBootAMX(conn);

        final WaitForDomainRootListenerCallback drCallback = new WaitForDomainRootListenerCallback(conn);
        listenForDomainRoot(conn, drCallback);
        drCallback.await();

        invokeWaitAMXReady(conn, domainRoot);
    }
    else
    {
        invokeWaitAMXReady(conn, domainRoot );
    }
    return domainRoot;
}
 
private MemoryStatistic collectMemoryStatistics(Map<String, String> options) throws Exception
{
    String host = options.get(JMX_HOST_ARG);
    String port = options.get(JMX_PORT_ARG);
    String user = options.get(JMX_USER_ARG);
    String password = options.get(JMX_USER_PASSWORD_ARG);

    if (!"".equals(host) && !"".equals(port) && !"".equals(user) && !"".equals(password))
    {
        Map<String, Object> environment = Collections.<String, Object>singletonMap(JMXConnector.CREDENTIALS, new String[]{user, password});

        try(JMXConnector jmxConnector = JMXConnectorFactory.newJMXConnector(new JMXServiceURL("rmi", "", 0, "/jndi/rmi://" + host + ":" + port + "/jmxrmi"), environment))
        {
            jmxConnector.connect();
            final MBeanServerConnection mBeanServerConnection = jmxConnector.getMBeanServerConnection();
            final ObjectName memoryMBean = new ObjectName("java.lang:type=Memory");
            String gcCollectorMBeanName = options.get(JMX_GARBAGE_COLLECTOR_MBEAN);
            if (gcCollectorMBeanName.equals(""))
            {
                mBeanServerConnection.invoke(memoryMBean, "gc", null, null);
                MemoryStatistic memoryStatistics = new MemoryStatistic();
                collectMemoryStatistics(memoryStatistics, mBeanServerConnection, memoryMBean);
                return memoryStatistics;
            }
            else
            {
                ObjectName gcMBean = new ObjectName(gcCollectorMBeanName);
                if (mBeanServerConnection.isRegistered(gcMBean))
                {
                    return collectMemoryStatisticsAfterGCNotification(mBeanServerConnection, gcMBean);
                }
                else
                {
                    Set<ObjectName> existingGCs = mBeanServerConnection.queryNames(new ObjectName("java.lang:type=GarbageCollector,name=*"), null);
                    throw new IllegalArgumentException("MBean '" +gcCollectorMBeanName + "' does not exists! Registered GC MBeans :" + existingGCs);
                }
            }
        }
    }
    return null;
}