org.objectweb.proactive.core.process
Class AbstractSequentialListProcessDecorator

java.lang.Object
  extended byorg.objectweb.proactive.core.process.AbstractSequentialListProcessDecorator
All Implemented Interfaces:
ExternalProcess, ExternalProcessDecorator, java.io.Serializable, UniversalProcess
Direct Known Subclasses:
DependentListProcessDecorator, IndependentListProcessDecorator

public abstract class AbstractSequentialListProcessDecorator
extends java.lang.Object
implements ExternalProcessDecorator

This class contains a list of ExternalProcess processes that have to be executed sequentially

Since:
ProActive 3.0
Version:
1.0, 01 Dec 2005
Author:
ProActiveTeam
See Also:
Serialized Form

Field Summary
protected  int currentRank
           
protected  java.util.ArrayList processes
           
 
Fields inherited from interface org.objectweb.proactive.core.process.ExternalProcessDecorator
APPEND_TO_COMMAND_COMPOSITION, COPY_FILE_AND_APPEND_COMMAND, GIVE_COMMAND_AS_PARAMETER, SEND_TO_OUTPUT_STREAM_COMPOSITION
 
Fields inherited from interface org.objectweb.proactive.core.process.UniversalProcess
logger, UNKNOWN_NODE_NUMBER
 
Constructor Summary
AbstractSequentialListProcessDecorator()
           
 
Method Summary
 void addProcessToList(ExternalProcess process)
          Add a process to the processes queue
 void addProcessToList(int rank, ExternalProcess process)
          Add a process to the processes queue at index rank
 void closeStream()
          Closes Input, Output, Error stream just after forking this process
protected abstract  ExternalProcess createProcess()
           
 int exitValue()
          This method returns the exit value of the subprocess.
 java.lang.String getCommand()
          Returns the command that will be or has been execute by the process.
 java.lang.String getCommandPath()
          Returns the path of the command to be executed by this process
 int getCompositionType()
          Returns the type of this process.
 java.lang.String[] getEnvironment()
          Returns the current environment for this process.
 RemoteProcessMessageLogger getErrorMessageLogger()
          Returns the RemoteProcessMessageLogger handling the error stream of the process
 FileTransferWorkShop getFileTransferWorkShopDeploy()
          This method returns a single FileTransferStructure instance for this process.
 FileTransferWorkShop getFileTransferWorkShopRetrieve()
          This method returns a single FileTransferStructure instance for this process.
 UniversalProcess getFinalProcess()
          Returns the last process of the chain
 ExternalProcess getFirstProcess()
          Return the next process to be launched and increase current rank
 RemoteProcessMessageLogger getInputMessageLogger()
          Returns the RemoteProcessMessageLogger handling the input stream of the process
 java.util.ArrayList getListProcess()
           
 ExternalProcess getNextProcess()
          Return the next process to be launched and increase current rank
 int getNodeNumber()
          Returns the number of nodes targeted
 MessageSink getOutputMessageSink()
          Returns the MessageSink handling the output stream of the process
 java.lang.String getProcessId()
          Returns the id of the process
 ExternalProcess getTargetProcess()
          Returns the process target of this process.
 java.lang.String getUsername()
          Return the username that will be used to run the command.
 boolean isFinished()
          Returns true if and only if this process has been stopped.
 boolean isSequential()
          Returns true if and only if this process is sequential
 boolean isStarted()
          Returns true if and only if this process has been started.
 void setCommandPath(java.lang.String path)
          Sets the path of the command to be executed by this process
 void setCompositionType(int compositionType)
          Sets the type of composition that occurs between the commands of two processes.
 void setEnvironment(java.lang.String[] environment)
          Set the environment for this process.
 void setErrorMessageLogger(RemoteProcessMessageLogger errorMessageLogger)
          sets the RemoteProcessMessageLogger handling the error stream of the process
 void setInputMessageLogger(RemoteProcessMessageLogger inputMessageLogger)
          sets the RemoteProcessMessageLogger handling the input stream of the process
 void setOutputMessageSink(MessageSink outputMessageSink)
          sets the MessageSink handling the output stream of the process
 void setStarted(boolean isStarted)
          Sets the state started of this process
 void setTargetProcess(ExternalProcess targetProcess)
          Sets the process target of this process.
 void setUsername(java.lang.String username)
          Set the username that will be used to run the command.
 void startFileTransfer()
          Starts the FileTransfer if defined for this process.
 void stopProcess()
          Stops the running process.
 int waitFor()
          Causes the current thread to wait until this Process has terminated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.proactive.core.process.UniversalProcess
getHostname, isDependent, isHierarchical, setHostname, startProcess
 

Field Detail

processes

protected java.util.ArrayList processes

currentRank

protected int currentRank
Constructor Detail

AbstractSequentialListProcessDecorator

public AbstractSequentialListProcessDecorator()
Method Detail

addProcessToList

public void addProcessToList(ExternalProcess process)
Add a process to the processes queue

Parameters:
process -

addProcessToList

public void addProcessToList(int rank,
                             ExternalProcess process)
Add a process to the processes queue at index rank

Parameters:
rank -
process -

getFirstProcess

public ExternalProcess getFirstProcess()
Return the next process to be launched and increase current rank

Returns:
process

getNextProcess

public ExternalProcess getNextProcess()
Return the next process to be launched and increase current rank

Returns:
ExternalProcess

getTargetProcess

public ExternalProcess getTargetProcess()
Description copied from interface: ExternalProcessDecorator
Returns the process target of this process. The target process is embedded inside the current process.

Specified by:
getTargetProcess in interface ExternalProcessDecorator
Returns:
the process target of this process
See Also:
ExternalProcessDecorator.getTargetProcess()

setTargetProcess

public void setTargetProcess(ExternalProcess targetProcess)
Description copied from interface: ExternalProcessDecorator
Sets the process target of this process. The target process is embedded inside the current process.

Specified by:
setTargetProcess in interface ExternalProcessDecorator
Parameters:
targetProcess - the process target of this process
See Also:
ExternalProcessDecorator.setTargetProcess(org.objectweb.proactive.core.process.ExternalProcess)

getCompositionType

public int getCompositionType()
Description copied from interface: ExternalProcess
Returns the type of this process. For processes that does not reference another process, the type is NO_COMPOSITION For other types are APPEND_TO_COMMAND_COMPOSITION or SEND_TO_OUTPUT_STREAM_COMPOSITION or GIVE_COMMAND_AS_PARAMETER or COPY_FILE_AND_APPEND_COMMAND.

Specified by:
getCompositionType in interface ExternalProcess
Returns:
the type this process.
See Also:
ExternalProcess.getCompositionType()

setCompositionType

public void setCompositionType(int compositionType)
Description copied from interface: ExternalProcessDecorator
Sets the type of composition that occurs between the commands of two processes. Type are APPEND_TO_COMMAND_COMPOSITION or SEND_TO_OUTPUT_STREAM_COMPOSITION.

Specified by:
setCompositionType in interface ExternalProcessDecorator
Parameters:
compositionType - the type of composition that occurs between the commands of two processes
See Also:
ExternalProcessDecorator.setCompositionType(int)

getFileTransferWorkShopRetrieve

public FileTransferWorkShop getFileTransferWorkShopRetrieve()
Description copied from interface: ExternalProcess
This method returns a single FileTransferStructure instance for this process. If many invocations to this method are done, the same instance of FileTransferStructure will be returned. This means, that changes made to the structure will be reflected on all the references obtained through this method for this process. Note that different process do not share a FileTransferStructure, and thus changes made to one will not reflect on the other.

Specified by:
getFileTransferWorkShopRetrieve in interface ExternalProcess

getFileTransferWorkShopDeploy

public FileTransferWorkShop getFileTransferWorkShopDeploy()
Description copied from interface: ExternalProcess
This method returns a single FileTransferStructure instance for this process. If many invocations to this method are done, the same instance of FileTransferStructure will be returned. This means, that changes made to the structure will be reflected on all the references obtained through this method for this process. Note that different process do not share a FileTransferStructure, and thus changes made to one will not reflect on the other.

Specified by:
getFileTransferWorkShopDeploy in interface ExternalProcess

startFileTransfer

public void startFileTransfer()
Description copied from interface: UniversalProcess
Starts the FileTransfer if defined for this process.

Specified by:
startFileTransfer in interface UniversalProcess

closeStream

public void closeStream()
Description copied from interface: ExternalProcess
Closes Input, Output, Error stream just after forking this process

Specified by:
closeStream in interface ExternalProcess
See Also:
ExternalProcess.closeStream()

getInputMessageLogger

public RemoteProcessMessageLogger getInputMessageLogger()
Description copied from interface: ExternalProcess
Returns the RemoteProcessMessageLogger handling the input stream of the process

Specified by:
getInputMessageLogger in interface ExternalProcess
Returns:
the RemoteProcessMessageLogger handling the input stream of the process
See Also:
ExternalProcess.getInputMessageLogger()

getErrorMessageLogger

public RemoteProcessMessageLogger getErrorMessageLogger()
Description copied from interface: ExternalProcess
Returns the RemoteProcessMessageLogger handling the error stream of the process

Specified by:
getErrorMessageLogger in interface ExternalProcess
Returns:
the RemoteProcessMessageLogger handling the error stream of the process
See Also:
ExternalProcess.getErrorMessageLogger()

getOutputMessageSink

public MessageSink getOutputMessageSink()
Description copied from interface: ExternalProcess
Returns the MessageSink handling the output stream of the process

Specified by:
getOutputMessageSink in interface ExternalProcess
Returns:
the MessageSink handling the output stream of the process
See Also:
ExternalProcess.getOutputMessageSink()

setInputMessageLogger

public void setInputMessageLogger(RemoteProcessMessageLogger inputMessageLogger)
Description copied from interface: ExternalProcess
sets the RemoteProcessMessageLogger handling the input stream of the process

Specified by:
setInputMessageLogger in interface ExternalProcess
Parameters:
inputMessageLogger - the handler of the input stream of the process
See Also:
ExternalProcess.setInputMessageLogger(org.objectweb.proactive.core.util.RemoteProcessMessageLogger)

setErrorMessageLogger

public void setErrorMessageLogger(RemoteProcessMessageLogger errorMessageLogger)
Description copied from interface: ExternalProcess
sets the RemoteProcessMessageLogger handling the error stream of the process

Specified by:
setErrorMessageLogger in interface ExternalProcess
Parameters:
errorMessageLogger - the handler of the error stream of the process
See Also:
ExternalProcess.setErrorMessageLogger(org.objectweb.proactive.core.util.RemoteProcessMessageLogger)

setOutputMessageSink

public void setOutputMessageSink(MessageSink outputMessageSink)
Description copied from interface: ExternalProcess
sets the MessageSink handling the output stream of the process

Specified by:
setOutputMessageSink in interface ExternalProcess
Parameters:
outputMessageSink - the handler of the output stream of the process
See Also:
ExternalProcess.setOutputMessageSink(org.objectweb.proactive.core.process.MessageSink)

getEnvironment

public java.lang.String[] getEnvironment()
Description copied from interface: UniversalProcess
Returns the current environment for this process. Each cell of the array contains the definition of one variable in a syntax that is system dependant.

Specified by:
getEnvironment in interface UniversalProcess
Returns:
an array of string containing all environment variables or null if the environment is empty
See Also:
UniversalProcess.getEnvironment()

setEnvironment

public void setEnvironment(java.lang.String[] environment)
Description copied from interface: UniversalProcess
Set the environment for this process. Each cell of the array contains the definition of one variable in a syntax that is system dependant.

Specified by:
setEnvironment in interface UniversalProcess
Parameters:
environment - an array of string containing all environment variables or null if the environment is empty
See Also:
UniversalProcess.setEnvironment(java.lang.String[])

getUsername

public java.lang.String getUsername()
Description copied from interface: UniversalProcess
Return the username that will be used to run the command.

Specified by:
getUsername in interface UniversalProcess
Returns:
the username that will be used to run the command.
See Also:
UniversalProcess.getUsername()

setUsername

public void setUsername(java.lang.String username)
Description copied from interface: UniversalProcess
Set the username that will be used to run the command. By default the current username owner of the JVM process is used.

Specified by:
setUsername in interface UniversalProcess
Parameters:
username - the target username or null to use the default one.
See Also:
UniversalProcess.setUsername(java.lang.String)

