Search in sources :

Example 1 with GarbageCollectorMXBeanImpl

use of com.ibm.java.lang.management.internal.GarbageCollectorMXBeanImpl in project openj9 by eclipse.

the class MemoryNotificationThread method dispatchGCNotificationHelper.

/**
 * A helper used by processNotificationLoop to construct and dispatch
 * garbage collection notification objects
 *
 * @param gcName
 *            the name of garbage collector which we are sending notifications on behalf of
 * @param gcAction
 *            the action of the performed by the garbage collector
 * @param gcCause
 *            the cause the garbage collection
 * @param index
 *            the identifier of this garbage collection which is the number of collections that this collector has done
 * @param startTime
 *            the start time of this GC in milliseconds since the Java virtual machine was started
 * @param endTime
 *            the end time of this GC in milliseconds since the Java virtual machine was started
 * @param poolNames
 *            the name of all memory pools (includes non-heap memory pools)
 * @param initialSize
 *            the initial amount of memory of all memory pools
 * @param preUsed
 *            the amounts of memory used of all memory pools before the garbage collection
 * @param preCommitted
 *            the amounts of all memory pools that is guaranteed to be available for use before the garbage collection
 * @param preMax
 *            the maximum amounts of memory pools that can be used before the garbage collection
 * @param postUsed
 *            the amounts of memory used of all memory pools after the garbage collection
 * @param postCommitted
 *            the amounts of all memory pools that is guaranteed to be available for use after the garbage collection
 * @param postMax
 *            the maximum amounts of memory pools that can be used after the garbage collection
 * @param sequenceNumber
 *            the sequence identifier of the current notification
 */
private void dispatchGCNotificationHelper(String gcName, String gcAction, String gcCause, long index, long startTime, long endTime, String[] poolNames, long[] initialSize, long[] preUsed, long[] preCommitted, long[] preMax, long[] postUsed, long[] postCommitted, long[] postMax, long sequenceNumber) {
    GcInfo gcInfo = ExtendedGarbageCollectorMXBeanImpl.buildGcInfo(index, startTime, endTime, poolNames, initialSize, preUsed, preCommitted, preMax, postUsed, postCommitted, postMax);
    GarbageCollectionNotificationInfo info = new GarbageCollectionNotificationInfo(gcName, gcAction, gcCause, gcInfo);
    for (MemoryManagerMXBean bean : memBean.getMemoryManagerMXBeans(false)) {
        if (bean instanceof GarbageCollectorMXBeanImpl && bean.getName().equals(gcName)) {
            Notification notification = new Notification(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION, // $NON-NLS-1$
            "java.lang:type=GarbageCollector", sequenceNumber);
            notification.setUserData(GarbageCollectionNotificationInfoUtil.toCompositeData(info));
            ((GarbageCollectorMXBeanImpl) bean).sendNotification(notification);
            break;
        }
    }
}
Also used : GarbageCollectionNotificationInfo(com.sun.management.GarbageCollectionNotificationInfo) GcInfo(com.sun.management.GcInfo) GarbageCollectorMXBeanImpl(com.ibm.java.lang.management.internal.GarbageCollectorMXBeanImpl) MemoryManagerMXBean(java.lang.management.MemoryManagerMXBean) Notification(javax.management.Notification)

Example 2 with GarbageCollectorMXBeanImpl

use of com.ibm.java.lang.management.internal.GarbageCollectorMXBeanImpl in project openj9 by eclipse.

the class MemoryNotificationThread method dispatchGCNotificationHelper.

/**
 * A helper used by processNotificationLoop to construct and dispatch
 * garbage collection notification objects
 *
 * @param gcName
 *            the name of garbage collector which we are sending notifications on behalf of
 * @param gcAction
 *            the action of the performed by the garbage collector
 * @param gcCause
 *            the cause the garbage collection
 * @param index
 *            the identifier of this garbage collection which is the number of collections that this collector has done
 * @param startTime
 *            the start time of this GC in milliseconds since the Java virtual machine was started
 * @param endTime
 *            the end time of this GC in milliseconds since the Java virtual machine was started
 * @param initialSize
 *            the initial amount of memory of all memory pools
 * @param preUsed
 *            the amounts of memory used of all memory pools before the garbage collection
 * @param preCommitted
 *            the amounts of all memory pools that is guaranteed to be available for use before the garbage collection
 * @param preMax
 *            the maximum amounts of memory pools that can be used before the garbage collection
 * @param postUsed
 *            the amounts of memory used of all memory pools after the garbage collection
 * @param postCommitted
 *            the amounts of all memory pools that is guaranteed to be available for use after the garbage collection
 * @param postMax
 *            the maximum amounts of memory pools that can be used after the garbage collection
 * @param sequenceNumber
 *            the sequence identifier of the current notification
 */
private void dispatchGCNotificationHelper(String gcName, String gcAction, String gcCause, long index, long startTime, long endTime, long[] initialSize, long[] preUsed, long[] preCommitted, long[] preMax, long[] postUsed, long[] postCommitted, long[] postMax, long sequenceNumber) {
    GcInfo gcInfo = ExtendedGarbageCollectorMXBeanImpl.buildGcInfo(index, startTime, endTime, initialSize, preUsed, preCommitted, preMax, postUsed, postCommitted, postMax);
    GarbageCollectionNotificationInfo info = new GarbageCollectionNotificationInfo(gcName, gcAction, gcCause, gcInfo);
    for (MemoryManagerMXBean bean : memBean.getMemoryManagerMXBeans(false)) {
        if (bean instanceof GarbageCollectorMXBeanImpl && bean.getName().equals(gcName)) {
            Notification notification = new Notification(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION, // $NON-NLS-1$
            "java.lang:type=GarbageCollector", sequenceNumber);
            notification.setUserData(GarbageCollectionNotificationInfoUtil.toCompositeData(info));
            ((GarbageCollectorMXBeanImpl) bean).sendNotification(notification);
            break;
        }
    }
}
Also used : GarbageCollectionNotificationInfo(com.sun.management.GarbageCollectionNotificationInfo) GcInfo(com.sun.management.GcInfo) GarbageCollectorMXBeanImpl(com.ibm.java.lang.management.internal.GarbageCollectorMXBeanImpl) MemoryManagerMXBean(java.lang.management.MemoryManagerMXBean) Notification(javax.management.Notification)

Aggregations

GarbageCollectorMXBeanImpl (com.ibm.java.lang.management.internal.GarbageCollectorMXBeanImpl)2 GarbageCollectionNotificationInfo (com.sun.management.GarbageCollectionNotificationInfo)2 GcInfo (com.sun.management.GcInfo)2 MemoryManagerMXBean (java.lang.management.MemoryManagerMXBean)2 Notification (javax.management.Notification)2