edu.sdsc.inca.agent
Class AccessMethod

java.lang.Object
  extended by edu.sdsc.inca.agent.AccessMethod
Direct Known Subclasses:
Globus, Local, Manual, Sleep, Ssh

public abstract class AccessMethod
extends java.lang.Object

An abstract class used to represent methods for transferring files and running processes on resources. Supported methods include Globus, Local (exec), Manual, and SSH currently. The classes that implement each of these methods exist in the 'access' directory.

Author:
Shava Smallen <ssmallen@sdsc.edu>

Constructor Summary
AccessMethod()
           
 
Method Summary
static AccessMethod create(java.lang.String resource, edu.sdsc.inca.util.ResourcesWrapper resources, java.lang.String temp)
          Scan the resource configuration specified in resources and use the remoteInvocationMethod value for the resource to create the appropriate subclass of AccessMethod.
 void get(java.lang.String[] remoteFiles, java.lang.String localDirPath)
          Transfer a list of remote files to a directory on the local machine.
 void get(java.lang.String remoteFile, java.lang.String localDirPath)
          Transfer a file from a remote machine to a local directory.
abstract  boolean isActive()
          Checks to see if the process started by start() is active.
 java.lang.String prependHome(java.lang.String path)
          Given a path relative to the home directory, prepend the home signifier for the given access method to the path and return the new string.
 void put(java.lang.String[] localFiles, java.lang.String remoteDirPath)
          Transfer a list of files to a directory on a remote machine.
 void put(java.lang.String localFile, java.lang.String remoteDirPath)
          Transfer a file to a directory on a remote machine.
 AccessMethodOutput run(java.lang.String executable, java.lang.String[] arguments)
          Run a process on a remote machine.
 AccessMethodOutput run(java.lang.String executable, java.lang.String[] arguments, java.lang.String stdin)
          Run a process on a remote machine.
abstract  AccessMethodOutput run(java.lang.String executable, java.lang.String[] arguments, java.lang.String stdin, java.lang.String directory)
          Execute the specified process on the remote resource.
 void start(java.lang.String executable, java.lang.String[] arguments)
          Start a process on a remote machine.
 void start(java.lang.String executable, java.lang.String[] arguments, java.lang.String stdin)
          Start a process on a remote machine.
abstract  void start(java.lang.String executable, java.lang.String[] arguments, java.lang.String in, java.lang.String directory)
          Start a process on a remote machine.
abstract  void stop()
          Stop the currently running process started by start().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AccessMethod

public AccessMethod()
Method Detail

create

public static AccessMethod create(java.lang.String resource,
                                  edu.sdsc.inca.util.ResourcesWrapper resources,
                                  java.lang.String temp)
                           throws edu.sdsc.inca.ConfigurationException
Scan the resource configuration specified in resources and use the remoteInvocationMethod value for the resource to create the appropriate subclass of AccessMethod.

Parameters:
resource - The name of the resource to start the process on
resources - The resource configuration information
temp - Path to a directory for temporary files to be stored
Returns:
An object of a AccessMethod subclass
Throws:
edu.sdsc.inca.ConfigurationException - unknown access method specified

get

public void get(java.lang.String remoteFile,
                java.lang.String localDirPath)
         throws AccessMethodException
Transfer a file from a remote machine to a local directory.

Parameters:
remoteFile - contains a path to the file on the remote file system
localDirPath - contains a path to a directory/file on the local machine
Throws:
AccessMethodException - if unable to fetch remote file

get

public void get(java.lang.String[] remoteFiles,
                java.lang.String localDirPath)
         throws AccessMethodException
Transfer a list of remote files to a directory on the local machine.

Parameters:
remoteFiles - list of paths to files on the remote file system
localDirPath - contains a path to a directory/file on the local machine
Throws:
AccessMethodException - if unable to fetch remote file

isActive

public abstract boolean isActive()
                          throws AccessMethodException
Checks to see if the process started by start() is active.

Returns:
true if the process is running; false otherwise.
Throws:
AccessMethodException - if unable to determine if process is active

prependHome

