org.apache.oozie.action.ssh
Class SshActionExecutor

java.lang.Object
  extended by org.apache.oozie.action.ActionExecutor
      extended by org.apache.oozie.action.ssh.SshActionExecutor

public class SshActionExecutor
extends ActionExecutor

Ssh action executor.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.oozie.action.ActionExecutor
ActionExecutor.Context
 
Field Summary
static java.lang.String ACTION_TYPE
           
static java.lang.String CONF_SSH_ALLOW_USER_AT_HOST
          Configuration parameter which specifies whether the specified ssh user is allowed, or has to be the job user.
static java.lang.String DELETE_TMP_DIR
           
static java.lang.String ERR_AUTH_FAILED
           
static java.lang.String ERR_COULD_NOT_CONNECT
           
static java.lang.String ERR_EXCEDE_LEN
           
static java.lang.String ERR_EXECUTION_FAILED
           
static java.lang.String ERR_FNF
           
static java.lang.String ERR_HOST_RESOLUTION
           
static java.lang.String ERR_NO_EXEC_PERM
           
static java.lang.String ERR_SETUP_FAILED
           
static java.lang.String ERR_UNKNOWN_ERROR
           
static java.lang.String ERR_USER_MISMATCH
           
static java.lang.String HTTP_COMMAND
           
static java.lang.String HTTP_COMMAND_OPTIONS
           
protected static java.lang.String SCP_COMMAND_BASE
           
protected static java.lang.String SSH_COMMAND_BASE
           
protected static java.lang.String SSH_COMMAND_OPTIONS
           
 
Fields inherited from class org.apache.oozie.action.ActionExecutor
CONF_PREFIX, ERROR_OTHER, MAX_RETRIES, RETRY_INTERVAL
 
Constructor Summary
protected SshActionExecutor()
           
 
Method Summary
 void check(ActionExecutor.Context context, WorkflowAction action)
          Check ssh action status.
protected  java.lang.String doExecute(java.lang.String host, java.lang.String dirLocation, java.lang.String cmnd, java.lang.String args, boolean ignoreOutput, WorkflowAction action, java.lang.String recoveryId)
          Execute the ssh command.
 void end(ActionExecutor.Context context, WorkflowAction action)
          End action execution.
 int executeCommand(java.lang.String command)
          Utility method to execute command.
protected  WorkflowAction.Status getActionStatus(ActionExecutor.Context context, WorkflowAction action)
          Get action status.
 java.lang.String getRemoteFileName(ActionExecutor.Context context, WorkflowAction action, java.lang.String fileExtension, boolean dirOnly, boolean useExtId)
          Get remote host working location.
 void initActionType()
          Initialize Action.
 boolean isCompleted(java.lang.String externalStatus)
          Return if the external status indicates that the action has completed.
 void kill(ActionExecutor.Context context, WorkflowAction action)
          Kill ssh action.
protected  java.lang.String setupRemote(java.lang.String host, ActionExecutor.Context context, WorkflowAction action)
          Do ssh action execution setup on remote host.
 void start(ActionExecutor.Context context, WorkflowAction action)
          Start the ssh action execution.
 
Methods inherited from class org.apache.oozie.action.ActionExecutor
convertException, disableInit, enableInit, getActionDir, getActionDirPath, getActionSignal, getMaxRetries, getOozieConf, getOozieRuntimeDir, getOozieSystemId, getRetryInterval, getType, registerError, resetInitInfo, setMaxRetries, setRetryInterval
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTION_TYPE

public static final java.lang.String ACTION_TYPE
See Also:
Constant Field Values

CONF_SSH_ALLOW_USER_AT_HOST

public static final java.lang.String CONF_SSH_ALLOW_USER_AT_HOST
Configuration parameter which specifies whether the specified ssh user is allowed, or has to be the job user.

See Also:
Constant Field Values

SSH_COMMAND_OPTIONS

protected static final java.lang.String SSH_COMMAND_OPTIONS
See Also:
Constant Field Values

SSH_COMMAND_BASE

protected static final java.lang.String SSH_COMMAND_BASE
See Also:
Constant Field Values

SCP_COMMAND_BASE

protected static final java.lang.String SCP_COMMAND_BASE
See Also:
Constant Field Values

ERR_SETUP_FAILED

public static final java.lang.String ERR_SETUP_FAILED
See Also:
Constant Field Values

ERR_EXECUTION_FAILED

public static final java.lang.String ERR_EXECUTION_FAILED
See Also:
Constant Field Values

ERR_UNKNOWN_ERROR

public static final java.lang.String ERR_UNKNOWN_ERROR
See Also:
Constant Field Values

ERR_COULD_NOT_CONNECT

public static final java.lang.String ERR_COULD_NOT_CONNECT
See Also:
Constant Field Values

ERR_HOST_RESOLUTION

public static final java.lang.String ERR_HOST_RESOLUTION
See Also:
Constant Field Values

ERR_FNF

public static final java.lang.String ERR_FNF
See Also:
Constant Field Values

