| 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.oozie.command.XCommand<T>
public abstract class XCommand<T>
Base class for synchronous and asynchronous commands.
It enables by API the following pattern:
| Field Summary | |
|---|---|
static String | 
DEFAULT_LOCK_TIMEOUT
 | 
static Long | 
DEFAULT_REQUEUE_DELAY
 | 
protected  boolean | 
dryrun
 | 
protected  Instrumentation | 
instrumentation
 | 
static String | 
INSTRUMENTATION_GROUP
 | 
 XLog | 
LOG
 | 
protected  XLog.Info | 
logInfo
 | 
| Constructor Summary | |
|---|---|
XCommand(String name,
                 String type,
                 int priority)
Create a command.  | 
|
XCommand(String name,
                 String type,
                 int priority,
                 boolean dryrun)
 | 
|
| Method Summary | |
|---|---|
 T | 
call()
Implements the XCommand life-cycle.  | 
protected  void | 
eagerLoadState()
Load the necessary state to perform an eager precondition check.  | 
protected  void | 
eagerVerifyPrecondition()
Verify the precondition for the command before obtaining a lock.  | 
protected abstract  T | 
execute()
Command execution body.  | 
 long | 
getCreatedTime()
Returns the creation time of the command.  | 
protected abstract  String | 
getEntityKey()
Return the entity key for the command.  | 
protected  Instrumentation | 
getInstrumentation()
Return the Instrumentation instance in use. | 
 String | 
getKey()
Get command key  | 
protected  long | 
getLockTimeOut()
Return the time out when acquiring a lock.  | 
 XLog | 
getLog()
Get XLog log  | 
 String | 
getName()
Return the command name.  | 
 int | 
getPriority()
Return the priority of the command.  | 
protected  Long | 
getRequeueDelay()
Return the delay time for requeue  | 
 String | 
getType()
Return the callable type.  | 
protected abstract  boolean | 
isLockRequired()
Indicate if the the command requires locking.  | 
protected  boolean | 
isReQueueRequired()
Indicate if the the command requires to requeue itself if the lock is not acquired.  | 
protected abstract  void | 
loadState()
Load the necessary state to perform the precondition check and to execute the command.  | 
protected  void | 
queue(XCommand<?> command)
Queue a command for execution after the current command execution completes.  | 
protected  void | 
queue(XCommand<?> command,
           long msDelay)
Queue a command for delayed execution after the current command execution completes.  | 
 void | 
resetUsed()
 | 
protected abstract  void | 
verifyPrecondition()
Verify the precondition for the command after a lock has been obtain, just before executing the command.  | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
public static final String DEFAULT_LOCK_TIMEOUT
public static final String INSTRUMENTATION_GROUP
public static final Long DEFAULT_REQUEUE_DELAY
public XLog LOG
protected boolean dryrun
protected Instrumentation instrumentation
protected XLog.Info logInfo
| Constructor Detail | 
|---|
public XCommand(String name,
                String type,
                int priority)
name - command name.type - command type.priority - command priority.
public XCommand(String name,
                String type,
                int priority,
                boolean dryrun)
name - command name.type - command type.priority - command priority.dryrun - indicates if dryrun option is enabled. if enabled bundle will show a diagnostic output without
        really running the job| Method Detail | 
|---|
public String getName()
getName in interface XCallable<T>public String getType()
CallableQueueService.
getType in interface XCallable<T>public int getPriority()
getPriority in interface XCallable<T>public long getCreatedTime()
getCreatedTime in interface XCallable<T>protected void queue(XCommand<?> command)
command - command to queue.
protected void queue(XCommand<?> command,
                     long msDelay)
command - command to queue.msDelay - delay in milliseconds.
public final T call()
             throws CommandException
call in interface Callable<T>Exception - thrown if the command could not be executed.
CommandExceptionprotected long getLockTimeOut()
protected abstract boolean isLockRequired()
true/falseprotected abstract String getEntityKey()
protected boolean isReQueueRequired()
true/false
protected void eagerLoadState()
                       throws CommandException
CommandException
protected void eagerVerifyPrecondition()
                                throws CommandException,
                                       PreconditionException
CommandException - thrown if the precondition is not met.
PreconditionException
protected abstract void loadState()
                           throws CommandException
CommandException
protected abstract void verifyPrecondition()
                                    throws CommandException,
                                           PreconditionException
CommandException - thrown if the precondition is not met.
PreconditionException
protected abstract T execute()
                      throws CommandException
CommandException - thrown if the command execution failed.protected Instrumentation getInstrumentation()
Instrumentation instance in use.
Instrumentation instance in use.public void resetUsed()
used - set false to the usedprotected Long getRequeueDelay()
public String getKey()
getKey in interface XCallable<T>public XLog getLog()
  | 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||