|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.oozie.command.Command<T,S>
public abstract class Command<T,S extends Store>
Base class for all synchronous and asynchronous DagEngine commands.
Field Summary | |
---|---|
protected boolean |
dryrun
|
protected Instrumentation |
instrumentation
|
protected static long |
LOCK_FAILURE_REQUEUE_INTERVAL
|
Constructor Summary | |
---|---|
Command(String name,
String type,
int priority,
int logMask)
Create a command that uses a WorkflowStore instance. |
|
Command(String name,
String type,
int priority,
int logMask,
boolean withStore)
Create a command. |
|
Command(String name,
String type,
int priority,
int logMask,
boolean withStore,
boolean dryrun)
Create a command. |
Method Summary | |
---|---|
T |
call()
Execute the command #call(WorkflowStore) setting all the necessary context. |
protected abstract T |
call(S store)
DagCallable subclasses must implement this method to perform their task. |
protected T |
execute(S store)
|
long |
getCreatedTime()
Returns the createdTime of the callable in milliseconds |
String |
getEntityKey()
Get command lock key returning the key as an entity key, [not used] Just to be able to implement XCallable [to be deprecated] |
protected Instrumentation |
getInstrumentation()
Return the Instrumentation instance in use. |
String |
getKey()
Get command key |
String |
getName()
Return the name of the command. |
int |
getPriority()
Return the priority of the command. |
protected abstract Class<? extends Store> |
getStoreClass()
Command subclasses must implement this method correct Store can be passed to call(store); |
String |
getType()
Return the callable type. |
protected void |
incrCommandCounter(int count)
Used to increment command counters. |
protected void |
incrJobCounter(int count)
Used to increment job counters. |
protected void |
incrJobCounter(String name,
int count)
Used to increment job counters. |
boolean |
inInterruptMode()
[to be deprecated] |
protected boolean |
lock(String id)
|
protected void |
logQueueCallableFalse(List<? extends XCallable<Void>> callables)
Logging the info if failed to queue the callables. |
protected void |
queueCallable(List<? extends XCallable<Void>> callables)
Queue a list of callables for execution after the current callable call invocation completes and the WorkflowStore transaction commits. |
protected void |
queueCallable(XCallable<Void> callable)
Queue a callable for execution after the current callable call invocation completes and the WorkflowStore
transaction commits. |
protected void |
queueCallable(XCallable<Void> callable,
long delay)
Queue a callable for delayed execution after the current callable call invocation completes and the WorkflowStore transaction commits. |
protected void |
queueCallableForException(XCallable<Void> callable)
Queue a callable for execution only in the event of an exception being thrown during the call invocation. |
protected void |
resetLogInfoAction()
Reset the action bean information from the log info. |
protected void |
resetLogInfoWorkflow()
Reset the workflow bean information from the log info. |
void |
setInterruptMode(boolean mode)
set the mode of execution for the callable. |
protected void |
setLogInfo(CoordinatorActionBean action)
Set the log info with the context of the given coordinator action bean. |
protected void |
setLogInfo(CoordinatorJobBean cBean)
Set the log info with the context of the given coordinator bean. |
protected void |
setLogInfo(WorkflowActionBean action)
Set the log info with the context of the given action bean. |
protected void |
setLogInfo(WorkflowJobBean workflow)
Set the log info with the context of the given workflow bean. |
String |
toString()
Return the identity. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final long LOCK_FAILURE_REQUEUE_INTERVAL
protected Instrumentation instrumentation
protected boolean dryrun
Constructor Detail |
---|
public Command(String name, String type, int priority, int logMask)
WorkflowStore
instance. The current XLog.Info
values are
captured for execution.
name
- command name.type
- command type.priority
- priority of the command, used when queuing for asynchronous execution.logMask
- log mask for the command logging calls.public Command(String name, String type, int priority, int logMask, boolean withStore)
XLog.Info
values are captured for execution.
name
- command name.type
- command type.priority
- priority of the command, used when queuing for asynchronous execution.logMask
- log mask for the command logging calls.withStore
- indicates if the command needs a WorkflowStore
instance or not.public Command(String name, String type, int priority, int logMask, boolean withStore, boolean dryrun)
XLog.Info
values are captured for execution.
name
- command name.type
- command type.priority
- priority of the command, used when queuing for asynchronous execution.logMask
- log mask for the command logging calls.withStore
- indicates if the command needs a WorkflowStore
instance or not.dryrun
- indicates if dryrun option is enabled. if enabled coordinator will show a diagnostic output without
really submitting the jobMethod 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>
public final T call() throws CommandException
#call(WorkflowStore)
setting all the necessary context. The XLog.Info
is
set to the values at instance creation time. The command execution is logged and instrumented. If a
WorkflowStore
is used, a fresh instance will be passed and it will be commited after the #call(WorkflowStore)
execution. It will be closed without committing if an exception is thrown. Commands
queued via the DagCommand queue methods are queued for execution after the workflow store has been committed.
If an exception happends the queued commands will not be effectively queued for execution. Instead, the the
commands queued for exception will be effectively queued fro execution..
call
in interface Callable<T>
CommandException
- thrown if the command could not be executed successfully, the workflow store is closed
without committing, thus doing a rollback.protected void queueCallable(XCallable<Void> callable)
WorkflowStore
transaction commits. All queued callables, regardless of the number of queue invocations, are queued for a
single serial execution. If the call invocation throws an exception all queued callables are discarded, they
are not queued for execution.
callable
- callable to queue for execution.protected void queueCallable(List<? extends XCallable<Void>> callables)
WorkflowStore
transaction commits. All queued callables, regardless of the number of queue invocations, are
queued for a single serial execution. If the call invocation throws an exception all queued callables are
discarded, they are not queued for execution.
callables
- list of callables to queue for execution.protected void queueCallable(XCallable<Void> callable, long delay)
WorkflowStore
transaction commits. All queued delayed callables, regardless of the number of delay queue
invocations, are queued for a single serial delayed execution with the highest delay of all queued callables.
If the call invocation throws an exception all queued callables are discarded, they are not queued for
execution.
callable
- callable to queue for delayed execution.delay
- the queue delay in millisecondsprotected void queueCallableForException(XCallable<Void> callable)
callable
- callable to queue for execution in the case of an exception.protected void logQueueCallableFalse(List<? extends XCallable<Void>> callables)
callables
- protected abstract T call(S store) throws StoreException, CommandException
store
- the workflow store instance for the callable, null
if the callable does not use a
store.
StoreException
- thrown if the workflow store could not perform an operation.
CommandException
- thrown if the command could not perform its operation.protected abstract Class<? extends Store> getStoreClass()
CommandException
- thrown if the command could not perform its operation.protected void setLogInfo(CoordinatorJobBean cBean)
cBean
- coordinator bean.protected void setLogInfo(CoordinatorActionBean action)
action
- action bean.protected void setLogInfo(WorkflowJobBean workflow)
workflow
- workflow bean.protected void setLogInfo(WorkflowActionBean action)
action
- action bean.protected void resetLogInfoAction()
protected void resetLogInfoWorkflow()
protected void incrCommandCounter(int count)
count
- the increment count.protected void incrJobCounter(int count)
count
- the increment count.protected void incrJobCounter(String name, int count)
name
- the job name.count
- the increment count.protected Instrumentation getInstrumentation()
Instrumentation
instance in use.
Instrumentation
instance in use.public String toString()
toString
in class Object
protected boolean lock(String id) throws InterruptedException
InterruptedException
protected T execute(S store) throws CommandException, StoreException
CommandException
StoreException
public String getKey()
getKey
in interface XCallable<T>
public String getEntityKey()
getEntityKey
in interface XCallable<T>
public void setInterruptMode(boolean mode)
setInterruptMode
in interface XCallable<T>
public boolean inInterruptMode()
inInterruptMode
in interface XCallable<T>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |