edu.sdsc.inca.agent.access
Class Sleep

java.lang.Object
  extended by edu.sdsc.inca.agent.AccessMethod
      extended by edu.sdsc.inca.agent.access.Sleep

public class Sleep
extends AccessMethod

Used for testing to make sure the ReporterManagerStarter class handles interrupts correctly. Can be configured to have the run method sleep on the nth call so it can be interrupted and tested to see if the run method handles the interrupt correctly.

Author:
Shava Smallen <ssmallen@sdsc.edu>

Field Summary
 java.lang.String lastCommand
           
 int numSkips
           
 int sleepOnNthTime
           
 int sleepPeriod
           
 
Constructor Summary
Sleep(java.lang.String resource, edu.sdsc.inca.util.ResourcesWrapper resources)
          Create a interrupt manual process.
 
Method Summary
 void get(java.lang.String remoteFile, java.lang.String localDir)
          Log the remote file that would be transferred to a directory on the local machine.
 boolean isActive()
          Checks to see if the current ssh session is active.
 void put(java.lang.String localFile, java.lang.String remoteDir)
          Log the file that would be transferred to a directory on a remote machine .
 AccessMethodOutput run(java.lang.String executable, java.lang.String[] arguments, java.lang.String stdin, java.lang.String directory)
          Log the command that should be executed on the remote machine.
 void start(java.lang.String executable, java.lang.String[] arguments, java.lang.String stdin, java.lang.String directory)
          Start a process on a remote machine.
 void stop()
          Just log that the process needs to be stopped.
 
Methods inherited from class edu.sdsc.inca.agent.AccessMethod
create, get, prependHome, put, run, run, start, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sleepPeriod

public int sleepPeriod

sleepOnNthTime

public int sleepOnNthTime

numSkips

public int numSkips

lastCommand

public java.lang.String lastCommand
Constructor Detail

Sleep

public Sleep(java.lang.String resource,
             edu.sdsc.inca.util.ResourcesWrapper resources)
Create a interrupt manual process.

Parameters:
resource - The name of the resource to start the process on
resources - The resource configuration information.
Method Detail

get

public void get(java.lang.String remoteFile,
                java.lang.String localDir)
         throws AccessMethodException
Log the remote file that would be transferred to a directory on the local machine.

Overrides:
get in class AccessMethod
Parameters:
remoteFile - Path to the remote file that will be transfered
localDir - Path to the directory on the local machine where the remote file will be placed
Throws:
AccessMethodException - if unable to fetch remote file

put

public void put(java.lang.String localFile,
                java.lang.String remoteDir)
         throws AccessMethodException
Log the file that would be transferred to a directory on a remote machine .

Overrides:
put in class AccessMethod
Parameters:
localFile - Path to the local file that will be transfered
remoteDir - Path to the directory on the remote machine where the local file will be placed
Throws:
AccessMethodException - if unable to transfer remote file

run

public AccessMethodOutput run(java.lang.String executable,
                              java.lang.String[] arguments,
                              java.lang.String stdin,
                              java.lang.String directory)
                       throws java.lang.InterruptedException
Log the command that should be executed on the remote machine.

Specified by:
run in class AccessMethod
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 AccessMethodOutput
Throws:
java.lang.InterruptedException - if interrupted while running remote process

start

public void start(java.lang.String executable,
                  java.lang.String[] arguments,
                  java.lang.String stdin,
                  java.lang.String directory)
Start a process on a remote machine. This is a non-blocking call. Important note: this process will not be killed on call to stop()

Specified by:
start in class AccessMethod
Parameters:
executable - Path to the remote executable.
arguments - Contains the arguments that should be passed to the executable
directory - Path to the directory where the process will be executed
stdin - A string that will be passedd in as stdin to the process when it is started

stop

public void stop()
          throws AccessMethodException
Just log that the process needs to be stopped.

Specified by:
stop in class AccessMethod
Throws:
AccessMethodException

isActive

public boolean isActive()
                 throws AccessMethodException
Checks to see if the current ssh session is active. Does not indicate whether the remote process is alive (for now).

Specified by:
isActive in class AccessMethod
Returns:
true if the SSH session is alive; false otherwise.
Throws:
AccessMethodException - if unable to determine if process is active