org.ourgrid.common.executor
Interface Executor

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
AbstractExecutor, LinuxExecutor, SWANExecutor, Win32Executor

public interface Executor
extends java.io.Serializable

This interface defines the contract between platform dependent layer and the upper layers. The idea is to provide a clean interface that is a minimum set of features to perform native operations.


Field Summary
static long serialVersionUID
          Serial identification of the class.
 
Method Summary
 void chmod(java.io.File file, java.lang.String perm)
          Changes the permissions for the indicated file.
 ExecutorHandle execute(java.lang.String dirName, java.lang.String command)
          Execute a local command in a specific dirName.
 ExecutorHandle execute(java.lang.String dirName, java.lang.String command, java.util.Map envVars)
          Execute a local command in a specific dirName, with the environment defined by envVars
 ExecutorResult getResult(ExecutorHandle handle)
          Blocks until the command finishes and returns its result
 void kill(ExecutorHandle handle)
          Kills command that was issued via an execute method
 

Field Detail

serialVersionUID

static final long serialVersionUID
Serial identification of the class. It need to be changed only if the class interface is changed.

See Also:
Constant Field Values
Method Detail

execute

ExecutorHandle execute(java.lang.String dirName,
                       java.lang.String command,
                       java.util.Map envVars)
                       throws ExecutorException
Execute a local command in a specific dirName, with the environment defined by envVars

Parameters:
dirName - directory to execute the script
command - command to be executed
envVars - environment variables used by this command
Returns:
a handle that identifies this execution
Throws:
ExecutorException - when there is a problem in the execution.

execute

ExecutorHandle execute(java.lang.String dirName,
                       java.lang.String command)
                       throws ExecutorException
Execute a local command in a specific dirName. This method doens't set any enviornment variables.

Parameters:
dirName - directory to execute the script
command - command to be executed
Returns:
a handle that identifies this execution
Throws:
ExecutorException - when there is a problem in the execution.

chmod

void chmod(java.io.File file,
           java.lang.String perm)
           throws ExecutorException
Changes the permissions for the indicated file. Permissions are described using the "rwx" Linux convention. The permissions are changed in a way that further access from this JVM will see the new permissions.

Parameters:
file - the File object
perm - the new permission in "rwx" format
Throws:
ExecutorException - error changing the permissions

kill

void kill(ExecutorHandle handle)
          throws ExecutorException
Kills command that was issued via an execute method

Parameters:
handle - the command handle
Throws:
ExecutorException - when there is a problem while changing .the permissions of a file.

getResult

ExecutorResult getResult(ExecutorHandle handle)
                         throws ExecutorException
Blocks until the command finishes and returns its result

Parameters:
handle - the command handle
Returns:
ExecutorResult StdOut, StdErr and exitValue from kill command.
Throws:
ExecutorException - when there is a problem while obtaining the result of an execution.