Interface ManagedNewTransactionRunner

  • All Superinterfaces:
    ManagedTransactionFactory
    All Known Implementing Classes:
    ManagedNewTransactionRunnerImpl, RetryingManagedNewTransactionRunner

    @Beta
    @Deprecated(forRemoval=true)
    public interface ManagedNewTransactionRunner
    extends ManagedTransactionFactory
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use ManagedNewTransactionRunner instead.
    Managed transactions utility to simplify handling of new transactions and ensure they are always closed. Implementation in ManagedNewTransactionRunnerImpl, alternative implementation of this API with optional retries is RetryingManagedNewTransactionRunner.

    This should typically be used (only) directly in code which really must be creating its own new transactions, such as RPC entry points, or background jobs. Other lower level code "behind" such entry points should just get handed over the transaction provided by this API.

    • Method Detail

      • callWithNewWriteOnlyTransactionAndSubmit

        @CheckReturnValue
        @Deprecated
        <E extends java.lang.Exception> com.google.common.util.concurrent.ListenableFuture<java.lang.Void> callWithNewWriteOnlyTransactionAndSubmit​(org.opendaylight.infrautils.utils.function.InterruptibleCheckedConsumer<org.opendaylight.mdsal.binding.api.WriteTransaction,​E> txConsumer)
        Deprecated.
        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. 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 WriteTransaction.cancel(), or (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 and chaining on that, or at the very least simply by using LoggingFutures.addErrorLogging(ListenableFuture, org.slf4j.Logger, String) (but better NOT by using the blocking Future.get() on it).

        Type Parameters:
        E - Exception subclass
        Parameters:
        txConsumer - the CheckedConsumer that needs a new write only transaction
        Returns:
        the ListenableFuture returned by , or a failed future with an application specific exception (not from submit())
      • callWithNewReadWriteTransactionAndSubmit

        @CheckReturnValue
        @Deprecated
        <E extends java.lang.Exception> com.google.common.util.concurrent.ListenableFuture<java.lang.Void> callWithNewReadWriteTransactionAndSubmit​(org.opendaylight.infrautils.utils.function.InterruptibleCheckedConsumer<org.opendaylight.mdsal.binding.api.ReadWriteTransaction,​E> txConsumer)
        Deprecated.
        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. 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 WriteTransaction.cancel(), or (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 and chaining on that, or at the very least simply by using LoggingFutures.addErrorLogging(ListenableFuture, org.slf4j.Logger, String) (but better NOT by using the blocking Future.get() on it).

        Type Parameters:
        E - Exception subclass
        Parameters:
        txConsumer - the CheckedConsumer that needs a new read-write transaction
        Returns:
        the ListenableFuture returned by , or a failed future with an application specific exception (not from submit())
      • applyWithNewTransactionChainAndClose

        <R> R applyWithNewTransactionChainAndClose​(java.util.function.Function<ManagedTransactionChain,​R> chainConsumer)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Invokes a function with a new ManagedTransactionChain, which is a wrapper around standard transaction chains providing managed semantics. The transaction chain will be closed when the function returns.

        This is an asynchronous API, like DataBroker's own; when this method returns, the transactions in the chain may well still be ongoing in the background, or pending. It is up to the consumer and caller to agree on how failure will be handled; for example, the return type can include the futures corresponding to the transactions in the chain. The implementation uses a default transaction chain listener which logs an error if any of the transactions fail.

        The MD-SAL transaction chain semantics are preserved: each transaction in the chain will see the results of the previous transactions in the chain, even if they haven't been fully committed yet; and any error will result in subsequent transactions in the chain not being submitted.

        Type Parameters:
        R - The type of result returned by the function.
        Parameters:
        chainConsumer - The InterruptibleCheckedFunction that will build transactions in the transaction chain.
        Returns:
        The result of the function call.