public java.lang.String prependHome(java.lang.String path)
Given a path relative to the home directory, prepend the home signifier for the given access method to the path and return the new string.

Parameters:
path - A path relative to the user's home directory
Returns:
A new string that contains the home signifier prepended to the provided path.

put

public void put(java.lang.String localFile,
                java.lang.String remoteDirPath)
         throws AccessMethodException
Transfer a file to a directory on a remote machine.

Parameters:
localFile - contains a path to the file on the local file system
remoteDirPath - contains a path to a directory/file on a remote machine
Throws:
AccessMethodException - if unable to transfer remote file

put

public void put(java.lang.String[] localFiles,
                java.lang.String remoteDirPath)
         throws AccessMethodException
Transfer a list of files to a directory on a remote machine.

Parameters:
localFiles - list of paths to files on the local file system
remoteDirPath - contains a path to a directory/file on a remote machine
Throws:
AccessMethodException - if unable to transfer remote file

run

public AccessMethodOutput run(java.lang.String executable,
                              java.lang.String[] arguments)
                       throws AccessMethodException,
                              java.lang.InterruptedException
Run a process on a remote machine.

Parameters:
executable - Path to the remote executable.
arguments - Contains the arguments that should be passed to the executable
Returns:
The stdout and stderr of the executed process in RemoteProcessObject.
Throws:
AccessMethodException - if unable to execute remote process
java.lang.InterruptedException - if interrupted while running remote process

run

public AccessMethodOutput run(java.lang.String executable,
                              java.lang.String[] arguments,
                              java.lang.String stdin)
                       throws AccessMethodException,
                              java.lang.InterruptedException
Run a process on a remote machine.

Parameters:
executable - Path to the remote executable.
arguments - Contains the arguments that should be passed to the executable
stdin - A string that will be passedd in as stdin to the process when it is started
Returns:
The stdout and stderr of the executed process in RemoteProcessObject.
Throws:
AccessMethodException - if unable to execute remote process
java.lang.InterruptedException - if interrupted while running remote process

run

public abstract AccessMethodOutput run(java.lang.String executable,
                                       java.lang.String[] arguments,
                                       java.lang.String stdin,
                                       java.lang.String directory)
                                throws AccessMethodException,
                                       java.lang.InterruptedException
Execute the specified process on the remote resource. This call will block until the process has completed.

Parameters:
executable - Path to the remote executable.
arguments - Contains the arguments that should be passed to the executable
stdin - A string that will be passedd in as stdin to the process when it is started
directory - Path to the directory where the process will be executed from
Returns:
The stdout and stderr of the executed process in RemoteProcessObject.
Throws:
AccessMethodException - if unable to execute remote process
java.lang.InterruptedException - if interrupted while running remote process

start

public void start(java.lang.String executable,
                  java.lang.String[] arguments)
           throws AccessMethodException
Start a process on a remote machine. This is a non-blocking call.

Parameters:
executable - Path to the remote executable.
arguments - Contains the arguments that should be passed to the executable
Throws:
AccessMethodException - if unable to start remote process

start

public void start(java.lang.String executable,
                  java.lang.String[] arguments,
                  java.lang.String stdin)
           throws AccessMethodException
Start a process on a remote machine. This is a non-blocking call.

Parameters:
executable - Path to the remote executable.
arguments - Contains the arguments that should be passed to the executable
stdin - A string that will be passedd in as stdin to the process when it is started
Throws:
AccessMethodException - if unable to start remote process

start

public abstract void start(java.lang.String executable,
                           java.lang.String[] arguments,
                           java.lang.String in,
                           java.lang.String directory)
                    throws AccessMethodException
Start a process on a remote machine. This is a non-blocking call.

Parameters:
executable - Path to the remote executable.
arguments - Contains the arguments that should be passed to the executable
in - A string that will be passedd in as stdin to the process when it is started
directory - Path to the directory where the process will be executed from
Throws:
AccessMethodException - if unable to start remote process

stop

public abstract void stop()
                   throws AccessMethodException
Stop the currently running process started by start().

Throws:
AccessMethodException - if unable to stop remote process