Overview | Package | Class | Tree | Deprecated | Index | Help
| Hyperic HQ Plugin API v. 4.4.0.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.hyperic.util.exec
Class ExecuteWatchdog

    java.lang.Object
      org.hyperic.util.exec.ExecuteWatchdog

All Implemented Interfaces:
  java.lang.Runnable

    public class ExecuteWatchdog

extends java.lang.Object
implements java.lang.Runnable

Destroys a process running for too long. For example:

     ExecuteWatchdog watchdog = new ExecuteWatchdog(30000);
     Execute exec = new Execute(myloghandler, watchdog);
     exec.setCommandLine(mycmdline);
     int exitvalue = exec.execute();
     if (exitvalue != SUCCESS && watchdog.killedProcess()){
                  // it was killed on purpose by the watchdog
     }

See Also:
  `Execute`

Constructor Summary
`ExecuteWatchdog(int timeout)` Creates a new watchdog with a given timeout.

Method Summary
`protected void` | `cleanUp()` reset the monitor flag and the process.
`java.lang.Exception` | `getException()` This method will rethrow the exception that was possibly caught during the run of the process.
`boolean` | `isWatching()` Indicates whether or not the watchdog is still monitoring the process.
`boolean` | `killedProcess()` Indicates whether the last process run was killed on timeout or not.
`void` | `run()` Watches the process and terminates it, if it runs for to long.
`void` | `setDontkill(boolean b)`
`void` | `start(java.lang.Process process, java.lang.Thread execThread)` Watches the given process and terminates it, if it runs for too long.
`void` | `stop()` Stops the watcher.

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

Constructor Detail

### ExecuteWatchdog

    public ExecuteWatchdog(int timeout)

  Creates a new watchdog with a given timeout.

  Parameters:
    `timeout` - the timeout for the process in milliseconds. It must be greather than 0.

Method Detail

### setDontkill

    public void setDontkill(boolean b)

### start

    public void start(java.lang.Process process,
                      java.lang.Thread execThread)

  Watches the given process and terminates it, if it runs for too long. All information from the previous run are reset.

  Parameters:
    `process` - the process to monitor. It cannot be `null`
  Throws:
    `java.lang.IllegalStateException` - thrown if a process is still being monitored.

### stop

    public void stop()

  Stops the watcher. It will notify all threads possibly waiting on this object.

### run

    public void run()

  Watches the process and terminates it, if it runs for to long.

  Specified by:
    `run` in interface `java.lang.Runnable`

### cleanUp

    protected void cleanUp()

  reset the monitor flag and the process.

### getException

    public java.lang.Exception getException()

  This method will rethrow the exception that was possibly caught during the run of the process. It will only remains valid once the process has been terminated either by 'error', timeout or manual intervention. Information will be discarded once a new process is ran.

  Throws:
    `BuildException` - a wrapped exception over the one that was silently swallowed and stored during the process run.

### isWatching

    public boolean isWatching()

  Indicates whether or not the watchdog is still monitoring the process.

  Returns:
    `true` if the process is still running, otherwise `false`.

### killedProcess

    public boolean killedProcess()

  Indicates whether the last process run was killed on timeout or not.

  Returns:
    `true` if the process was killed otherwise `false`.

Overview | Package | Class | Tree | Deprecated | Index | Help
| Hyperic HQ Plugin API v. 4.4.0.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004-2006 Hyperic, Inc. support@hyperic.net, All Rights Reserved.