Package org.jppf.utils
Class ManagementUtils
java.lang.Object
org.jppf.utils.ManagementUtils
- Author:
- Laurent Cohen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectgetAttribute(MBeanServerConnection connection, String mbeanName, String attributeName) Get the given attribute of the given mbean via the specified mbean server connection.static MBeanServerGet the platform MBean server.static longgetThreadCpuTime(long threadID) Determien the CPU time for the specified thread.static longgetThreadUserTime(long threadID) Determien the user time for the specified thread.static booleanWhether CPU time measurement is enabled/supported.static booleanDetermine whether management is available for the current JVM.static booleanisMBeanRegistered(String mbeanName) Determine whether the MBean with the specified is already registered.static booleanisMBeanRegistered(String mbeanName, MBeanServer server) Determine whether the MBean with the specified is already registered.
-
Constructor Details
-
ManagementUtils
public ManagementUtils()
-
-
Method Details
-
getAttribute
public static Object getAttribute(MBeanServerConnection connection, String mbeanName, String attributeName) throws Exception Get the given attribute of the given mbean via the specified mbean server connection.- Parameters:
connection- the mbean server connection to use.mbeanName- the name of the mbean on which to invoke an attribute.attributeName- the name of the attribute to get.- Returns:
- the value of the attrribute, or
nullif management is not available. - Throws:
Exception- if any error occurs.
-
isManagementAvailable
public static boolean isManagementAvailable()Determine whether management is available for the current JVM.- Returns:
trueif management is available,falseotherwise.
-
getPlatformServer
Get the platform MBean server.- Returns:
- a
MBeanServerObject.
-
isMBeanRegistered
Determine whether the MBean with the specified is already registered.- Parameters:
mbeanName- the name of the MBean to check.- Returns:
trueif the MBean is registered,falseotherwise.- Throws:
Exception- if any error occurs.
-
isMBeanRegistered
Determine whether the MBean with the specified is already registered.- Parameters:
mbeanName- the name of the MBean to check.server- the MBean server to check.- Returns:
trueif the MBean is registered,falseotherwise.- Throws:
Exception- if any error occurs.
-
isCpuTimeEnabled
public static boolean isCpuTimeEnabled()Whether CPU time measurement is enabled/supported.- Returns:
trueif time measurement is enabled,falseotherwise.
-
getThreadCpuTime
public static long getThreadCpuTime(long threadID) Determien the CPU time for the specified thread.- Parameters:
threadID- the id of the thread.- Returns:
- the CPU time in nanoseconds, or -1L if the cpu time is not supported or could not be measured.
-
getThreadUserTime
public static long getThreadUserTime(long threadID) Determien the user time for the specified thread.- Parameters:
threadID- the id of the thread.- Returns:
- the user time in nanoseconds, or -1L if the user time is not supported or could not be measured.
-