org.apache.oozie.command.wf
Class ActionXCommand<T>

java.lang.Object
  extended by org.apache.oozie.command.XCommand<T>
      extended by org.apache.oozie.command.wf.WorkflowXCommand<Void>
          extended by org.apache.oozie.command.wf.ActionXCommand<T>
All Implemented Interfaces:
Callable<Void>, XCallable<Void>
Direct Known Subclasses:
ActionCheckXCommand, ActionEndXCommand, ActionKillXCommand, ActionStartXCommand

public abstract class ActionXCommand<T>
extends WorkflowXCommand<Void>

Base class for Action execution commands. Provides common functionality to handle different types of errors while attempting to start or end an action.


Nested Class Summary
static class ActionXCommand.ActionExecutorContext
          Workflow action executor context
 
Field Summary
protected static String INSTR_FAILED_JOBS_COUNTER
           
protected static String RECOVERY_ID_SEPARATOR
           
 
Fields inherited from class org.apache.oozie.command.XCommand
DEFAULT_LOCK_TIMEOUT, DEFAULT_REQUEUE_DELAY, dryrun, instrumentation, LOG, logInfo
 
Constructor Summary
ActionXCommand(String name, String type, int priority)
           
 
Method Summary
protected  void addActionCron(String type, Instrumentation.Cron cron)
          Adding a cron for the instrumentation time for the given Instrumentation group
 void failJob(ActionExecutor.Context context)
          Fail the job due to failed action
protected  void handleError(ActionExecutor.Context context, ActionExecutor executor, String message, boolean isStart, org.apache.oozie.client.WorkflowAction.Status status)
          Takes care of errors.
protected  void handleNonTransient(ActionExecutor.Context context, ActionExecutor executor, org.apache.oozie.client.WorkflowAction.Status status)
          Takes care of non transient failures.
protected  boolean handleTransient(ActionExecutor.Context context, ActionExecutor executor, org.apache.oozie.client.WorkflowAction.Status status)
          Takes care of Transient failures.
 boolean handleUserRetry(WorkflowActionBean action)
          Execute retry for action if this action is eligible for user-retry
protected  void incrActionCounter(String type, int count)
          Increment the action counter in the instrumentation log.
 
Methods inherited from class org.apache.oozie.command.XCommand
call, eagerLoadState, eagerVerifyPrecondition, execute, executeInterrupts, getCreatedTime, getEntityKey, getInstrumentation, getKey, getLockTimeOut, getLog, getName, getPriority, getRequeueDelay, getType, inInterruptMode, isLockRequired, isReQueueRequired, loadState, queue, queue, resetUsed, setInterruptMode, verifyPrecondition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTR_FAILED_JOBS_COUNTER

protected static final String INSTR_FAILED_JOBS_COUNTER
See Also:
Constant Field Values

RECOVERY_ID_SEPARATOR

protected static final String RECOVERY_ID_SEPARATOR
See Also:
Constant Field Values
Constructor Detail

ActionXCommand

public ActionXCommand(String name,
                      String type,
                      int priority)
Method Detail

handleTransient

protected boolean handleTransient(ActionExecutor.Context context,
                                  ActionExecutor executor,
                                  org.apache.oozie.client.WorkflowAction.Status status)
                           throws CommandException
Takes care of Transient failures. Sets the action status to retry and increments the retry count if not enough attempts have been made. Otherwise returns false.

Parameters:
context - the execution context.
executor - the executor instance being used.
status - the status to be set for the action.
Returns:
true if the action is scheduled for another retry. false if the number of retries has exceeded the maximum number of configured retries.
Throws:
CommandException - thrown if unable to handle transient

handleNonTransient

protected void handleNonTransient(ActionExecutor.Context context,
                                  ActionExecutor executor,
                                  org.apache.oozie.client.WorkflowAction.Status status)
                           throws CommandException
Takes care of non transient failures. The job is suspended, and the state of the action is changed to *MANUAL and set pending flag of action to false

Parameters:
context - the execution context.
executor - the executor instance being used.
status - the status to be set for the action.
Throws:
CommandException - thrown if unable to suspend job

handleError

protected void handleError(ActionExecutor.Context context,
                           ActionExecutor executor,
                           String message,
                           boolean isStart,
                           org.apache.oozie.client.WorkflowAction.Status status)
                    throws CommandException
Takes care of errors.

For errors while attempting to start the action, the job state is updated and an ActionEndCommand is queued.

For errors while attempting to end the action, the job state is updated.

Parameters:
context - the execution context.
executor - the executor instance being used.
message -
isStart - whether the error was generated while starting or ending an action.
status - the status to be set for the action.
Throws:
CommandException - thrown if unable to handle action error

failJob

public void failJob(ActionExecutor.Context context)
             throws CommandException
Fail the job due to failed action

Parameters:
context - the execution context.
Throws:
CommandException - thrown if unable to fail job

handleUserRetry

public boolean handleUserRetry(WorkflowActionBean action)
                        throws CommandException
Execute retry for action if this action is eligible for user-retry

Parameters:
context - the execution context.
Returns:
true if user-retry has to be handled for this action
Throws:
CommandException - thrown if unable to fail job

incrActionCounter

protected void incrActionCounter(String type,
                                 int count)
Increment the action counter in the instrumentation log. indicating how many times the action was executed since the start Oozie server


addActionCron

protected void addActionCron(String type,
                             Instrumentation.Cron cron)
Adding a cron for the instrumentation time for the given Instrumentation group



Copyright © 2013 Apache Software Foundation. All Rights Reserved.