Package edu.wisc.ssec.mcidasv.util
Class SystemState
java.lang.Object
edu.wisc.ssec.mcidasv.util.SystemState
Utility methods for querying the state of the user's machine.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.LoggerHandy logging object. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringescapeWhitespaceChars(CharSequence sequence) Returns a mapping of display number to aRectanglethat represents the "bounds" of the display.static StringGets a human-friendly representation of the information embedded within IDV'sbuild.properties.Return McIDAS-V's classpath.private static StringgetMcvJarname(String jarDir) Determine the actual name of the McIDAS-V JAR file.static StringGets a human-friendly representation of the information embedded within McIDAS-V'sbuild.properties.static StringGets a human-friendly representation of the ncIdv.jar version information.static StringgetStateAsString(McIDASV mcv) Builds a (filtered) subset of the McIDAS-V system properties and returns the results as aString.static StringgetStateAsString(McIDASV mcv, boolean firehose) Builds the McIDAS-V system properties and returns the results as aString.static Rectanglestatic StringGets a human-friendly representation of the version information embedded within VisAD's "DATE" file.Returns aMapof the (currently) most useful contents ofucar/unidata/idv/resources/build.properties.Polls Java 3D for information about its environment.Returns the contents of Jython's registry (basically just Jython-specific properties) as well as some of the information from Python's "sys" module.Polls Java for information about the user's machine.Returns aMapof the (currently) most useful contents ofedu/wisc/ssec/mcidasv/resources/build.properties.queryMcvState(McIDASV mcv) Queries McIDAS-V for information about its state.Attempts to call methods belonging tocom.sun.management.OperatingSystemMXBean.private static <T> TqueryPlatformBean(String attrName, T defaultValue) Query anOperatingSystemMXBeanattribute and return the result.Returns aMapcontaining any relevant version information.private static InputStreamresourceAsStream(String name) Open a file for reading.
-
Field Details
-
logger
Handy logging object.
-
-
Constructor Details
-
SystemState
private SystemState()
-
-
Method Details
-
escapeWhitespaceChars
-
queryPlatformBean
Query anOperatingSystemMXBeanattribute and return the result.- Type Parameters:
T- Type of the expected return value anddefaultValue.- Parameters:
attrName- Name of theOperatingSystemMXBeanattribute to query. Cannot benullor empty.defaultValue- Value returned ifattrNamecould not be queried.- Returns:
- Either the value corresponding to
attrNameordefaultValue.
-
queryJythonProps
Returns the contents of Jython's registry (basically just Jython-specific properties) as well as some of the information from Python's "sys" module.- Returns:
- Jython's configuration settings.
-
queryOpSysProps
Attempts to call methods belonging tocom.sun.management.OperatingSystemMXBean. If successful, we'll have the following information:- opsys.memory.virtual.committed: virtual memory that is guaranteed to be available
- opsys.memory.swap.total: total amount of swap space in bytes
- opsys.memory.swap.free: free swap space in bytes
- opsys.cpu.time: CPU time used by the process (nanoseconds)
- opsys.memory.physical.free: free physical memory in bytes
- opsys.memory.physical.total: physical memory in bytes
- opsys.load: system load average for the last minute
- Returns:
- Map of properties that contains interesting information about the hardware McIDAS-V is using.
-
queryMachine
Polls Java for information about the user's machine. We're specifically after memory statistics, number of processors, and display information.- Returns:
Mapof properties that describes the user's machine.
-
getDisplayBounds
Returns a mapping of display number to aRectanglethat represents the "bounds" of the display.- Returns:
- Rectangles representing the "bounds" of the current display devices.
-
getVirtualDisplayBounds
-
queryJava3d
Polls Java 3D for information about its environment. Specifically, we callVirtualUniverse.getProperties()andCanvas3D.queryProperties().- Returns:
- As much information as Java 3D can provide.
-
getIdvVersionString
Gets a human-friendly representation of the information embedded within IDV'sbuild.properties.- Returns:
Stringthat looks like "IDV version major.minor<b>revision</b> built <b>date</b>". For example:IDV version 2.9u4 built 2011-04-13 14:01 UTC.
-
getMcvVersionString
Gets a human-friendly representation of the information embedded within McIDAS-V'sbuild.properties.- Returns:
Stringthat looks like "McIDAS-V version major.minor<b>release</b> built <b>date</b>". For example:McIDAS-V version 1.02beta1 built 2011-04-14 17:36.
-
getVisadVersionString
Gets a human-friendly representation of the version information embedded within VisAD's "DATE" file.- Returns:
Stringthat looks "VisAD version <b>revision</b> built <b>date</b>". For example:VisAD version 5952 built Thu Mar 22 13:01:31 CDT 2012.
-
getNcidvVersionString
Gets a human-friendly representation of the ncIdv.jar version information.- Returns:
Stringthat looks like "netCDF-Java version <b>revision</b> <b>built</b>".
-
resourceAsStream
Open a file for reading.- Parameters:
name- File to open.- Returns:
InputStreamused to readname, ornullifnamecould not be found.
-
queryVisadBuildProperties
Returns aMapcontaining any relevant version information.Currently this information consists of the date visad.jar was built, as well as the (then-current) Subversion revision number.
- Returns:
Mapof the contents of VisAD's DATE file.
-
getMcvJarname
Determine the actual name of the McIDAS-V JAR file.This is needed because we're now following the Maven naming convention, and this means that "mcidasv.jar" no longer exists.
- Parameters:
jarDir- Directory containing all of the McIDAS-V JARs. Cannot benull.- Returns:
- Name (note: not path) of the McIDAS-V JAR file.
- Throws:
IOException- if there was a problem locating the McIDAS-V JAR.
-
getMcvJarClasspath
Return McIDAS-V's classpath.This may differ from what is reported by
System.getProperty("java.class.path"). This is because McIDAS-V specifies its classpath usingMETA-INF/MANIFEST.MFinmcidasv.jar.This is used by console_init.py to figure out where the VisAD, IDV, and McIDAS-V JAR files are located.
- Returns:
- Either a list of strings containing the path to each JAR file in the classpath, or an empty list.
-
queryNcidvBuildProperties
- Returns:
Mapcontaining netCDF-Java version and build date.
-
queryIdvBuildProperties
Returns aMapof the (currently) most useful contents ofucar/unidata/idv/resources/build.properties.Consider the output of
getIdvVersionString(); it's built with the the following:idv.version.major: currently "3"idv.version.minor: currently "0"idv.version.revision: currently "u2"}idv.build.date: varies pretty frequently, as it's the build timestamp for idv.jar
- Returns:
- A
Mapof at least the useful parts of build.properties.
-
queryMcvBuildProperties
Returns aMapof the (currently) most useful contents ofedu/wisc/ssec/mcidasv/resources/build.properties.Consider the output of
getMcvVersionString(); it's built with the the following:mcidasv.version.major: currently "1"mcidasv.version.minor: currently "02"mcidasv.version.release: currently "beta1"mcidasv.build.date: varies pretty frequently, as it's the build timestamp for mcidasv.jar.
- Returns:
- A
Mapof at least the useful parts of build.properties.
-
queryMcvState
Queries McIDAS-V for information about its state. There's not a good way to characterize what we're interested in, so let's leave it at "whatever seems useful".- Parameters:
mcv- The McIDASV "god" object.- Returns:
- Information about the state of McIDAS-V.
-
getStateAsString
Builds a (filtered) subset of the McIDAS-V system properties and returns the results as aString.- Parameters:
mcv- The McIDASV "god" object.- Returns:
- The McIDAS-V system properties in the following format:
KEY=VALUE\n. This is so we kinda-sorta conform to the standardPropertiesfile format. - See Also:
-
getStateAsString
Builds the McIDAS-V system properties and returns the results as aString.- Parameters:
mcv- The McIDASV "god" object.firehose- Iftrue, enables "unfiltered" output.- Returns:
- The McIDAS-V system properties in the following format:
KEY=VALUE\n. This is so we kinda-sorta conform to the standardPropertiesfile format.
-