- java.lang.Object
-
- com.sun.management.GarbageCollectionNotificationInfo
-
- All Implemented Interfaces:
CompositeDataView
public class GarbageCollectionNotificationInfo extends Object implements CompositeDataView
The information about a garbage collectionA garbage collection notification is emitted by
GarbageCollectorMXBean
when 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 to perform the collection.
- The action performed by the garbage collector.
- The cause of the garbage collection action.
- A
GcInfo
object containing some statistics about the GC cycle (start time, end time) and the memory usage before and after the GC cycle.
A
CompositeData
representing theGarbageCollectionNotificationInfo
object is stored in the userdata of a notification. Thefrom
method is provided to convert from aCompositeData
to aGarbageCollectionNotificationInfo
object. For example:Notification notif; // receive the notification emitted by a GarbageCollectorMXBean and set to 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
GarbageCollectorMXBean
is:- 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 String
GARBAGE_COLLECTION_NOTIFICATION
Notification 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)
Constructs aGarbageCollectionNotificationInfo
object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static GarbageCollectionNotificationInfo
from(CompositeData cd)
Returns aGarbageCollectionNotificationInfo
object represented by the givenCompositeData
.String
getGcAction()
Returns the action performed by the garbage collectorString
getGcCause()
Returns the cause of the garbage collectionGcInfo
getGcInfo()
Returns the GC information related to the last garbage collectionString
getGcName()
Returns the name of the garbage collector used to perform the collectionCompositeData
toCompositeData(CompositeType ct)
Return aCompositeData
corresponding to the values in this object.
-
-
-
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 aGarbageCollectorMXBean
. The value of this notification type iscom.sun.management.gc.notification
.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GarbageCollectionNotificationInfo
public GarbageCollectionNotificationInfo(String gcName, String gcAction, String gcCause, GcInfo gcInfo)
Constructs aGarbageCollectionNotificationInfo
object.- Parameters:
gcName
- The name of the garbage collector used to perform the collectiongcAction
- The name of the action performed by the garbage collectorgcCause
- The cause of the garbage collection actiongcInfo
- 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- Returns:
- the name of the garbage collector used to perform the collection
-
getGcAction
public String getGcAction()
Returns the action performed by the garbage collector- Returns:
- the action performed by the garbage collector
-
getGcCause
public String getGcCause()
Returns the cause of the garbage collection- Returns:
- the cause of the garbage collection
-
getGcInfo
public GcInfo getGcInfo()
Returns the GC information related to the last garbage collection- Returns:
- the GC information related to the last garbage collection
-
from
public static GarbageCollectionNotificationInfo from(CompositeData cd)
Returns aGarbageCollectionNotificationInfo
object represented by the givenCompositeData
. The givenCompositeData
must contain the following attributes:Attribute Name Type gcName java.lang.String
gcAction java.lang.String
gcCause java.lang.String
gcInfo javax.management.openmbean.CompositeData
- Parameters:
cd
-CompositeData
representing aGarbageCollectionNotificationInfo
- Returns:
- a
GarbageCollectionNotificationInfo
object represented bycd
ifcd
is notnull
;null
otherwise. - Throws:
IllegalArgumentException
- ifcd
does not represent aGarbaageCollectionNotificationInfo
object.
-
toCompositeData
public CompositeData toCompositeData(CompositeType ct)
Description copied from interface:CompositeDataView
Return a
CompositeData
corresponding to the values in this object. The returned value should usually be an instance ofCompositeDataSupport
, or a class that serializes as aCompositeDataSupport
via awriteReplace
method. Otherwise, a remote client that receives the object might not be able to reconstruct it.- Specified by:
toCompositeData
in interfaceCompositeDataView
- Parameters:
ct
- The expectedCompositeType
of the returned value. If the returned value iscd
, thencd.getCompositeType().equals(ct)
should be true. Typically this will be becausecd
is aCompositeDataSupport
constructed withct
as itsCompositeType
.- Returns:
- the
CompositeData
.
-
-