Java Code Examples for java.lang.management.ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE

The following are Jave code examples for showing how to use GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE of the java.lang.management.ManagementFactory 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: jdk8u-jdk   File: MXBeanInteropTest1.java   View Source Code Vote up 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 2
Project: openjdk-jdk10   File: MXBeanInteropTest1.java   View Source Code Vote up 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 ;
}