- java.lang.Object
-
- com.sun.management.GarbageCollectionNotificationInfo
-
- All Implemented Interfaces:
CompositeDataView
public class GarbageCollectionNotificationInfo extends Object implements CompositeDataView
Information about a garbage collection.A garbage collection notification is emitted by
GarbageCollectorMXBeanwhen the Java virtual machine completes a garbage collection action. The notification emitted will contain the garbage collection notification information about the status of the memory:- The name of the garbage collector used perform the collection.
- The action performed by the garbage collector.
- The cause of the garbage collection action.
- A
GcInfoobject containing some statistics about the GC cycle (start time, end time) and the memory usage before and after the GC cycle.
A
CompositeDatarepresenting theGarbageCollectionNotificationInfoobject is stored in the userdata of a notification. Thefrommethod is provided to convert from aCompositeDatato aGarbageCollectionNotificationInfoobject. For example:Notification notif; // receive the notification emitted by a GarbageCollectorMXBean and save in notif ... String notifType = notif.getType(); if (notifType.equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION)) { // retrieve the garbage collection notification information CompositeData cd = (CompositeData) notif.getUserData(); GarbageCollectionNotificationInfo info = GarbageCollectionNotificationInfo.from(cd); ... }The type of the notification emitted by a
GarbageCollectorMXBeanis:- A garbage collection notification.
Used by every notification emitted by the garbage collector, the details about the notification are provided in the action String.
-
-
Field Summary
Fields Modifier and Type Field Description static StringGARBAGE_COLLECTION_NOTIFICATIONNotification type denoting that the Java virtual machine has completed a garbage collection cycle.
-
Constructor Summary
Constructors Constructor Description GarbageCollectionNotificationInfo(String gcName, String gcAction, String gcCause, GcInfo gcInfo)Creates a newGarbageCollectionNotificationInfoinstance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static GarbageCollectionNotificationInfofrom(CompositeData cd)Returns aGarbageCollectionNotificationInfoobject represented by the givenCompositeData.StringgetGcAction()StringgetGcCause()GcInfogetGcInfo()StringgetGcName()CompositeDatatoCompositeData(CompositeType ct)Return theCompositeDatarepresentation of thisGarbageCollectionNotificationInfo.
-
-
-
Field Detail
-
GARBAGE_COLLECTION_NOTIFICATION
public static final String GARBAGE_COLLECTION_NOTIFICATION
Notification type denoting that the Java virtual machine has completed a garbage collection cycle. This notification is emitted by a GarbageCollectorMXBean. The value of this notification type is "com.ibm.lang.management.gc.notification" which matches RI naming for compatibility.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GarbageCollectionNotificationInfo
public GarbageCollectionNotificationInfo(String gcName, String gcAction, String gcCause, GcInfo gcInfo)
Creates a newGarbageCollectionNotificationInfoinstance.- Parameters:
gcName- the name of the garbage collector used to perform the collectiongcAction- the action of the performed by the garbage collectorgcCause- the cause the garbage collectiongcInfo- a GcInfo object providing statistics about the GC cycle
-
-
Method Detail
-
getGcName
public String getGcName()
- Returns:
- the name of the garbage collector used to perform the collection.
-
getGcAction
public String getGcAction()
- Returns:
- the action of the performed by the garbage collector
-
getGcCause
public String getGcCause()
- Returns:
- the cause of the garbage collection
-
getGcInfo
public GcInfo getGcInfo()
- Returns:
- the GC information related to the last garbage collection
-
from
public static GarbageCollectionNotificationInfo from(CompositeData cd)
Returns aGarbageCollectionNotificationInfoobject represented by the givenCompositeData. The givenCompositeDatamust contain the following attributes:CompositeData attributes Attribute Name Type gcName java.lang.StringgcAction java.lang.StringgcCause java.lang.StringgcInfo com.ibm.lang.management.GcInfo- Parameters:
cd-CompositeDatarepresenting aGarbageCollectionNotificationInfo- Returns:
- a
GarbageCollectionNotificationInfoobject represented bycdifcdis notnull;nullotherwise - Throws:
IllegalArgumentException- ifcddoes not represent aGarbageCollectionNotificationInfoobject
-
toCompositeData
public CompositeData toCompositeData(CompositeType ct)
Return the
CompositeDatarepresentation of thisGarbageCollectionNotificationInfo.- Specified by:
toCompositeDatain interfaceCompositeDataView- Parameters:
ct- theCompositeTypethat the caller expects. This parameter is ignored and can be null.- Returns:
- the
CompositeDatarepresentation.
-
-