org.objectweb.proactive.core.process
Class AbstractExternalProcess

java.lang.Object
  extended byorg.objectweb.proactive.core.process.AbstractUniversalProcess
      extended byorg.objectweb.proactive.core.process.AbstractExternalProcess
All Implemented Interfaces:
ExternalProcess, java.io.Serializable, UniversalProcess
Direct Known Subclasses:
AbstractExternalProcessDecorator, JVMProcessImpl, SimpleExternalProcess

public abstract class AbstractExternalProcess
extends AbstractUniversalProcess
implements ExternalProcess

See Also:
Serialized Form

Nested Class Summary
static class AbstractExternalProcess.NullMessageLogger
          Implementation of a RemoteProcessMessageLogger that discard all output
protected  class AbstractExternalProcess.ProcessInputHandler
          This class reads all messages from an input and log them using a RemoteProcessMessageLogger
protected  class AbstractExternalProcess.ProcessOutputHandler
          This class uses a MessageSink to write all messages produced in a given output
static class AbstractExternalProcess.SimpleMessageSink
          Implementation of a MessageSink that can receive one message at a time
static class AbstractExternalProcess.StandardOutputMessageLogger
          Implementation of a RemoteProcessMessageLogger that output all messages to the standard output
 
Field Summary
protected static org.apache.log4j.Logger clogger
           
protected  boolean closeStream
           
protected  RemoteProcessMessageLogger errorMessageLogger
           
protected  java.lang.Process externalProcess
           
protected  java.lang.String FILE_TRANSFER_DEFAULT_PROTOCOL
           
protected static org.apache.log4j.Logger fileTransferLogger
           
protected  RemoteProcessMessageLogger inputMessageLogger
           
protected static boolean IS_WINDOWS_SYSTEM
           
static int NO_COMPOSITION
           
protected  MessageSink outputMessageSink
           
 
Fields inherited from class org.objectweb.proactive.core.process.AbstractUniversalProcess
certificateLocation, command, command_path, DEFAULT_HOSTNAME, DEFAULT_USERNAME, environment, hostname, isFinished, isStarted, LOCALHOST, privateKeyLocation, securityFile, username
 
Fields inherited from interface org.objectweb.proactive.core.process.UniversalProcess
logger, UNKNOWN_NODE_NUMBER
 
Constructor Summary
protected AbstractExternalProcess()
           
  AbstractExternalProcess(RemoteProcessMessageLogger messageLogger)
           
  AbstractExternalProcess(RemoteProcessMessageLogger inputMessageLogger, RemoteProcessMessageLogger errorMessageLogger)
           
  AbstractExternalProcess(RemoteProcessMessageLogger inputMessageLogger, RemoteProcessMessageLogger errorMessageLogger, MessageSink outputMessageSink)
           
 
Method Summary
protected abstract  java.lang.String buildCommand()
           
protected  java.lang.String buildEnvironmentCommand()
           
protected  java.lang.String buildUnixEnvironmentCommand()
           
protected  java.lang.String buildWindowsEnvironmentCommand()
           
 void closeStream()
          Closes Input, Output, Error stream just after forking this process
 int getCompositionType()
          Returns the type of this process.
 RemoteProcessMessageLogger getErrorMessageLogger()
          Returns the RemoteProcessMessageLogger handling the error stream of the process
 java.lang.String getFileTransferDefaultCopyProtocol()
           
 FileTransferWorkShop getFileTransferWorkShopDeploy()
          This method returns a single FileTransferStructure instance for this process.
 FileTransferWorkShop getFileTransferWorkShopRetrieve()
          This method returns a single FileTransferStructure instance for this process.
 RemoteProcessMessageLogger getInputMessageLogger()
          Returns the RemoteProcessMessageLogger handling the input stream of the process
 MessageSink getOutputMessageSink()
          Returns the MessageSink handling the output stream of the process
protected  void handleError(java.io.BufferedReader err)
           
protected  void handleInput(java.io.BufferedReader in)
           
protected  void handleOutput(java.io.BufferedWriter out)
           
protected  void handleProcess(java.io.BufferedReader in, java.io.BufferedWriter out, java.io.BufferedReader err)
           
protected  boolean internalFileTransferDefaultProtocol()
          This method should be redefined on every protocol that internaly implements the file transfer.
protected  void internalStartFileTransfer(FileTransferWorkShop fts)
          Try all the protocols until one is successful.