ERR_AUTH_FAILED

public static final java.lang.String ERR_AUTH_FAILED
See Also:
Constant Field Values

ERR_NO_EXEC_PERM

public static final java.lang.String ERR_NO_EXEC_PERM
See Also:
Constant Field Values

ERR_USER_MISMATCH

public static final java.lang.String ERR_USER_MISMATCH
See Also:
Constant Field Values

ERR_EXCEDE_LEN

public static final java.lang.String ERR_EXCEDE_LEN
See Also:
Constant Field Values

DELETE_TMP_DIR

public static final java.lang.String DELETE_TMP_DIR
See Also:
Constant Field Values

HTTP_COMMAND

public static final java.lang.String HTTP_COMMAND
See Also:
Constant Field Values

HTTP_COMMAND_OPTIONS

public static final java.lang.String HTTP_COMMAND_OPTIONS
See Also:
Constant Field Values
Constructor Detail

SshActionExecutor

protected SshActionExecutor()
Method Detail

initActionType

public void initActionType()
Initialize Action.

Overrides:
initActionType in class ActionExecutor

check

public void check(ActionExecutor.Context context,
                  WorkflowAction action)
           throws ActionExecutorException
Check ssh action status.

Specified by:
check in class ActionExecutor
Parameters:
context - action execution context.
action - action object.
Throws:
ActionExecutorException - thrown if the action could not be checked.

kill

public void kill(ActionExecutor.Context context,
                 WorkflowAction action)
          throws ActionExecutorException
Kill ssh action.

Specified by:
kill in class ActionExecutor
Parameters:
context - action execution context.
action - object.
Throws:
ActionExecutorException - thrown if the action could not be killed.

start

public void start(ActionExecutor.Context context,
                  WorkflowAction action)
           throws ActionExecutorException
Start the ssh action execution.

Specified by:
start in class ActionExecutor
Parameters:
context - action execution context.
action - action object.
Throws:
ActionExecutorException - thrown if the action could not start.

getRemoteFileName

public java.lang.String getRemoteFileName(ActionExecutor.Context context,
                                          WorkflowAction action,
                                          java.lang.String fileExtension,
                                          boolean dirOnly,
                                          boolean useExtId)
Get remote host working location.

Parameters:
context - action execution context
action - Action
fileExtension - Extension to be added to file name
dirOnly - Get the Directory only
useExtId - Flag to use external ID in the path
Returns:
remote host file name/Directory.

executeCommand

public int executeCommand(java.lang.String command)
                   throws java.io.IOException,
                          java.lang.InterruptedException
Utility method to execute command.

Parameters:
command - Command to execute as String.
Returns:
exit status of the execution.
Throws:
java.io.IOException - if process exits with status nonzero.
java.lang.InterruptedException - if process does not run properly.

setupRemote

protected java.lang.String setupRemote(java.lang.String host,
                                       ActionExecutor.Context context,
                                       WorkflowAction action)
                                throws java.io.IOException,
                                       java.lang.InterruptedException
Do ssh action execution setup on remote host.

Parameters:
host - host name.
context - action execution context.
action - action object.
Returns:
remote host working directory.
Throws:
java.io.IOException - thrown if failed to setup.
java.lang.InterruptedException - thrown if any interruption happens.

doExecute

protected java.lang.String doExecute(java.lang.String host,
                                     java.lang.String dirLocation,
                                     java.lang.String cmnd,
                                     java.lang.String args,
                                     boolean ignoreOutput,
                                     WorkflowAction action,
                                     java.lang.String recoveryId)
                              throws java.io.IOException,
                                     java.lang.InterruptedException
Execute the ssh command.

Parameters:
host - hostname.
dirLocation - location of the base and wrapper scripts.
cmnd - command to be executed.
args - command arguments.
ignoreOutput - ignore output option.
action - action object.
recoveryId - action id + run number to enable recovery in rerun
Returns:
process id of the running command.
Throws:
java.io.IOException - thrown if failed to run the command.
java.lang.InterruptedException - thrown if any interruption happens.

end

public void end(ActionExecutor.Context context,
                WorkflowAction action)
         throws ActionExecutorException
End action execution.

Specified by:
end in class ActionExecutor
Parameters:
context - action execution context.
action - action object.
Throws:
ActionExecutorException - thrown if action end execution fails.

getActionStatus

protected WorkflowAction.Status getActionStatus(ActionExecutor.Context context,
                                                WorkflowAction action)
                                         throws ActionExecutorException
Get action status.

Parameters:
action - action object.
Returns:
status of the action(RUNNING/OK/ERROR).
Throws:
ActionExecutorException - thrown if there is any error in getting status.

isCompleted

public boolean isCompleted(java.lang.String externalStatus)
Description copied from class: ActionExecutor
Return if the external status indicates that the action has completed.

Specified by:
isCompleted in class ActionExecutor
Parameters:
externalStatus - external status to check.
Returns:
if the external status indicates that the action has completed.


Copyright © 2010 Yahoo. All Rights Reserved.