## org.apache.hadoop.contrib.failmon
Class Environment

    java.lang.Object
      org.apache.hadoop.contrib.failmon.Environment

    public class Environment

extends Object

This class provides various methods for interaction with the configuration and the operating system environment. Also provides some helper methods for use by other classes in the package.

Field Summary
`static int` `DEFAULT_LOG_INTERVAL`
`static int` `DEFAULT_POLL_INTERVAL`
`static org.apache.commons.logging.Log` `LOG`
`static int` `MAX_OUTPUT_LENGTH`
`static int` `MIN_INTERVAL`

Constructor Summary
`Environment()`

Method Summary
`static boolean` `checkExistence(String cmd)` Checks whether a specific shell command is available in the system.
`static int` `gcd(int[] numbers)` Determines the greatest common divisor (GCD) of a list of integers.
`static int` `gcd(int m, int n)` Determines the greatest common divisor (GCD) of two integers.
`static int` `getInterval(ArrayList<MonitorJob> monitors)` Determines the minimum interval at which the executor thread needs to wake upto execute jobs.
`static ArrayList<MonitorJob>` `getJobs()` Scans the configuration file to determine which monitoring utilities are available in the system.
`static String` `getProperty(String key)` Fetches the value of a property from the configuration file.
`static void` `logInfo(String str)`
`static void` `prepare(String fname)` Initializes structures needed by other methods.
`static StringBuffer` `runCommand(String cmd)` Runs a shell command in the system and provides a StringBuffer with the output of the command.
`static StringBuffer` `runCommand(String[] cmd)` Runs a shell command in the system and provides a StringBuffer with the output of the command.
`static void` `setProperty(String key, String value)` Sets the value of a property inthe configuration file.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_LOG_INTERVAL

    public static final int DEFAULT_LOG_INTERVAL

See Also:
  Constant Field Values

### DEFAULT_POLL_INTERVAL

    public static final int DEFAULT_POLL_INTERVAL

See Also:
  Constant Field Values

### MIN_INTERVAL

    public static int MIN_INTERVAL

### MAX_OUTPUT_LENGTH

    public static final int MAX_OUTPUT_LENGTH

See Also:
  Constant Field Values

### LOG

    public static org.apache.commons.logging.Log LOG

Constructor Detail

### Environment

    public Environment()

Method Detail

### prepare

    public static void prepare(String fname)

  Initializes structures needed by other methods. Also determines whether the executing user has superuser privileges.

### getProperty

    public static String getProperty(String key)

  Fetches the value of a property from the configuration file.

  Parameters:
    `key` - the name of the property
  Returns:
    the value of the property, if it exists and null otherwise

### setProperty

    public static void setProperty(String key,
                                   String value)

  Sets the value of a property inthe configuration file.

  Parameters:
    `key` - the name of the property
    `value` - the new value for the property

### getJobs

    public static ArrayList<MonitorJob> getJobs()

  Scans the configuration file to determine which monitoring utilities are available in the system. For each one of them, a job is created. All such jobs are scheduled and executed by Executor.

  Returns:
    an ArrayList that contains jobs to be executed by theExecutor.

### getInterval

    public static int getInterval(ArrayList<MonitorJob> monitors)

  Determines the minimum interval at which the executor thread needs to wake upto execute jobs. Essentially, this is interval equals the GCD of intervals of all scheduled jobs.

  Parameters:
    `monitors` - the list of scheduled jobs
  Returns:
    the minimum interval between two scheduled jobs

### checkExistence

    public static boolean checkExistence(String cmd)

  Checks whether a specific shell command is available in the system.

  Parameters:
    `cmd` - the command to check against
  Returns:
    true, if the command is availble, false otherwise

### runCommand

    public static StringBuffer runCommand(String[] cmd)

  Runs a shell command in the system and provides a StringBuffer with the output of the command.

  Parameters:
    `cmd` - an array of string that form the command to run
  Returns:
    a StringBuffer that contains the output of the command

### runCommand

    public static StringBuffer runCommand(String cmd)

  Runs a shell command in the system and provides a StringBuffer with the output of the command.

  Parameters:
    `cmd` - the command to run
  Returns:
    a StringBuffer that contains the output of the command

### gcd

    public static int gcd(int m,
                          int n)

  Determines the greatest common divisor (GCD) of two integers.

  Parameters:
    `m` - the first integer
    `n` - the second integer
  Returns:
    the greatest common divisor of m and n

### gcd

    public static int gcd(int[] numbers)

  Determines the greatest common divisor (GCD) of a list of integers.

  Parameters:
    `numbers` - the list of integers to process
  Returns:
    the greatest common divisor of all numbers

### logInfo

    public static void logInfo(String str)

Copyright © 2009 The Apache Software Foundation