one.world.util
Class SystemUtilities

java.lang.Object
  |
  +--one.world.util.SystemUtilities

public final class SystemUtilities
extends Object

Implementation of system utilities. This class provides functionality available through java.lang.System or java.lang.Runtime to code running in a protection domain that limits access to the Java platform libraries. It also provides information about the local node.

Version:
$Revision: 1.15 $

Method Summary
static int activeThreads()
          Get the current number of threads.
static void arraycopy(Object src, int src_position, Object dst, int dst_position, int length)
          Copy an array.
static long currentTimeMillis()
          Get the current time.
static void debug(String msg)
          Print the specified debug message to the console.
static void debug(Throwable x)
          Print the specified throwable to the console.
static Process exec(String command)
          Execute the specified command in a separate process.
static String format(long time)
          Format the specified time.
static long freeMemory()
          Get the current amount of free memory.
static Properties getProperties()
          Get the current system propeties.
static String getProperty(String key)
          Get the system property.
static String getProperty(String key, String def)
          Get the system property.
static int identityHashCode(Object o)
          Get the identity hashcode.
static String ipAddress()
          Get the IP address for this node.
static boolean isLocalHost(String host)
          Determine whether the specified host is the local host.
static byte[] rawIpAddress()
          Get the IP address for this node as an array of bytes.
static void sleep(long duration)
          Sleep for the specified time.
static void sleep(long duration, int nanos)
          Sleep for the specified time.
static long totalMemory()
          Get the total amount of memory.
static long uptime()
          Get the current uptime.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

arraycopy

public static void arraycopy(Object src,
                             int src_position,
                             Object dst,
                             int dst_position,
                             int length)
Copy an array. This method simply calls the corresponding method in java.lang.System.

identityHashCode

public static int identityHashCode(Object o)
Get the identity hashcode. This method simply calls the corresponding method in java.lang.System.

getProperties

public static Properties getProperties()
Get the current system propeties. This method simply calls the corresponding method in java.lang.System.

getProperty

public static String getProperty(String key)
Get the system property. This method simply calls the corresponding method in java.lang.System.

getProperty

public static String getProperty(String key,
                                 String def)
Get the system property. This method simply calls the corresponding method in java.lang.System.

currentTimeMillis

public static long currentTimeMillis()
Get the current time. This method simply calls the corresponding method in java.lang.System.

uptime

public static long uptime()
Get the current uptime. This method returns the current uptime of this instance of one.world in milliseconds.
Returns:
The current uptime.

sleep

public static void sleep(long duration)
                  throws InterruptedException
Sleep for the specified time. This method simply calls Thread.sleep(long) with the specified duration.
Parameters:
duration - The duration in milliseconds.
Throws:
InterruptedException - Signals that the sleep was interrupted.

sleep

public static void sleep(long duration,
                         int nanos)
                  throws InterruptedException
Sleep for the specified time. This method simply calls Thread.sleep(long,int) with the specified duration.
Parameters:
duration - The duration in milliseconds.
nanos - The additional nanoseconds to sleep.
Throws:
InterruptedException - Signals that the sleep was interrupted.

format

public static String format(long time)
Format the specified time.
Parameters:
time - The time to format.
Returns:
A string representation of the specified time.

freeMemory

public static long freeMemory()
Get the current amount of free memory. This method simply calls the corresponding method in java.lang.Runtime.
Returns:
The current amount of free memory.

totalMemory

public static long totalMemory()
Get the total amount of memory. This method simply calls the corresponding method in java.lang.Runtime.
Returns:
The total amount of memory.

activeThreads

public static int activeThreads()
Get the current number of threads. This method returns an estimate of the number of threads currently active in one.world. Note that this method needs to internally allocate an array to determine the actual number of threads in the system and thus is somewhat expensive.
Returns:
The current number of threads.

ipAddress

public static String ipAddress()
Get the IP address for this node.
Returns:
The IP address for this node, or null if this node has no IP address.

rawIpAddress

public static byte[] rawIpAddress()
Get the IP address for this node as an array of bytes.
Returns:
The IP address for this node as an array of bytes, or null if this node has no IP address.

isLocalHost

public static boolean isLocalHost(String host)
Determine whether the specified host is the local host. The specified host may be a DNS name or an IP address. The name "localhost" is always treated as this host.
Parameters:
host - The host to test.
Returns:
true if the specified host is the local host.

exec

public static Process exec(String command)
                    throws IOException
Execute the specified command in a separate process. This method simply calls the corresponding method in java.lang.Runtime.

This method is provided for legacy code that requires access to outside processes. Note that such processes execute outside one.world and cannot be check-pointed or migrated. Furthermore, to use this method, a node's security policy has to be configured so that the calling code as well as one.world's core code have the appropriate FilePermission.


debug

public static void debug(String msg)
Print the specified debug message to the console.
Parameters:
msg - The debug message to print to the console.

debug

public static void debug(Throwable x)
Print the specified throwable to the console. This method prints a stack trace for the specified throwable to the console.
Parameters:
x - The throwable to print to the console.


(C) Copyright 2001 UW CSE