public abstract class ActionExecutor extends Object
All the action executors should extend this class.
Modifier and Type | Class and Description |
---|---|
static interface |
ActionExecutor.Context
Context information passed to the ActionExecutor methods.
|
static class |
ActionExecutor.RETRYPOLICY |
Modifier and Type | Field and Description |
---|---|
static String |
ACTION_RETRY_INTERVAL |
static String |
ACTION_RETRY_POLICY |
static String |
CONF_PREFIX
Configuration prefix for action executor (sub-classes) properties.
|
static String |
ERROR_OTHER
Error code used by
convertException(java.lang.Exception) when there is not register error information for an exception. |
static String |
MAX_RETRIES |
static String |
OOZIE_ACTION_YARN_TAG |
static long |
RETRY_INTERVAL
Define the default inteval in seconds between retries.
|
Modifier | Constructor and Description |
---|---|
protected |
ActionExecutor(String type)
Create an action executor with default retry parameters.
|
protected |
ActionExecutor(String type,
long defaultRetryInterval)
Create an action executor.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
check(ActionExecutor.Context context,
WorkflowAction action)
Check if an action has completed.
|
protected ActionExecutorException |
convertException(Exception ex)
Utility method to handle exceptions in the
start(org.apache.oozie.action.ActionExecutor.Context, org.apache.oozie.client.WorkflowAction) , end(org.apache.oozie.action.ActionExecutor.Context, org.apache.oozie.client.WorkflowAction) , kill(org.apache.oozie.action.ActionExecutor.Context, org.apache.oozie.client.WorkflowAction) and check(org.apache.oozie.action.ActionExecutor.Context, org.apache.oozie.client.WorkflowAction) methods |
static void |
disableInit()
Disable action type initialization.
|
static void |
enableInit()
Enable action type initialization.
|
abstract void |
end(ActionExecutor.Context context,
WorkflowAction action)
End an action after it has executed.
|
org.apache.hadoop.fs.Path |
getActionDir(String jobId,
WorkflowAction action,
String key,
boolean temp)
Return the path that will be used to store action specific data.
|
protected String |
getActionDirPath(String jobId,
WorkflowAction action,
String key,
boolean temp)
Return the path that will be used to store action specific data
|
protected String |
getActionSignal(WorkflowAction.Status status)
Convenience method that return the signal for an Action based on the action status.
|
static String |
getActionYarnTag(org.apache.hadoop.conf.Configuration conf,
WorkflowJob wfJob,
WorkflowAction action)
Creating and forwarding the tag, It will be useful during repeat attempts of Launcher, to ensure only
one child job is running.
|
int |
getMaxRetries()
Return the maximum number of retries for the action executor.
|
org.apache.hadoop.conf.Configuration |
getOozieConf()
Return Oozie configuration.
|
String |
getOozieRuntimeDir()
Return the runtime directory of the Oozie instance.
|
String |
getOozieSystemId()
Return the system ID, this ID is defined in Oozie configuration.
|
long |
getRetryInterval()
Return the retry interval for the action executor in seconds.
|
ActionExecutor.RETRYPOLICY |
getRetryPolicy()
Return the retry policy for the action executor.
|
String |
getType()
Return the action executor type.
|
void |
initActionType()
Invoked once at system initialization time.
|
abstract boolean |
isCompleted(String externalStatus)
Return if the external status indicates that the action has completed.
|
abstract void |
kill(ActionExecutor.Context context,
WorkflowAction action)
Kill an action.
|
protected void |
registerError(String exClass,
ActionExecutorException.ErrorType errorType,
String errorCode)
Register error handling information for an exception.
|
boolean |
requiresNameNodeJobTracker()
Returns true if this action type requires a NameNode and JobTracker.
|
static void |
resetInitInfo()
Clear all init settings for all action types.
|
void |
setMaxRetries(int maxRetries)
Set the maximum number of retries for the action executor.
|
void |
setRetryInterval(long retryInterval)
Sets the retry interval for the action executor.
|
void |
setRetryPolicy(ActionExecutor.RETRYPOLICY retryPolicy)
Sets the retry policy for the action executor.
|
abstract void |
start(ActionExecutor.Context context,
WorkflowAction action)
Start an action.
|
boolean |
supportsConfigurationJobXML()
Returns true if this action type supports a Configuration and JobXML.
|
public static final String CONF_PREFIX
public static final String MAX_RETRIES
public static final String ACTION_RETRY_INTERVAL
public static final String ACTION_RETRY_POLICY
public static final String OOZIE_ACTION_YARN_TAG
public static final String ERROR_OTHER
convertException(java.lang.Exception)
when there is not register error information for an exception.public static final long RETRY_INTERVAL
protected ActionExecutor(String type)
type
- action executor type.protected ActionExecutor(String type, long defaultRetryInterval)
type
- action executor type.defaultRetryInterval
- retry interval, in seconds.public static void resetInitInfo()
public static void enableInit()
public static void disableInit()
public void initActionType()
It can be used to register error information for the expected exceptions. Exceptions should be register from subclasses to superclasses to ensure proper detection, same thing that it is done in a normal catch.
This method should invoke the registerError(java.lang.String, org.apache.oozie.action.ActionExecutorException.ErrorType, java.lang.String)
method to register
all its possible errors.
Subclasses overriding must invoke super.
public String getOozieSystemId()
public String getOozieRuntimeDir()
The directory is created under TMP and it is always a new directory per system initialization.
public org.apache.hadoop.conf.Configuration getOozieConf()
This is useful for actions that need access to configuration properties.
protected void registerError(String exClass, ActionExecutorException.ErrorType errorType, String errorCode)
exClass
- exception class name (to work in case of a particular exception not being in the classpath, needed
to be able to handle multiple version of Hadoop or other JARs used by executors with the same codebase).errorType
- error type for the exception.errorCode
- error code for the exception.public int getMaxRetries()
public void setMaxRetries(int maxRetries)
maxRetries
- the maximum number of retries.public ActionExecutor.RETRYPOLICY getRetryPolicy()
public void setRetryPolicy(ActionExecutor.RETRYPOLICY retryPolicy)
retryPolicy
- retry policy for the action executor.public long getRetryInterval()
public void setRetryInterval(long retryInterval)
retryInterval
- retry interval in seconds.protected ActionExecutorException convertException(Exception ex)
start(org.apache.oozie.action.ActionExecutor.Context, org.apache.oozie.client.WorkflowAction)
, end(org.apache.oozie.action.ActionExecutor.Context, org.apache.oozie.client.WorkflowAction)
, kill(org.apache.oozie.action.ActionExecutor.Context, org.apache.oozie.client.WorkflowAction)
and check(org.apache.oozie.action.ActionExecutor.Context, org.apache.oozie.client.WorkflowAction)
methods
It uses the error registry to convert exceptions to ActionExecutorException
s.
ex
- exception to convert.protected String getActionSignal(WorkflowAction.Status status)
status
- action status.protected String getActionDirPath(String jobId, WorkflowAction action, String key, boolean temp)
jobId
- Worfklow IDaction
- Actionkey
- An Identifiertemp
- temp directory flagpublic org.apache.hadoop.fs.Path getActionDir(String jobId, WorkflowAction action, String key, boolean temp)
jobId
- Workflow IDaction
- Actionkey
- An identifiertemp
- Temp directory flagpublic abstract void start(ActionExecutor.Context context, WorkflowAction action) throws ActionExecutorException
The ActionExecutor.Context.setStartData(java.lang.String, java.lang.String, java.lang.String)
method must be called within this method.
If the
action has completed, the ActionExecutor.Context.setExecutionData(java.lang.String, java.util.Properties)
method must be called within this method.
context
- executor context.action
- the action to start.ActionExecutorException
- thrown if the action could not start.public abstract void end(ActionExecutor.Context context, WorkflowAction action) throws ActionExecutorException
The ActionExecutor.Context.setEndData(org.apache.oozie.client.WorkflowAction.Status, java.lang.String)
method must be called within this
method.
context
- executor context.action
- the action to end.ActionExecutorException
- thrown if the action could not end.public abstract void check(ActionExecutor.Context context, WorkflowAction action) throws ActionExecutorException
If the action
has completed, the ActionExecutor.Context.setExecutionData(java.lang.String, java.util.Properties)
method must be called within this method.
If the action
has not completed, the ActionExecutor.Context.setExternalStatus(java.lang.String)
method must be called within this method.
context
- executor context.action
- the action to end.ActionExecutorException
- thrown if the action could not be checked.public abstract void kill(ActionExecutor.Context context, WorkflowAction action) throws ActionExecutorException
The ActionExecutor.Context.setEndData(org.apache.oozie.client.WorkflowAction.Status, java.lang.String)
method must be called within this method.
context
- executor context.action
- the action to kill.ActionExecutorException
- thrown if the action could not be killed.public abstract boolean isCompleted(String externalStatus)
externalStatus
- external status to check.public boolean requiresNameNodeJobTracker()
public boolean supportsConfigurationJobXML()
public static String getActionYarnTag(org.apache.hadoop.conf.Configuration conf, WorkflowJob wfJob, WorkflowAction action)
conf
- the confwfJob
- the wf jobaction
- the actionCopyright © 2018 Apache Software Foundation. All rights reserved.