@Beta
public interface ManagedNewTransactionRunner
This should typically be used (only) in code which really must be creating its own new transactions, such as RPC entry points, or background jobs.
| Modifier and Type | Method and Description |
|---|---|
com.google.common.util.concurrent.ListenableFuture<Void> |
callWithNewReadWriteTransactionAndSubmit(CheckedConsumer<org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction> txRunner)
Invokes a consumer with a NEW
ReadWriteTransaction, and then submits that transaction and
returns the Future from that submission, or cancels it if an exception was thrown and returns a failed
future with that exception. |
com.google.common.util.concurrent.ListenableFuture<Void> |
callWithNewWriteOnlyTransactionAndSubmit(CheckedConsumer<org.opendaylight.controller.md.sal.binding.api.WriteTransaction> txRunner)
Invokes a consumer with a NEW
WriteTransaction, and then submits that transaction and
returns the Future from that submission, or cancels it if an exception was thrown and returns a failed
future with that exception. |
@CheckReturnValue com.google.common.util.concurrent.ListenableFuture<Void> callWithNewWriteOnlyTransactionAndSubmit(CheckedConsumer<org.opendaylight.controller.md.sal.binding.api.WriteTransaction> txRunner)
WriteTransaction, and then submits that transaction and
returns the Future from that submission, or cancels it if an exception was thrown and returns a failed
future with that exception. Thus when this method returns, that transaction is guaranteed to have
been either submitted or cancelled, and will never "leak" and waste memory.
The consumer should not (cannot) itself use
AsyncWriteTransaction.cancel(), AsyncWriteTransaction.commit() or
AsyncWriteTransaction.submit() (it will throw an UnsupportedOperationException).
This is an asynchronous API, like DataBroker's own;
when returning from this method, the operation of the Transaction may well still be ongoing in the background,
or pending;
calling code therefore must handle the returned future, e.g. by passing it onwards (return),
or by itself adding callback listeners to it using Futures' methods, or by transforming it into a
CompletionStage using infrautils' ListenableFutures and chaining on
that, or at the very least simply by using
ListenableFutures' addErrorLogging()
(but better NOT by using the blocking Future.get() on it).
txRunner - the CheckedConsumer that needs a new write only transactionListenableFuture returned by AsyncWriteTransaction.submit(),
or a failed future with an application specific exception (not from submit())@CheckReturnValue com.google.common.util.concurrent.ListenableFuture<Void> callWithNewReadWriteTransactionAndSubmit(CheckedConsumer<org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction> txRunner)
ReadWriteTransaction, and then submits that transaction and
returns the Future from that submission, or cancels it if an exception was thrown and returns a failed
future with that exception. Thus when this method returns, that transaction is guaranteed to have
been either submitted or cancelled, and will never "leak" and waste memory.
The consumer should not (cannot) itself use
AsyncWriteTransaction.cancel(), AsyncWriteTransaction.commit() or
AsyncWriteTransaction.submit() (it will throw an UnsupportedOperationException).
This is an asynchronous API, like DataBroker's own;
when returning from this method, the operation of the Transaction may well still be ongoing in the background,
or pending;
calling code therefore must handle the returned future, e.g. by passing it onwards (return),
or by itself adding callback listeners to it using Futures' methods, or by transforming it into a
CompletionStage using infrautils' ListenableFutures and chaining on
that, or at the very least simply by using
ListenableFutures' addErrorLogging
(but better NOT by using the blocking Future.get() on it).
txRunner - the CheckedConsumer that needs a new read-write transactionListenableFuture returned by AsyncWriteTransaction.submit(),
or a failed future with an application specific exception (not from submit())Copyright © 2018 OpenDaylight. All rights reserved.