public interface ManagedTransactionFactory
Modifier and Type | Method and Description |
---|---|
<D extends Datastore,E extends Exception,R> |
applyWithNewReadOnlyTransactionAndClose(Class<D> datastoreType,
org.opendaylight.infrautils.utils.function.InterruptibleCheckedFunction<TypedReadTransaction<D>,R,E> txFunction)
Invokes a function with a NEW
TypedReadTransaction , and ensures that that transaction is closed. |
<D extends Datastore,E extends Exception,R> |
applyWithNewReadWriteTransactionAndSubmit(Class<D> datastoreType,
org.opendaylight.infrautils.utils.function.InterruptibleCheckedFunction<TypedReadWriteTransaction<D>,R,E> txFunction)
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 Exception> |
callWithNewReadOnlyTransactionAndClose(Class<D> datastoreType,
org.opendaylight.infrautils.utils.function.InterruptibleCheckedConsumer<TypedReadTransaction<D>,E> txConsumer)
Invokes a function with a NEW
ReadTransaction , and ensures that that transaction is closed. |
<D extends Datastore,E extends Exception> |
callWithNewReadWriteTransactionAndSubmit(Class<D> datastoreType,
org.opendaylight.infrautils.utils.function.InterruptibleCheckedConsumer<TypedReadWriteTransaction<D>,E> txConsumer)
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 Exception> |
callWithNewWriteOnlyTransactionAndSubmit(Class<D> datastoreType,
org.opendaylight.infrautils.utils.function.InterruptibleCheckedConsumer<TypedWriteTransaction<D>,E> txConsumer)
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. |
<D extends Datastore,E extends Exception,R> R applyWithNewReadOnlyTransactionAndClose(Class<D> datastoreType, org.opendaylight.infrautils.utils.function.InterruptibleCheckedFunction<TypedReadTransaction<D>,R,E> txFunction) throws E extends Exception, InterruptedException
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.
datastoreType
- the Datastore
type that will be accessedtxFunction
- the InterruptibleCheckedFunction
that needs a new read transactionE
- if an error occurs.InterruptedException
- if the transaction is interrupted.E extends Exception
@CheckReturnValue <D extends Datastore,E extends Exception,R> com.google.common.util.concurrent.FluentFuture<R> applyWithNewReadWriteTransactionAndSubmit(Class<D> datastoreType, org.opendaylight.infrautils.utils.function.InterruptibleCheckedFunction<TypedReadWriteTransaction<D>,R,E> txFunction)
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
AsyncWriteTransaction.cancel()
, or
AsyncWriteTransaction.submit()
(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 ListenableFutures.toCompletionStage(ListenableFuture)
and chaining on
that, or at the very least simply by using
ListenableFutures.addErrorLogging(ListenableFuture, org.slf4j.Logger, String)
(but better NOT by using the blocking Future.get()
on it).
datastoreType
- the Datastore
type that will be accessedtxFunction
- the InterruptibleCheckedFunction
that needs a new read-write transactionListenableFuture
returned by AsyncWriteTransaction.submit()
,
or a failed future with an application specific exception (not from submit())<D extends Datastore,E extends Exception> void callWithNewReadOnlyTransactionAndClose(Class<D> datastoreType, org.opendaylight.infrautils.utils.function.InterruptibleCheckedConsumer<TypedReadTransaction<D>,E> txConsumer) throws E extends Exception, InterruptedException
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.
datastoreType
- the Datastore
type that will be accessedtxConsumer
- the InterruptibleCheckedFunction
that needs a new read transactionE
- if an error occurs.InterruptedException
- if the transaction is interrupted.E extends Exception
@CheckReturnValue <D extends Datastore,E extends Exception> com.google.common.util.concurrent.FluentFuture<Void> callWithNewReadWriteTransactionAndSubmit(Class<D> datastoreType, org.opendaylight.infrautils.utils.function.InterruptibleCheckedConsumer<TypedReadWriteTransaction<D>,E> txConsumer)
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()
, or
AsyncWriteTransaction.submit()
(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 ListenableFutures.toCompletionStage(ListenableFuture)
and chaining on
that, or at the very least simply by using
ListenableFutures.addErrorLogging(ListenableFuture, org.slf4j.Logger, String)
(but better NOT by using the blocking Future.get()
on it).
datastoreType
- the Datastore
type that will be accessedtxConsumer
- the InterruptibleCheckedConsumer
that needs a new read-write transactionListenableFuture
returned by AsyncWriteTransaction.submit()
,
or a failed future with an application specific exception (not from submit())@CheckReturnValue <D extends Datastore,E extends Exception> com.google.common.util.concurrent.FluentFuture<Void> callWithNewWriteOnlyTransactionAndSubmit(Class<D> datastoreType, org.opendaylight.infrautils.utils.function.InterruptibleCheckedConsumer<TypedWriteTransaction<D>,E> txConsumer)
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()
, or
AsyncWriteTransaction.submit()
(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 ListenableFutures.toCompletionStage(ListenableFuture)
and chaining on
that, or at the very least simply by using
ListenableFutures.addErrorLogging(ListenableFuture, org.slf4j.Logger, String)
(but better NOT by using the blocking Future.get()
on it).
datastoreType
- the Datastore
type that will be accessedtxConsumer
- the InterruptibleCheckedConsumer
that needs a new write only transactionListenableFuture
returned by AsyncWriteTransaction.submit()
,
or a failed future with an application specific exception (not from submit())Copyright © 2019 OpenDaylight. All rights reserved.