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 String ACTION_TYPE
           
static 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 String DELETE_TMP_DIR
           
static String ERR_AUTH_FAILED
           
static String ERR_COULD_NOT_CONNECT
           
static String ERR_EXCEDE_LEN
           
static String ERR_EXECUTION_FAILED
           
static String ERR_FNF
           
static String ERR_HOST_RESOLUTION
           
static String ERR_NO_EXEC_PERM
           
static String ERR_SETUP_FAILED
           
static String ERR_UNKNOWN_ERROR
           
static String ERR_USER_MISMATCH
           
static String HTTP_COMMAND
           
static String HTTP_COMMAND_OPTIONS
           
protected static String SCP_COMMAND_BASE
           
protected static String SSH_COMMAND_BASE
           
protected static String SSH_COMMAND_OPTIONS
           
 
Fields inherited from class org.apache.oozie.action.ActionExecutor
CONF_PREFIX, ERROR_OTHER, MAX_RETRIES, requiresNNJT, RETRY_INTERVAL
 
Constructor Summary
protected SshActionExecutor()
           
 
Method Summary
 void check(ActionExecutor.Context context, org.apache.oozie.client.WorkflowAction action)
          Check ssh action status.
protected  String doExecute(String host, String dirLocation, String cmnd, String[] args, boolean ignoreOutput, org.apache.oozie.client.WorkflowAction action, String recoveryId, boolean preserveArgs)
          Execute the ssh command.
 void end(ActionExecutor.Context context, org.apache.oozie.client.WorkflowAction action)
          End action execution.
 int executeCommand(String command)
          Utility method to execute command.
protected  org.apache.oozie.client.WorkflowAction.Status getActionStatus(ActionExecutor.Context context, org.apache.oozie.client.WorkflowAction action)
          Get action status.
 String getRemoteFileName(ActionExecutor.Context context, org.apache.oozie.client.WorkflowAction action, String fileExtension, boolean dirOnly, boolean useExtId)
          Get remote host working location.
 void initActionType()
          Initialize Action.
 boolean isCompleted(String externalStatus)
          Return if the external status indicates that the action has completed.
 void kill(ActionExecutor.Context context, org.apache.oozie.client.WorkflowAction action)
          Kill ssh action.
protected  String setupRemote(String host, ActionExecutor.Context context, org.apache.oozie.client.WorkflowAction action)
          Do ssh action execution setup on remote host.
 void start(ActionExecutor.Context context, org.apache.oozie.client.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 String ACTION_TYPE
See Also:
Constant Field Values

CONF_SSH_ALLOW_USER_AT_HOST

public static final 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 String SSH_COMMAND_OPTIONS
See Also:
Constant Field Values

SSH_COMMAND_BASE

protected static final String SSH_COMMAND_BASE
See Also:
Constant Field Values

SCP_COMMAND_BASE

protected static final String SCP_COMMAND_BASE
See Also:
Constant Field Values

ERR_SETUP_FAILED

public static final String ERR_SETUP_FAILED
See Also:
Constant Field Values

ERR_EXECUTION_FAILED

public static final String ERR_EXECUTION_FAILED
See Also:
Constant Field Values

ERR_UNKNOWN_ERROR

public static final String ERR_UNKNOWN_ERROR
See Also:
Constant Field Values

ERR_COULD_NOT_CONNECT

public static final String ERR_COULD_NOT_CONNECT
See Also:
Constant Field Values

ERR_HOST_RESOLUTION

public static final String ERR_HOST_RESOLUTION
See Also:
Constant Field Values

ERR_FNF

public static final String ERR_FNF
See Also:
Constant Field Values

ERR_AUTH_FAILED

public static final String ERR_AUTH_FAILED
See Also:
Constant Field Values

ERR_NO_EXEC_PERM

public static final String ERR_NO_EXEC_PERM
See Also:
Constant Field Values

ERR_USER_MISMATCH

public static final String ERR_USER_MISMATCH
See Also:
Constant Field Values

ERR_EXCEDE_LEN

public static final String ERR_EXCEDE_LEN
See Also:
Constant Field Values

DELETE_TMP_DIR

public static final String DELETE_TMP_DIR
See Also:
Constant Field Values

HTTP_COMMAND

public static final String HTTP_COMMAND
See Also:
Constant Field Values

HTTP_COMMAND_OPTIONS

public static final 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,
                  org.apache.oozie.client.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,
                 org.apache.oozie.client.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,
                  org.apache.oozie.client.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 String getRemoteFileName(ActionExecutor.Context context,
                                org.apache.oozie.client.WorkflowAction action,
                                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(String command)
                   throws IOException,
                          InterruptedException
Utility method to execute command.

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

setupRemote

protected String setupRemote(String host,
                             ActionExecutor.Context context,
                             org.apache.oozie.client.WorkflowAction action)
                      throws IOException,
                             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:
IOException - thrown if failed to setup.
InterruptedException - thrown if any interruption happens.

doExecute

protected String doExecute(String host,
                           String dirLocation,
                           String cmnd,
                           String[] args,
                           boolean ignoreOutput,
                           org.apache.oozie.client.WorkflowAction action,
                           String recoveryId,
                           boolean preserveArgs)
                    throws IOException,
                           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
preserveArgs - tell the ssh scripts to preserve or flatten the arguments
Returns:
process id of the running command.
Throws:
IOException - thrown if failed to run the command.
InterruptedException - thrown if any interruption happens.

end

public void end(ActionExecutor.Context context,
                org.apache.oozie.client.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 org.apache.oozie.client.WorkflowAction.Status getActionStatus(ActionExecutor.Context context,
                                                                        org.apache.oozie.client.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(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 © 2013 Apache Software Foundation. All Rights Reserved.