Class JvmCpuMonitor

java.lang.Object
com.ibm.lang.management.internal.JvmCpuMonitor
All Implemented Interfaces:
JvmCpuMonitorMXBean, PlatformManagedObject

public class JvmCpuMonitor extends Object implements JvmCpuMonitorMXBean
Runtime type for JvmCpuMonitorMXBean.

Implements getting CPU Usage for various JVM thread categories.

  • Constructor Details

    • JvmCpuMonitor

      public JvmCpuMonitor()
  • Method Details

    • getInstance

      public static JvmCpuMonitor getInstance()
      Singleton accessor method. Returns an instance of JvmCpuMonitor
      Returns:
      a static instance of JvmCpuMonitor
    • getObjectName

      public ObjectName getObjectName()
      Returns the object name of the MXBean
      Specified by:
      getObjectName in interface PlatformManagedObject
      Returns:
      objectName representing the MXBean
    • getThreadsCpuUsage

      public JvmCpuMonitorInfo getThreadsCpuUsage(JvmCpuMonitorInfo jcmInfo)
      This function updates the user provided JvmCpuMonitorInfo object with CPU usage statistics of the various thread categories. The statistics are an aggregate across all CPUs of the operating system.
      Specified by:
      getThreadsCpuUsage in interface JvmCpuMonitorMXBean
      Parameters:
      jcmInfo - User provided JvmCpuMonitorInfo object.
      Returns:
      the updated JvmCpuMonitorInfo instance.
    • getThreadsCpuUsage

      public JvmCpuMonitorInfo getThreadsCpuUsage()
      This function creates a new JvmCpuMonitorInfo object and populates it with CPU usage statistics of the various thread categories. The statistics are an aggregate across all CPUs of the operating system.
      Specified by:
      getThreadsCpuUsage in interface JvmCpuMonitorMXBean
      Returns:
      the new JvmCpuMonitorInfo instance.
    • setThreadCategory

      public int setThreadCategory(long id, String category)
      This function sets the thread category of the target thread. Valid categories are
      1. "Resource-Monitor"
      2. "Application"
      3. "Application-User1" through to "Application-User5"
      Some notes on the setting the thread categories
      1. "Application" threads cannot be changed to any "System-JVM" category.
      2. Threads in the "System-JVM" category cannot be modified.
      3. Once a thread is designated as "Resource-Monitor", it cannot be changed.
      Specified by:
      setThreadCategory in interface JvmCpuMonitorMXBean
      Parameters:
      id - The target thread id for which the type needs to be set.
      category - The category of the target thread.
      Returns:
      -1 to indicate failure or 0 on success.
    • getThreadCategory

      public String getThreadCategory(long id)
      This function gets the current value of the thread category for the target thread.
      Specified by:
      getThreadCategory in interface JvmCpuMonitorMXBean
      Parameters:
      id - The target thread id for which we need the thread category.
      Returns:
      NULL to indicate failure, else the category string of the target thread.