|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ourgrid.common.executor.AbstractExecutor
org.ourgrid.common.executor.LinuxExecutor
public class LinuxExecutor
This class is the concrete implementation of Executor interface that provides the platform dependent command execution. The reationale behind this implementation is to implement Linux native command invocation.
Constructor Summary | |
---|---|
protected |
LinuxExecutor()
A protected constructor to be accessible only by the ExecutorFactory . |
Method Summary | |
---|---|
void |
chmod(java.io.File file,
java.lang.String modeStr)
Changes the permissions for the indicated file. |
protected java.io.File |
createScript(java.lang.String command,
java.lang.String dirName,
java.util.Map envVars,
ExecutorHandle handle)
Creates a script file to execute the command passed as paramether. |
ExecutorHandle |
execute(java.lang.String dirName,
java.lang.String command)
This method implements the command execution feature for Linux environment. |
ExecutorHandle |
execute(java.lang.String dirName,
java.lang.String command,
java.util.Map envVars)
This method implements the command execution feature for Linux environment. |
protected ExecutorHandle |
getNextHandle()
This method manage the handles issued for each command execution |
ExecutorResult |
getResult(ExecutorHandle handle)
Blocks until the command finishes and returns its result |
protected void |
includeInProcesses(ExecutorHandle handle,
java.lang.Process process,
java.lang.String dirName)
Adds a process into the set of the ones which results were not collected yet. |
void |
kill(ExecutorHandle handle)
Kills command that was issued via an execute method |
Methods inherited from class org.ourgrid.common.executor.AbstractExecutor |
---|
catchOutput |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected LinuxExecutor()
ExecutorFactory
.
Method Detail |
---|
protected ExecutorHandle getNextHandle()
public void chmod(java.io.File file, java.lang.String modeStr) throws ExecutorException
Executor
file
- the File objectmodeStr
- the new permission in "rwx" format
ExecutorException
- error changing the permissionsExecutor.chmod(File, String)
public ExecutorHandle execute(java.lang.String dirName, java.lang.String command) throws ExecutorException
command
- The command must be executeddirName
- The execution root directory following the Linux name
convention
ExecutorException
- If the command could not be executed.public ExecutorHandle execute(java.lang.String dirName, java.lang.String command, java.util.Map envVars) throws ExecutorException
command
- The command must be executeddirName
- The execution root directory following the Linux name
conventionenvVars
- A map (var name, value) with the environment variables
used by the command
ExecutorException
- If the command could not be executed.protected void includeInProcesses(ExecutorHandle handle, java.lang.Process process, java.lang.String dirName)
handle
- The handle for the processprocess
- The process to be included at the groupdirName
- The directory where the process was started.protected java.io.File createScript(java.lang.String command, java.lang.String dirName, java.util.Map envVars, ExecutorHandle handle) throws ExecutorException
command
- The command to be executed.dirName
- Where the command has to be executed.envVars
- The environment variables to be exported and used by the
command.handle
- The process handle.
ExecutorException
- If the directory passed is not valid (does not
exists) and if could not create the script file for any I/O
problem..public void kill(ExecutorHandle handle) throws ExecutorException
Executor
handle
- the command handle
ExecutorException
- when there is a problem while changing .the
permissions of a file.Executor.kill(ExecutorHandle)
public ExecutorResult getResult(ExecutorHandle handle) throws ExecutorException
Executor
handle
- the command handle
ExecutorException
- when there is a problem while obtaining the
result of an execution.Executor.getResult(ExecutorHandle)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |