com.friendshipsystems.fsshresourcemanager
Interface FIJobCanceler

All Known Implementing Classes:
FJobCancelerLinux, FJobCancelerWin

public interface FIJobCanceler

The FIJobCanceler interface provides methods that create commands that need to be executed on remote host in order to find process ids of remote processes based on their executable and the executing user as well as commands that need to be executed to kill processes on remote computers. The interface is used by the SSH Resource Manager to cancel remote processes. Depending on the operating system of the remote machine there are different ways for finding out the PID of a process and for killing processes. In order to implement this interface there are five methods that need to be implemented:

The work flow is as follows: The Resource Manager connects to the remote host, opens an SSH-channel and executes the command to start the actual application. Right after that, another channel will be opened and the command line returned by getPIDCommand(String, String) is executed on the remote host in order to find out the process id of the newly started process. The output of that command is then passed on to the method getPIDFromResponse(String). This method has to parse the response, extract the process id and return it. When an application needs to be canceled, a new SSH-channel is opened and the command returned by getKillCommand(int) is executed. In order to make sure that the remote process was actually killed, another command will be executed which is requested from the getConfirmKillCommand(int) method. The output of that command is then passed on to the confirmKill(String) method which has to parse it and determine whether the response is to be interpreted as success or failure.

Author:
FRIENDSHIP SYSTEMS

Method Summary
 boolean confirmKill(java.lang.String response)
          After a kill command was issued confirmKill(String) tries to find out whether the remote process was successfully killed.
 java.lang.String getConfirmKillCommand(int pid)
          Method that returns command to issue to find out whether killing of a process succeeded.
 java.lang.String getKillCommand(int pid)
          Method to determine the command to send to the remote host in order to kill the process with the previously determined PID.
 java.lang.String getPIDCommand(java.lang.String exe, java.lang.String user)
          Method that returns the command to issue in order to determine a program's PID.
 int getPIDFromResponse(java.lang.String response)
          Method that parses the remote hosts's response to the PID request
 

Method Detail

getPIDCommand

java.lang.String getPIDCommand(java.lang.String exe,
                               java.lang.String user)
Method that returns the command to issue in order to determine a program's PID.

Parameters:
exe - The program to determine the PID for
user - The user that submitted the program
Returns:
The command to issue

getPIDFromResponse

int getPIDFromResponse(java.lang.String response)
Method that parses the remote hosts's response to the PID request

Parameters:
response - The response read after issuing the command returned from getPIDCommand(String, String).
Returns:
The PID, 0 if not successful

getKillCommand

java.lang.String getKillCommand(int pid)
Method to determine the command to send to the remote host in order to kill the process with the previously determined PID.

Parameters:
pid - The process id of the process to kill
Returns:
the command to be issued on the remote machine in order to kill the remote process

getConfirmKillCommand

java.lang.String getConfirmKillCommand(int pid)
Method that returns command to issue to find out whether killing of a process succeeded.

Parameters:
pid - The process id of the process that should be searched
Returns:
The command

confirmKill

boolean confirmKill(java.lang.String response)
After a kill command was issued confirmKill(String) tries to find out whether the remote process was successfully killed. This method is used to parse the answer received after the command returned from getConfirmKillCommand(int) was executed on the remote host.

Parameters:
response - The response received from the remote host after getConfirmKillCommand(int) was executed.
Returns:
true if the response confirms the command to be succesful, false otherwise