Example usage for java.lang.management GarbageCollectorMXBean getObjectName

List of usage examples for java.lang.management GarbageCollectorMXBean getObjectName

Introduction

In this page you can find the example usage for java.lang.management GarbageCollectorMXBean getObjectName.

Prototype

public ObjectName getObjectName();

Source Link

Document

Returns an ObjectName ObjectName instance representing the object name of this platform managed object.

Usage

From source file:org.apache.hadoop.hbase.util.TestJSONMetricUtil.java

@Test
public void testGetLastGCInfo() {
    List<GarbageCollectorMXBean> gcBeans = ManagementFactory.getGarbageCollectorMXBeans();
    for (GarbageCollectorMXBean bean : gcBeans) {
        ObjectName on = bean.getObjectName();
        Object value = JSONMetricUtil.getValueFromMBean(on, "LastGcInfo");
        LOG.info("Collector Info: " + value);
        if (value != null && value instanceof CompositeData) {
            CompositeData cds = (CompositeData) value;
            assertNotNull(cds.get("duration"));
        }/*from w ww.j a  va2  s . c o m*/
    }
}