V - The type of the object returned by the sub tasks.T - The type of the sub task.public class CompositeTxTask<V,T extends AbstractTxTask<V>> extends AbstractTxTask<List<V>>
AbstractTxTask that executes multiple tasks
on a single transaction.
This task returns a list of results of sub tasks. The order of results in the returned list is the same as the sub tasks configured in this task. Note that all sub tasks are required to return the same type of objects.
| Constructor and Description |
|---|
CompositeTxTask(List<T> tasks)
Construct a new task.
|
| Modifier and Type | Method and Description |
|---|---|
protected List<V> |
execute(TxContext ctx)
Execute all sub tasks on the given MD-SAL transaction context.
|
List<T> |
getSubTasks()
Return an immutable list of sub tasks.
|
boolean |
needErrorLog(Throwable t)
Determine whether the transaction queue should log the given error
or not.
|
protected void |
onCompleted(TxContext ctx,
List<V> results)
Invoked when all the sub tasks have completed.
|
void |
onFailure(VTNManagerProvider provider,
Throwable t)
Invoked when the task has failed.
|
protected void |
onStarted(TxContext ctx)
Invoked when the MD-SAL datastore transaction has started.
|
void |
onSuccess(VTNManagerProvider provider,
List<V> result)
Invoked when the task has completed successfully.
|
addBackgroundTask, execute, getBackgroundTasks, getMaxRetrypublic CompositeTxTask(List<T> tasks)
tasks - A list of tasks to be executed on a single transaction.IllegalArgumentException - The given task list is empty.public final List<T> getSubTasks()
protected void onStarted(TxContext ctx) throws VTNException
ctx - A runtime context for transaction task.VTNException - An error occurred.protected void onCompleted(TxContext ctx, List<V> results) throws VTNException
ctx - A runtime context for transaction task.results - A list of sub task results.VTNException - An error occurred.protected final List<V> execute(TxContext ctx) throws VTNException
Note that this method may be called more than once when a MD-SAL datastore transaction is aborted due to data conflict.
execute in class AbstractTxTask<List<V>>ctx - A runtime context for transaction task.VTNException - An error occurred.public boolean needErrorLog(Throwable t)
By default, this method returns true.
t - A Throwable that is going to be thrown.true if an error should be logged.
false if an error log is not required.public void onSuccess(VTNManagerProvider provider, List<V> result)
This method of this class does nothing.
onSuccess in interface TxTask<List<V>>onSuccess in class AbstractTxTask<List<V>>provider - VTN Manager provider service.result - An object returned by AbstractTxTask.execute(TxContext, int).public void onFailure(VTNManagerProvider provider, Throwable t)
This method of this class does nothing.
Copyright © 2018 OpenDaylight. All rights reserved.