Package org.jppf.utils
Class SystemUtils
java.lang.Object
org.jppf.utils.SystemUtils
Collection of utility methods used as a convenience for retrieving
JVM-level or System-level information.
- Author:
- Laurent Cohen
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanDetermine whether 2 objects are equal.static TypedPropertiesGet a map of the environment variables.static TypedPropertiesGet a map of the environment variables.static TypedPropertiesgetOS()Get the available physical ram information for the local machine.static doublestatic intgetPID()static TypedPropertiesGet information about the number of processors available to the JVM and the JVM memory usage.static TypedPropertiesGet storage information about the file system roots available on the current host.static StringGet a name for an object in the form class_fqn@hex_identity_hashcode.static StringGet a name for an object in the form simple_class_name@hex_identity_hashcode.static TypedPropertiesReturn a set of properties guaranteed to always be part of those returned bySystem.getProperties().static longstatic longCompute the used heap.static doubleCompute the percentage of used heap as compared to the maximum heap size of the JVM.static booleanisMac()Determine whether the current OS is Mac-based.static <T> booleanisOneOf(T value, T... possibles) Determine whether the specified value is one of the possibles.static booleanDetermine whether the current OS is Windows.static booleanisX11()Determine whether the current OS is X11-based.static longCompute the maximum memory currently available for the Java heap.static voidprintPidAndUuid(String component, String uuid) Prints the JPPF process id and uuid toSystem.out.static StringPrint the system properties to a string.
-
Method Details
-
getSystemProperties
Return a set of properties guaranteed to always be part of those returned bySystem.getProperties().- Returns:
- the properties as a
TypedPropertiesinstance.
-
getRuntimeInformation
Get information about the number of processors available to the JVM and the JVM memory usage.- Returns:
- a
TypedPropertiesinstance holding the requested information.
-
getStorageInformation
Get storage information about the file system roots available on the current host. This method populates aTypedPropertiesobject with root name, free space, total space and usable space information for each root.An example root name would be "C:\" for a Windows system and "/" for a Unix system.
- Returns:
- TypedProperties object with storage information.
-
getEnvironment
Get a map of the environment variables.- Returns:
- a mapping of environment variables to their value.
-
getNetwork
Get a map of the environment variables.- Returns:
- a mapping of environment variables to their value.
-
maxFreeHeap
public static long maxFreeHeap()Compute the maximum memory currently available for the Java heap.- Returns:
- the maximum number of free bytes in the heap.
-
heapUsage
public static long heapUsage()Compute the used heap.- Returns:
- the heap memory used in bytes.
-
heapUsagePct
public static double heapUsagePct()Compute the percentage of used heap as compared to the maximum heap size of the JVM.- Returns:
- the percentage of heap memory used.
-
isWindows
public static boolean isWindows()Determine whether the current OS is Windows.- Returns:
- true if the system is Windows, false otherwise.
-
isX11
public static boolean isX11()Determine whether the current OS is X11-based.- Returns:
- true if the system is X11, false otherwise.
-
isMac
public static boolean isMac()Determine whether the current OS is Mac-based.- Returns:
- true if the system is Mac-based, false otherwise.
-
getPID
public static int getPID()- Returns:
- the current process pid as an int, or -1 if the pid could not be obtained.
-
printPidAndUuid
Prints the JPPF process id and uuid toSystem.out.- Parameters:
component- the JPPF component type: driver, node or client.uuid- the component uuid.
-
getOS
Get the available physical ram information for the local machine.- Returns:
- the memory information eelements as a
TypedPropertiesinstance.
-
getUsedMemory
public static long getUsedMemory()- Returns:
- the currently used heap memory.
-
getPctUsedMemory
public static double getPctUsedMemory()- Returns:
- the currently used heap memory.
-
isOneOf
Determine whether the specified value is one of the possibles.- Type Parameters:
T- the type of values to check.- Parameters:
value- the value to compare.possibles- the possible values to compare with- Returns:
trueif value is one of the possibe values,falseotherwise.
-
printSystemProperties
Print the system properties to a string.- Returns:
- the system properties printed one per line.
-
getSystemIdentityName
Get a name for an object in the form simple_class_name@hex_identity_hashcode.- Parameters:
o- the object for which to get a name.- Returns:
- the object's identity name.
-
getSystemIdentity
Get a name for an object in the form class_fqn@hex_identity_hashcode.- Parameters:
o- the object for which to get a name.- Returns:
- the object's identity name.
-
areEqual
Determine whether 2 objects are equal.- Parameters:
o1- the first object.o2- the second object.- Returns:
trueif the 2 objects are equal,falseotherwise.
-