getCommand

public java.lang.String getCommand()
Description copied from interface: UniversalProcess
Returns the command that will be or has been execute by the process.

Specified by:
getCommand in interface UniversalProcess
Returns:
the command of this external process
See Also:
UniversalProcess.getCommand()

getProcessId

public java.lang.String getProcessId()
Description copied from interface: UniversalProcess
Returns the id of the process

Specified by:
getProcessId in interface UniversalProcess
Returns:
the id of the process. This id is just the first letters of the process class, to be able to identify the sequence of processes used
See Also:
UniversalProcess.getProcessId()

getNodeNumber

public int getNodeNumber()
Description copied from interface: UniversalProcess
Returns the number of nodes targeted

Specified by:
getNodeNumber in interface UniversalProcess
Returns:
the number of nodes targeted. Represents the number of nodes expected to use when starting this process. If this number cannot be known, waiting for all available nodes for example, UNKNOWN_NODE_NUMBER is returned.
See Also:
UniversalProcess.getNodeNumber()

getFinalProcess

public UniversalProcess getFinalProcess()
Description copied from interface: UniversalProcess
Returns the last process of the chain

Specified by:
getFinalProcess in interface UniversalProcess
Returns:
the last process of the chain
See Also:
UniversalProcess.getFinalProcess()

getListProcess

public java.util.ArrayList getListProcess()

stopProcess

public void stopProcess()
Description copied from interface: UniversalProcess
Stops the running process. If called on a stopped process this method has no effect.

Specified by:
stopProcess in interface UniversalProcess
See Also:
UniversalProcess.stopProcess()

waitFor

public int waitFor()
            throws java.lang.InterruptedException
Description copied from interface: UniversalProcess
Causes the current thread to wait until this Process has terminated. This method returns immediately if the subprocess has already terminated. If the subprocess has not yet terminated, the calling thread will be blocked until the subprocess exits.

Specified by:
waitFor in interface UniversalProcess
Returns:
int exit value
Throws:
java.lang.InterruptedException - if the current thread is interrupted by another thread while it is waiting. Then the wait is ended and an InterruptedException is thrown
See Also:
UniversalProcess.waitFor()

isStarted

public boolean isStarted()
Description copied from interface: UniversalProcess
Returns true if and only if this process has been started. A process that has been started can be finished or running.

Specified by:
isStarted in interface UniversalProcess
See Also:
UniversalProcess.isStarted()

isFinished

public boolean isFinished()
Description copied from interface: UniversalProcess
Returns true if and only if this process has been stopped. A process that has been stopped has been started and is no more running.

Specified by:
isFinished in interface UniversalProcess
See Also:
UniversalProcess.isFinished()

isSequential

public boolean isSequential()
Description copied from interface: UniversalProcess
Returns true if and only if this process is sequential

Specified by:
isSequential in interface UniversalProcess

setCommandPath

public void setCommandPath(java.lang.String path)
Description copied from interface: UniversalProcess
Sets the path of the command to be executed by this process

Specified by:
setCommandPath in interface UniversalProcess
See Also:
UniversalProcess.setCommandPath(java.lang.String)

getCommandPath

public java.lang.String getCommandPath()
Description copied from interface: UniversalProcess
Returns the path of the command to be executed by this process

Specified by:
getCommandPath in interface UniversalProcess
Returns:
the path of the command to be executed by this process
See Also:
UniversalProcess.getCommandPath()

createProcess

protected abstract ExternalProcess createProcess()

exitValue

public int exitValue()
              throws java.lang.IllegalThreadStateException
Description copied from interface: UniversalProcess
This method returns the exit value of the subprocess. By convention, the value 0 indicates normal termination. Subprocess has to be terminated, otherwise exception is thrown

Specified by:
exitValue in interface UniversalProcess
Returns:
int exit value
Throws:
java.lang.IllegalThreadStateException - if the current thread is not yet terminated while it is trying to get a return value.

setStarted

public void setStarted(boolean isStarted)
Description copied from interface: UniversalProcess
Sets the state started of this process

Specified by:
setStarted in interface UniversalProcess


Copyright 2001-2005 INRIA All Rights Reserved.