Interface ManagedTransactionFactory

    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method Description
      <D extends Datastore,​E extends java.lang.Exception,​R>
      R
      applyWithNewReadOnlyTransactionAndClose​(java.lang.Class<D> datastoreType, org.opendaylight.infrautils.utils.function.InterruptibleCheckedFunction<TypedReadTransaction<D>,​R,​E> txFunction)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Invokes a function with a NEW TypedReadTransaction, and ensures that that transaction is closed.
      <D extends Datastore,​E extends java.lang.Exception,​R>
      com.google.common.util.concurrent.FluentFuture<R>
      applyWithNewReadWriteTransactionAndSubmit​(java.lang.Class<D> datastoreType, org.opendaylight.infrautils.utils.function.InterruptibleCheckedFunction<TypedReadWriteTransaction<D>,​R,​E> txFunction)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Invokes a function 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.
      <D extends Datastore,​E extends java.lang.Exception>
      void
      callWithNewReadOnlyTransactionAndClose​(java.lang.Class<D> datastoreType, org.opendaylight.infrautils.utils.function.InterruptibleCheckedConsumer<TypedReadTransaction<D>,​E> txConsumer)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Invokes a function with a NEW ReadTransaction, and ensures that that transaction is closed.
      <D extends Datastore,​E extends java.lang.Exception>
      com.google.common.util.concurrent.FluentFuture<java.lang.Void>
      callWithNewReadWriteTransactionAndSubmit​(java.lang.Class<D> datastoreType, org.opendaylight.infrautils.utils.function.InterruptibleCheckedConsumer<TypedReadWriteTransaction<D>,​E> txConsumer)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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.
      <D extends Datastore,​E extends java.lang.Exception>
      com.google.common.util.concurrent.FluentFuture<java.lang.Void>
      callWithNewWriteOnlyTransactionAndSubmit​(java.lang.Class<D> datastoreType, org.opendaylight.infrautils.utils.function.InterruptibleCheckedConsumer<TypedWriteTransaction<D>,​E> txConsumer)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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.
    • Method Detail

      • applyWithNewReadOnlyTransactionAndClose

        <D extends Datastore,​E extends java.lang.Exception,​R> R applyWithNewReadOnlyTransactionAndClose​(java.lang.Class<D> datastoreType,
                                                                                                                    org.opendaylight.infrautils.utils.function.InterruptibleCheckedFunction<TypedReadTransaction<D>,​R,​E> txFunction)
                                                                                                             throws E extends java.lang.Exception,
                                                                                                                    java.lang.InterruptedException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Invokes a function with a NEW TypedReadTransaction, and ensures that that transaction is closed. Thus when this method returns, that transaction is guaranteed to have been closed, and will never "leak" and waste memory.

        The function must not itself attempt to close the transaction. (It can't directly, since TypedReadTransaction doesn't expose a close() method.)

        The provided transaction is specific to the given logical datastore type and cannot be used for any other.

        Type Parameters:
        D - DataObject subclass
        E - Exception subclass
        R - The type of result returned by the function.
        Parameters:
        datastoreType - the Datastore type that will be accessed
        txFunction - the InterruptibleCheckedFunction that needs a new read transaction
        Returns:
        the result of the function.
        Throws:
        E - if an error occurs.
        java.lang.InterruptedException - if the transaction is interrupted.
        E extends java.lang.Exception
      • applyWithNewReadWriteTransactionAndSubmit

        @CheckReturnValue
        <D extends Datastore,​E extends java.lang.Exception,​R> com.google.common.util.concurrent.FluentFuture<R> applyWithNewReadWriteTransactionAndSubmit​(java.lang.Class<D> datastoreType,
                                                                                                                                                                      org.opendaylight.infrautils.utils.function.InterruptibleCheckedFunction<TypedReadWriteTransaction<D>,​R,​E> txFunction)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Invokes a function 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 function must not itself use WriteTransaction.cancel(), or (it will throw an UnsupportedOperationException).

        The provided transaction is specific to the given logical datastore type and cannot be used for any other.

        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:
        D - DataObject subclass
        E - Exception subclass
        R - The type of result returned by the function.
        Parameters:
        datastoreType - the Datastore type that will be accessed
        txFunction - the InterruptibleCheckedFunction that needs a new read-write transaction
        Returns:
        the ListenableFuture returned by , or a failed future with an application specific exception (not from submit())
      • callWithNewReadOnlyTransactionAndClose

        <D extends Datastore,​E extends java.lang.Exception> void callWithNewReadOnlyTransactionAndClose​(java.lang.Class<D> datastoreType,
                                                                                                              org.opendaylight.infrautils.utils.function.InterruptibleCheckedConsumer<TypedReadTransaction<D>,​E> txConsumer)
                                                                                                       throws E extends java.lang.Exception,
                                                                                                              java.lang.InterruptedException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Invokes a function with a NEW ReadTransaction, and ensures that that transaction is closed. Thus when this method returns, that transaction is guaranteed to have been closed, and will never "leak" and waste memory.

        The function must not itself attempt to close the transaction. (It can't directly, since ReadTransaction doesn't expose a close() method.)

        The provided transaction is specific to the given logical datastore type and cannot be used for any other.

        Type Parameters:
        D - DataObject subclass
        E - Exception subclass
        Parameters:
        datastoreType - the Datastore type that will be accessed
        txConsumer - the InterruptibleCheckedFunction that needs a new read transaction
        Throws:
        E - if an error occurs.
        java.lang.InterruptedException - if the transaction is interrupted.
        E extends java.lang.Exception
      • callWithNewReadWriteTransactionAndSubmit

        @CheckReturnValue
        <D extends Datastore,​E extends java.lang.Exception> com.google.common.util.concurrent.FluentFuture<java.lang.Void> callWithNewReadWriteTransactionAndSubmit​(java.lang.Class<D> datastoreType,
                                                                                                                                                                          org.opendaylight.infrautils.utils.function.InterruptibleCheckedConsumer<TypedReadWriteTransaction<D>,​E> txConsumer)
        Deprecated, for removal: This API element is subject to removal in a future version.
        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).

        The provided transaction is specific to the given logical datastore type and cannot be used for any other.

        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:
        D - DataObject subclass
        E - Exception subclass
        Parameters:
        datastoreType - the Datastore type that will be accessed
        txConsumer - the InterruptibleCheckedConsumer that needs a new read-write transaction
        Returns:
        the ListenableFuture returned by , or a failed future with an application specific exception (not from submit())
      • callWithNewWriteOnlyTransactionAndSubmit

        @CheckReturnValue
        <D extends Datastore,​E extends java.lang.Exception> com.google.common.util.concurrent.FluentFuture<java.lang.Void> callWithNewWriteOnlyTransactionAndSubmit​(java.lang.Class<D> datastoreType,
                                                                                                                                                                          org.opendaylight.infrautils.utils.function.InterruptibleCheckedConsumer<TypedWriteTransaction<D>,​E> txConsumer)
        Deprecated, for removal: This API element is subject to removal in a future version.
        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).

        The provided transaction is specific to the given logical datastore type and cannot be used for any other.

        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 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:
        D - DataObject subclass
        E - Exception subclass
        Parameters:
        datastoreType - the Datastore type that will be accessed
        txConsumer - the InterruptibleCheckedConsumer that needs a new write only transaction
        Returns:
        the ListenableFuture returned by , or a failed future with an application specific exception (not from submit())