T - The type of the object to be returned by the task.public abstract class AbstractTxTask<T> extends Object implements TxTask<T>
TxTask.
This class attempt to repeat the transaction at most 5 times if the transaction fails due to data conflict.
| Constructor and Description |
|---|
AbstractTxTask() |
| Modifier and Type | Method and Description |
|---|---|
void |
addBackgroundTask(VTNFuture<?> future)
Associate the given future with this task.
|
protected abstract T |
execute(TxContext ctx)
Modify the MD-SAL datastore using the given transaction.
|
T |
execute(TxContext ctx,
int attempts)
Modify the MD-SAL datastore using the given transaction.
|
List<VTNFuture<?>> |
getBackgroundTasks()
Return an immutable list of
VTNFuture instances associated with
background tasks started by the MD-SAL transaction task. |
protected int |
getMaxRetry()
Return the number of times for retrying transaction.
|
void |
onFailure(VTNManagerProvider provider,
Throwable t)
Invoked when the task has failed.
|
void |
onSuccess(VTNManagerProvider provider,
T result)
Invoked when the task has completed successfully.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisAsync, needErrorLogprotected abstract T 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.
ctx - A runtime context for transaction task.VTNException - An error occurred.protected int getMaxRetry()
This method can be used to control the number of transaction retry when the transaction failed due to data confliction.
This method in this class returns MAX_RETRY.
Subclass can override this method to change the number of times for
retrying transaction.
public final T execute(TxContext ctx, int attempts) 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 interface TxTask<T>ctx - A runtime context for transaction task.attempts - The number of calls of this method.
0 is passed for the first call.VTNException - An error occurred.public void onSuccess(VTNManagerProvider provider, T result)
This method of this class does nothing.
onSuccess in interface TxTask<T>provider - VTN Manager provider service.result - An object returned by execute(TxContext, int).public void onFailure(VTNManagerProvider provider, Throwable t)
This method of this class does nothing.
public final List<VTNFuture<?>> getBackgroundTasks()
VTNFuture instances associated with
background tasks started by the MD-SAL transaction task.getBackgroundTasks in interface TxTask<T>VTNFuture instances.
An empty list is returned if no background task has started or
this task does not complete yet.
Note that this method must not return null.public final void addBackgroundTask(VTNFuture<?> future)
The task associated with the given future will be treated as a background task associated with this task.
addBackgroundTask in interface TxTask<T>future - A VTNFuture instance associated with background
task.Copyright © 2018 OpenDaylight. All rights reserved.