org.rhq.core.system
Class JavaSystemInfo

java.lang.Object
  extended by org.rhq.core.system.JavaSystemInfo
All Implemented Interfaces:
SystemInfo

public class JavaSystemInfo
extends Object
implements SystemInfo

This is the "non-native" fallback implementation of a SystemInfo used in the case when there is no native library available that can be used to obtain low-level system information. This implementation cannot provide all the types of information that a true NativeSystemInfo implementation can - in the cases where this implementation cannot provide the requested information, the UnsupportedOperationException exception will be thrown.


Method Summary
 ProcessExecutionResults executeProcess(ProcessExecution processExecution)
          Spawns a new process using the Java Runtime API.
 List<NetworkAdapterInfo> getAllNetworkAdapters()
          Returns partially filled NetworkAdapterInfo objects - only the data available via the Java API (particularly the NetworkInterface class) will be available in the returned objects.
 List<ProcessInfo> getAllProcesses()
          Throws UnsupportedOperationException since the Java API cannot obtain information about currently running processes.
 List<ServiceInfo> getAllServices()
          Throws UnsupportedOperationException since the Java API cannot obtain information about installed services.
 CpuInformation getCpu(int cpuIndex)
          Throws UnsupportedOperationException since the Java API cannot obtain information about CPUs.
 FileSystemInfo getFileSystem(String directory)
          Throws UnsupportedOperationException since the Java API cannot obtain information about file systems.
 List<FileSystemInfo> getFileSystems()
          Throws UnsupportedOperationException since the Java API cannot obtain information about file systems.
 String getHostname()
          This returns the canonical hostname as it is known via the Java API InetAddress.getLocalHost().
 org.hyperic.sigar.Mem getMemoryInfo()
          Throws UnsupportedOperationException since the Java API cannot obtain information about low level memory details.
 NetworkAdapterStats getNetworkAdapterStats(String interfaceName)
           
 NetworkStats getNetworkStats(String addressName, int port)
           
 int getNumberOfCpus()
          Throws UnsupportedOperationException since the Java API cannot obtain information about the number of CPUs.
 String getOperatingSystemName()
          Returns the value of the Java system property os.name.
 OperatingSystemType getOperatingSystemType()
          Returns OperatingSystemType.JAVA unless the type can be determined via the Java "os.name" property.
 String getOperatingSystemVersion()
          Returns the value of the Java system property os.version.
 List<ProcessInfo> getProcesses(String processInfoQuery)
          Throws UnsupportedOperationException since the Java API cannot obtain information about processes.
 org.hyperic.sigar.Swap getSwapInfo()
          Throws UnsupportedOperationException since the Java API cannot obtain information about low level swap details.
 String getSystemArchitecture()
          Returns the architecture of the underlying hardware
 ProcessInfo getThisProcess()
          Throws UnsupportedOperationException since the Java API cannot obtain information about currently running processes.
 boolean isNative()
          Returns false - this implementation relies solely on the Java API to get all the system information it can.
 String readLineFromConsole(boolean noEcho)
          Reads from System.in.
 void writeLineToConsole(String line)
          Writes to System.out.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isNative

public boolean isNative()
Returns false - this implementation relies solely on the Java API to get all the system information it can.

Specified by:
isNative in interface SystemInfo
Returns:
true if there is a low-level native API available for the JVM's platform
See Also:
SystemInfo.isNative()

getOperatingSystemType

public OperatingSystemType getOperatingSystemType()
Returns OperatingSystemType.JAVA unless the type can be determined via the Java "os.name" property. The caller can call getOperatingSystemName() to try to determine the real operating system type if this method cannot.

Specified by:
getOperatingSystemType in interface SystemInfo
Returns:
the type of operating system, as detected by the native layer
See Also:
SystemInfo.getOperatingSystemType()

getOperatingSystemName

public String getOperatingSystemName()
Returns the value of the Java system property os.name.

Specified by:
getOperatingSystemName in interface SystemInfo
Returns:
OS name
See Also:
SystemInfo.getOperatingSystemName()

getOperatingSystemVersion

public String getOperatingSystemVersion()
Returns the value of the Java system property os.version.

Specified by:
getOperatingSystemVersion in interface SystemInfo
Returns:
what the operating system says is its version
See Also:
SystemInfo.getOperatingSystemVersion()

getHostname

public String getHostname()
This returns the canonical hostname as it is known via the Java API InetAddress.getLocalHost().

Specified by:
getHostname in interface SystemInfo
Returns:
machine host name
See Also:
SystemInfo.getHostname()

getAllNetworkAdapters

public List<NetworkAdapterInfo> getAllNetworkAdapters()
                                               throws SystemInfoException
Returns partially filled NetworkAdapterInfo objects - only the data available via the Java API (particularly the NetworkInterface class) will be available in the returned objects.

Specified by:
getAllNetworkAdapters in interface SystemInfo
Returns:
list containing information on all network adapters
Throws:
SystemInfoException
See Also:
SystemInfo.getAllServices()