protected  void internalStartProcess(java.lang.String commandToExecute)
           
protected  void internalStopProcess()
           
protected  int internalWaitFor()
           
 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
 
Methods inherited from class org.objectweb.proactive.core.process.AbstractUniversalProcess
checkStarted, getCommand, getCommandPath, getEnvironment, getHostname, getUsername, isFinished, isHierarchical, isStarted, pushProcessAttributes, setCommandPath, setEnvironment, setHostname, setUsername, startFileTransfer, startProcess, stopProcess, toString, toString, waitFor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.objectweb.proactive.core.process.UniversalProcess
getCommand, getCommandPath, getEnvironment, getFinalProcess, getHostname, getNodeNumber, getProcessId, getUsername, isFinished, isHierarchical, isStarted, setCommandPath, setEnvironment, setHostname, setUsername, startFileTransfer, startProcess, stopProcess, waitFor
 

Field Detail

clogger

protected static org.apache.log4j.Logger clogger

fileTransferLogger

protected static org.apache.log4j.Logger fileTransferLogger

IS_WINDOWS_SYSTEM

protected static final boolean IS_WINDOWS_SYSTEM

externalProcess

protected java.lang.Process externalProcess

NO_COMPOSITION

public static final int NO_COMPOSITION
See Also:
Constant Field Values

closeStream

protected boolean closeStream

inputMessageLogger

protected RemoteProcessMessageLogger inputMessageLogger

errorMessageLogger

protected RemoteProcessMessageLogger errorMessageLogger

outputMessageSink

protected MessageSink outputMessageSink

FILE_TRANSFER_DEFAULT_PROTOCOL

protected java.lang.String FILE_TRANSFER_DEFAULT_PROTOCOL
Constructor Detail

AbstractExternalProcess

protected AbstractExternalProcess()

AbstractExternalProcess

public AbstractExternalProcess(RemoteProcessMessageLogger messageLogger)

AbstractExternalProcess

public AbstractExternalProcess(RemoteProcessMessageLogger inputMessageLogger,
                               RemoteProcessMessageLogger errorMessageLogger)

AbstractExternalProcess

public AbstractExternalProcess(RemoteProcessMessageLogger inputMessageLogger,
                               RemoteProcessMessageLogger errorMessageLogger,
                               MessageSink outputMessageSink)
Method Detail

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

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

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

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

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

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

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

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
Returns:
A FileTransferWorkShop instance for the deploy queue

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
Returns:
A FileTransferWorkShop instance for the retrieve queue

getFileTransferDefaultCopyProtocol

public java.lang.String getFileTransferDefaultCopyProtocol()

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.

buildCommand

protected abstract java.lang.String buildCommand()
Specified by:
buildCommand in class AbstractUniversalProcess

buildEnvironmentCommand

protected java.lang.String buildEnvironmentCommand()

buildWindowsEnvironmentCommand

protected java.lang.String buildWindowsEnvironmentCommand()

buildUnixEnvironmentCommand

protected java.lang.String buildUnixEnvironmentCommand()

internalStartProcess

protected void internalStartProcess(java.lang.String commandToExecute)
                             throws java.io.IOException
Specified by:
internalStartProcess in class AbstractUniversalProcess
Throws:
java.io.IOException

internalStopProcess

protected void internalStopProcess()
Specified by:
internalStopProcess in class AbstractUniversalProcess

internalWaitFor

protected int internalWaitFor()
                       throws java.lang.InterruptedException
Specified by:
internalWaitFor in class AbstractUniversalProcess
Throws:
java.lang.InterruptedException

internalStartFileTransfer

protected void internalStartFileTransfer(FileTransferWorkShop fts)
Try all the protocols until one is successful.

Specified by:
internalStartFileTransfer in class AbstractUniversalProcess

internalFileTransferDefaultProtocol

protected boolean internalFileTransferDefaultProtocol()
This method should be redefined on every protocol that internaly implements the file transfer. Ex: Unicore

Returns:
true if and only if successful.

handleProcess

protected void handleProcess(java.io.BufferedReader in,
                             java.io.BufferedWriter out,
                             java.io.BufferedReader err)

handleInput

protected void handleInput(java.io.BufferedReader in)

handleError

protected void handleError(java.io.BufferedReader err)

handleOutput

protected void handleOutput(java.io.BufferedWriter out)


Copyright 2001-2005 INRIA All Rights Reserved.