public abstract class ActionExecutor extends Object
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 |
boolean |
requiresNNJT |
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
It uses the error registry to convert exceptions to ActionExecutorException s. |
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.
|
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.
|
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.
|
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 ERROR_OTHER
convertException(java.lang.Exception)
when there is not register error information for an exception.public boolean requiresNNJT
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()
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()
public org.apache.hadoop.conf.Configuration getOozieConf()
protected void registerError(String exClass, ActionExecutorException.ErrorType errorType, String errorCode)
exClass
- excpetion 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
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
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
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
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.Copyright © 2015 Apache Software Foundation. All Rights Reserved.