getAllServices

public List<ServiceInfo> getAllServices()
                                 throws UnsupportedOperationException
Throws UnsupportedOperationException since the Java API cannot obtain information about installed services.

Specified by:
getAllServices in interface SystemInfo
Returns:
list container information on all services currently installed
Throws:
UnsupportedOperationException
See Also:
SystemInfo.getAllServices()

getAllProcesses

public List<ProcessInfo> getAllProcesses()
                                  throws UnsupportedOperationException
Throws UnsupportedOperationException since the Java API cannot obtain information about currently running processes.

Specified by:
getAllProcesses in interface SystemInfo
Returns:
list containing information on all processes currently running at the time the method was called
Throws:
UnsupportedOperationException
See Also:
SystemInfo.getAllProcesses()

getProcesses

public List<ProcessInfo> getProcesses(String processInfoQuery)
Throws UnsupportedOperationException since the Java API cannot obtain information about processes.

Specified by:
getProcesses in interface SystemInfo
Parameters:
processInfoQuery - the PIQL query string
Returns:
list containing process information
See Also:
SystemInfo.getProcesses(String)

getThisProcess

public ProcessInfo getThisProcess()
Throws UnsupportedOperationException since the Java API cannot obtain information about currently running processes.

Specified by:
getThisProcess in interface SystemInfo
Returns:
this VM process's information
See Also:
SystemInfo.getThisProcess()

executeProcess

public ProcessExecutionResults executeProcess(ProcessExecution processExecution)
Spawns a new process using the Java Runtime API.

Specified by:
executeProcess in interface SystemInfo
Parameters:
processExecution - the settings on how to execute the process
Returns:
the results of the execution
See Also:
SystemInfo.executeProcess(ProcessExecution)

getNumberOfCpus

public int getNumberOfCpus()
Throws UnsupportedOperationException since the Java API cannot obtain information about the number of CPUs.

Specified by:
getNumberOfCpus in interface SystemInfo
Returns:
CPU count
See Also:
SystemInfo.getNumberOfCpus()

getMemoryInfo

public org.hyperic.sigar.Mem getMemoryInfo()
Throws UnsupportedOperationException since the Java API cannot obtain information about low level memory details.

Specified by:
getMemoryInfo in interface SystemInfo
Returns:
memory information
See Also:
SystemInfo.getMemoryInfo()

getSwapInfo

public org.hyperic.sigar.Swap getSwapInfo()
Throws UnsupportedOperationException since the Java API cannot obtain information about low level swap details.

Specified by:
getSwapInfo in interface SystemInfo
Returns:
swap information
See Also:
SystemInfo.getSwapInfo()

readLineFromConsole

public String readLineFromConsole(boolean noEcho)
                           throws IOException
Reads from System.in.

Specified by:
readLineFromConsole in interface SystemInfo
Parameters:
noEcho - if true, the implementation should try to not echo the input to the console
Returns:
the line read from the console input
Throws:
IOException - if failed to read console input
See Also:
SystemInfo.readLineFromConsole(boolean)

writeLineToConsole

public void writeLineToConsole(String line)
                        throws IOException
Writes to System.out.

Specified by:
writeLineToConsole in interface SystemInfo
Throws:
IOException
See Also:
SystemInfo.writeLineToConsole(String)

getCpu

public CpuInformation getCpu(int cpuIndex)
Throws UnsupportedOperationException since the Java API cannot obtain information about CPUs.

Specified by:
getCpu in interface SystemInfo
Parameters:
cpuIndex - identifies the CPU whose information is to be returned; on a single-CPU system, the index must be 0.
Returns:
information on the CPU
See Also:
SystemInfo.getCpu(int)

getFileSystems

public List<FileSystemInfo> getFileSystems()
Throws UnsupportedOperationException since the Java API cannot obtain information about file systems.

Specified by:
getFileSystems in interface SystemInfo
Returns:
list of all file systems on the platform
See Also:
SystemInfo.getFileSystems()

getFileSystem

public FileSystemInfo getFileSystem(String directory)
Throws UnsupportedOperationException since the Java API cannot obtain information about file systems.

Specified by:
getFileSystem in interface SystemInfo
Parameters:
directory - the file or directory whose mounted file system should be returned
Returns:
the file system where the given file or directory is hosted
See Also:
SystemInfo.getFileSystem(String)

getNetworkAdapterStats

public NetworkAdapterStats getNetworkAdapterStats(String interfaceName)
Specified by:
getNetworkAdapterStats in interface SystemInfo

getNetworkStats

public NetworkStats getNetworkStats(String addressName,
                                    int port)
Specified by:
getNetworkStats in interface SystemInfo

getSystemArchitecture

public String getSystemArchitecture()
Description copied from interface: SystemInfo
Returns the architecture of the underlying hardware

Specified by:
getSystemArchitecture in interface SystemInfo
Returns:


Copyright © 2008-2009 RHQ Project Advisory Board (Red Hat, Inc.). All Rights Reserved.